T
Techno_Dex
Correct Most of the Time but Not Always
http://msdn.microsoft.com/en-us/library/system.timezoneinfo.adjustmentrule.aspx
In looking at the sample code MS provided for the TimeZoneInfo class, there
appears to be a bug in the way that it's implemented. Daylight Saving Time
for 2006 and before followed the rule Starts the First Sunday of April and
Ends the Last Sunday of October. Well apparently there is some funny math
going on as well which doesn't appear to be documented. The US doesn't use
a Fixed Day for the DST switch, rather it uses a position day of week in a
month. The issue I'm having is apparent in the Year 2003 where
transitionStart.Week is returning a value of 1 instead of 2.
The C# sample code would indicate in the US that "Every [Sunday] of the
[First] Week of [April] at [2:00AM]" is when DST starts. In the case of the
Year 2003, The First Week of April on a Gregorian calendar does not contain
a Sunday (4/1 is on a Tuesday) but transitionStart indicates that does
because the transitionStart.Week value = 1 when it should equal 2. This
might make sense if the Calendar was Broadcast (i.e. First Day of the Week
is a Monday), but this would then break the "Every [Sunday] of the [Fifth]
Week of [November] at [2:00AM]" code for the transitionEnd which indicates
that the transitionEnd.Week value = 5. There is a flaw in the logic of this
Class. Where the funny math comes in would be if MS is checking that the
Month has changed to something different than the value in the
transitionStart and transitionEnd and either Add 7 Days or Subtract 7 Days
to return the correct value as need. Am I missing something here????
http://msdn.microsoft.com/en-us/library/system.timezoneinfo.adjustmentrule.aspx
In looking at the sample code MS provided for the TimeZoneInfo class, there
appears to be a bug in the way that it's implemented. Daylight Saving Time
for 2006 and before followed the rule Starts the First Sunday of April and
Ends the Last Sunday of October. Well apparently there is some funny math
going on as well which doesn't appear to be documented. The US doesn't use
a Fixed Day for the DST switch, rather it uses a position day of week in a
month. The issue I'm having is apparent in the Year 2003 where
transitionStart.Week is returning a value of 1 instead of 2.
The C# sample code would indicate in the US that "Every [Sunday] of the
[First] Week of [April] at [2:00AM]" is when DST starts. In the case of the
Year 2003, The First Week of April on a Gregorian calendar does not contain
a Sunday (4/1 is on a Tuesday) but transitionStart indicates that does
because the transitionStart.Week value = 1 when it should equal 2. This
might make sense if the Calendar was Broadcast (i.e. First Day of the Week
is a Monday), but this would then break the "Every [Sunday] of the [Fifth]
Week of [November] at [2:00AM]" code for the transitionEnd which indicates
that the transitionEnd.Week value = 5. There is a flaw in the logic of this
Class. Where the funny math comes in would be if MS is checking that the
Month has changed to something different than the value in the
transitionStart and transitionEnd and either Add 7 Days or Subtract 7 Days
to return the correct value as need. Am I missing something here????