title: Why doesn't subtracting two local DateTime values appear to account for Daylight Saving Time?
body: <p>I'm playing with some C# code to try to gain an understanding of how subtracting DateTime objects in C# works with respect to Daylight Saving Time.</p>
  
  <p>Per Google and other sources, the Daylight Saving Time "spring ahead" event in the Eastern Standard Time zone in 2017 was at 2:00am on March 12.  So, the first few hours of the day on that date were:</p>
  
  <pre><code>   12:00am - 1:00am
      1:00am - 2:00am
     (There was no 2:00am - 3:00am hour due to the "spring ahead")
      3:00am - 4:00am
  </code></pre>
  
  <p>So, if I were to calculate the time differential between 1:00am and 4:00am in that time zone on that date, I'd expect the result to be <strong>2</strong> hours.</p>
  
  <p>However, the code I put together to try to simulate this problem is returning a <strong>3</strong> hour TimeSpan.</p>
  
  <p>Code:</p>
  
  <pre><code>TimeZoneInfo easternStandardTime = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
  
  DateTime oneAm = TimeZoneInfo.ConvertTime(new DateTime(2017, 03, 12, 01, 00, 00), easternStandardTime);
  DateTime fourAm = TimeZoneInfo.ConvertTime(new DateTime(2017, 03, 12, 04, 00, 00), easternStandardTime);
  
  TimeSpan difference = (fourAm - oneAm);
  
  Console.WriteLine(oneAm);
  Console.WriteLine(fourAm);
  Console.WriteLine(TimeZoneInfo.Local.IsDaylightSavingTime(oneAm));
  Console.WriteLine(TimeZoneInfo.Local.IsDaylightSavingTime(fourAm));
  Console.WriteLine(difference);
  </code></pre>
  
  <p>On my PC, this generates:</p>
  
  <pre><code>2017-03-12 01:00:00.000 -5
  2017-03-12 04:00:00.000 -4
  False
  True
  03:00:00
  </code></pre>
  
  <p>All of that output is as expected -- except that final value of 3 hours, which as I noted above, I would expect to be 2 hours instead.</p>
  
  <p>Obviously, my code isn't correctly simulating the situation that I have in mind.  What is the flaw?</p>