Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / February 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wayne - 10 Feb 2007 01:18 GMT
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
Mihai N. - 10 Feb 2007 04:03 GMT
> 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.

Signature

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

Mattias Sjögren - 10 Feb 2007 08:03 GMT
>Does anyone know if Microsoft has any guidance for handling these anomalies?
>Will there be another patch?

See http://msdn2.microsoft.com/en-us/vstudio/bb264729.aspx

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Wayne - 10 Feb 2007 18:40 GMT
> >Does anyone know if Microsoft has any guidance for handling these
> >anomalies?
>>Will there be another patch?
>
> See http://msdn2.microsoft.com/en-us/vstudio/bb264729.aspx

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
Mihai N. - 10 Feb 2007 20:48 GMT
> See http://msdn2.microsoft.com/en-us/vstudio/bb264729.aspx

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

Signature

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

Craig - 26 Feb 2007 18:43 GMT
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

> An interesting problem has arisen concerning the new Windows DST patches.
> The rules seem to apply without regard to year.  For example, run the
[quoted text clipped - 24 lines]
>
> Wayne

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.