Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past years

Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past years

Post by Wayn » Sun, 11 Feb 2007 10:18:55


An interesting problem has arisen concerning the new Windows DST patches.
The rules seem to apply without regard to year. For example, run the
following C# code (assume you're running in the US Eastern time zone):

DateTime d = new DateTime(2006, 11, 1);
Console.WriteLine(d.ToString("dd MMM yyyy hh:mm tt zzz ") + " " +
d.IsDaylightSavingTime());
DateTime d2 = new DateTime(2007, 11, 1);
Console.WriteLine(d2.ToString("dd MMM yyyy hh:mm tt zzz ") + " " +
d2.IsDaylightSavingTime());

If the DST patch has been applied, you will get the following output:

01 Nov 2006 12:00 AM -04:00 True
01 Nov 2007 12:00 AM -04:00 True

The result for 1 Nov 2006 is incorrect -- it was not DST, but it would have
been had the new rules been in effect.

It appears that if the DST patch is applied, then for past years there is a
two week period in March/April, and a one week period in October/November
when IsDaylightSavingTime() will be incorrect, since during those periods
the new rules will yield incorrect results.

Does anyone know if Microsoft has any guidance for handling these anomalies?
Will there be another patch?

Wayne
 
 
 

Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past years

Post by Mihai N » Sun, 11 Feb 2007 13:03:50

> Does anyone know if Microsoft has any guidance for handling these
From the previous experience with other such patches (for othere locales),
no, there will be no extra fix.
Windows does not have any "historical data" on DST or calendar changes,
and does not seem to have any code able to deal with such historical data.


--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.yqcomputer.com/
------------------------------------------
Replace _year_ with _ to get the real email

 
 
 

Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past years

Post by Mattias Sj » Sun, 11 Feb 2007 17:03:09

>Does anyone know if Microsoft has any guidance for handling these anomalies?

See http://www.yqcomputer.com/


Mattias

--
Mattias Sjren [C# MVP] mattias @ mvps.org
http://www.yqcomputer.com/ | http://www.yqcomputer.com/
Please reply only to the newsgroup.
 
 
 

Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past years

Post by Wayn » Mon, 12 Feb 2007 03:40:34


Thanks for that pointer. As the article mentions, historical information is
available in Windows Vista. Unfortunately, it's only available through an
unmanaged API (see
http://www.yqcomputer.com/
http://www.yqcomputer.com/
information). Unfortunately, there's no managed API to access that
information, but it looks like it will be available in Orcas.

Wayne
 
 
 

Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past years

Post by Mihai N » Mon, 12 Feb 2007 05:48:51

>

Quote:
========
Windows Vista offers support for multiple time zones, but the actual data in
the registry provides for two adjustment rules in the United States. This
means that historic time zone information is accurate from 1986 onward (the
current adjustment rules, which are replaced by the DST changes, date to
1986), but is inaccurate for dates before 1986
========

This "smells" like a patch for U.S. only :-(

Many countries have been affected by this kind of changes before, but it had
to happen in the US to get some realization from MS.
And even then, all they did was hack the US data only.

Ad to this the hard-coded time zone info in WinMobile 5 (in a dll, instead of
registry), and is a clear indication that "Microsoft does not get time zones"
http://www.yqcomputer.com/




--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.yqcomputer.com/
------------------------------------------
Replace _year_ with _ to get the real email