I want to compute the time 4 hours later during the DST transition, either into DST or out of it.
Currently doing this:
DateTime now = DateTime.now();
DateTime later = now.AddHours(4);
System.Console.WriteLine(now + " isDST " + now.IsDaylightSavingTime());
System.Console.WriteLine(later + " isDST " + later.IsDaylightSavingTime());
Provides:
11/1/2009 12:45:54 AM isDST True
11/1/2009 4:45:54 AM isDST False
What I want to see is:
11/1/2009 12:45:54 AM isDST True
11/1/2009 3:45:54 AM isDST False
The "best" way I've found to do this is to take a round trip through UTC like this:
DateTime now = DateTime.now();
DateTime later = now.ToUniversalTime().AddHours(4).ToLocalTime;
System.Console.WriteLine(now + " isDST " + now.IsDaylightSavingTime());
System.Console.WriteLine(later + " isDST " + later.IsDaylightSavingTime());
It seems I should be able to specify to AddHours() that the time returned should be elapsed time or display time. What am I missing?