Can someone explain how a DaylightSavingsRule can have a “StartMonth” after it's “EndMonth”?

StackOverflow https://stackoverflow.com/questions/824641

  •  05-07-2019
  •  | 
  •  

Question

Using C# (the .NET framework), I'm looping through all the TimeZones and their AdjustmentRules... and for "Mauritius Standard Time" {(GMT+04:00) Port Louis)} - the adjustment rule is as follows:

IsFixed = false;
DaylightTransitionStart.Month = 10;
DaylightTransitionEnd.Month = 1;

From what I understand, 'IsFixed=false' means that I do not use the "StartDate" and "EndDate" fields... but rather, I need to use the DaylightTransitionStart and End to dynamically determine if the time is in daylight time or not.

THE PROBLEM here is that, for about 30 transition rules, the "StartMonth" is AFTER the "EndMonth"

How can DaylightSavingsTime start in 'October 2008' and end in 'January 2008'?

Please help me to understand this... once I get past this hurdle, I should have a complete "convert any time to and from UTC with any time zone for all history" SQL function written.

Was it helpful?

Solution

A period of time cannot logically end before it starts, but perhaps you're assuming that these months refer to months of the same year when in fact OCT might be in 2008 but JAN is in 2009.

Think of it as a circularly-linked-list.

The DaylightTime class uses a DateTime for both start and end of the daylight-saving period, hence both specify a year.

OTHER TIPS

Wouldn't this be the case for countries south of the Equator?

Theres this thing called the southern hemisphere. Maybe you've heard of it.

In Australia daylight savings starts around October and ends around March (in the states that have it).

could be in the southern hemisphere, DST starts in october and ends in march in some parts of Australia

Two different years. e.g. start year 09 end year 10

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top