|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Windows DST patch causes DateTime.IsDaylightSavingTime() to be incorrect for dates in past yearsThe 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 > Does anyone know if Microsoft has any guidance for handling these From the previous experience with other such patches (for othere locales),> anomalies? > Will there be another patch? 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.mihai-nita.net ------------------------------------------ Replace _year_ with _ to get the real email >Does anyone know if Microsoft has any guidance for handling these anomalies? See http://msdn2.microsoft.com/en-us/vstudio/bb264729.aspx>Will there be another patch? Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message Thanks for that pointer. As the article mentions, historical information is news:OCH6vnOTHHA.5060@TK2MSFTNGP02.phx.gbl... > >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 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
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 -- Mihai Nita [Microsoft MVP, Windows - SDK] http://www.mihai-nita.net ------------------------------------------ Replace _year_ with _ to get the real email 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 Show quote "Wayne" wrote: > 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 > > > |
|||||||||||||||||||||||