How does .NET determine the week in a TimeZoneInfo.TransitionTime ?

Posted by Travis Brooks on Stack Overflow See other posts from Stack Overflow or by Travis Brooks
Published on 2010-05-10T22:16:16Z Indexed on 2010/05/10 22:24 UTC
Read the original article Hit count: 448

Filed under:

Greetings

I'm trying to do some DateTime math for various time zones and I wanted to take daylight savings into account. Lets say I have a TimeZoneInfo and i've determined the appropriate AdjustmentRule for a given DateTime. Lets also say the particular TimeZoneInfo i'm dealing with is specified as rule.DaylightTransitionStart.IsFixedDateRule == false, so I need to figure out if the given DateTime falls within the start/end TransitionTime.Week values.

This is where I'm getting confused, what is .NET considering as a "week"? My first thought was it probably used something like

DayOfWeek thisMarksWeekBoundaries = Thread.CurrentThread.CurrentUICulture.DateTimeFormat.FirstDayOfWeek;

and went through the calendar assigning days to week, incrementing week every time it crossed a boundary. But, if I do this for May 2010 there are 6 week boundary buckets, and the max valid value for TransitionTime.Week is 5 so this can't be right.

Whats the right way to slice up May 2010?

© Stack Overflow or respective owner

Related posts about c#