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

W

Wayne

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
 
M

Mihai N.

Does anyone know if Microsoft has any guidance for handling these
anomalies?
Will there be another patch?
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.
 
W

Wayne

Mattias Sjögren said:

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://blogs.msdn.com/michkap/archive/2006/12/18/1314233.aspx and
http://msdn2.microsoft.com/en-us/library/ms724253.aspx for more
information). Unfortunately, there's no managed API to access that
information, but it looks like it will be available in Orcas.

Wayne
 
M

Mihai N.


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://blogs.msdn.com/michkap/archive/2007/02/05/1606868.aspx
 
G

Guest

Has there been any reply by Microsoft personnel on this issue? We write
medical software using .NET and need accurate date time values. Applying
this rule to any date will do more harm than good.

Why can't there be a .NET framework QFE that applies the correct rules? We
don't want to make a fix because if Microsoft comes out with a fix, it would
break our fix.

Please let me know what the plan is. Thanks!

- Craig
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top