digitalmars.D.bugs - [Issue 1436] New: std.date.getLocalTZA() returns wrong values when in DST under Windows
- d-bugmail puremagic.com (50/50) Aug 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1436
- d-bugmail puremagic.com (9/9) Sep 28 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1436
http://d.puremagic.com/issues/show_bug.cgi?id=1436 Summary: std.date.getLocalTZA() returns wrong values when in DST under Windows Product: D Version: 1.020 Platform: All OS/Version: Windows Status: NEW Keywords: patch, wrong-code Severity: normal Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: deewiant gmail.com Currently, getLocalTZA() does the following: -- r = GetTimeZoneInformation(&tzi); switch (r) { case TIME_ZONE_ID_STANDARD: case TIME_ZONE_ID_DAYLIGHT: case TIME_ZONE_ID_UNKNOWN: t = -(tzi.Bias + tzi.StandardBias) * cast(d_time)(60 * TicksPerSecond); break; default: t = 0; break; } return t; -- As can be seen, it always uses the StandardBias field, as long as GetTimeZoneInformation doesn't result in an error. However, this is incorrect. When TIME_ZONE_ID_DAYLIGHT is returned, the DaylightBias field should be used, as this indicates that the system is currently using Daylight Savings Time. StandardBias is meant to be used only when the system is not in DST, as documented at http://msdn.microsoft.com/library/en-us/sysinfo/base/gettimezoneinformation.asp and http://msdn2.microsoft.com/en-us/library/ms725481.aspx One possible working version follows: -- r = GetTimeZoneInformation(&tzi); switch (r) { case TIME_ZONE_ID_STANDARD: t = tzi.Bias + tzi.StandardBias; break; case TIME_ZONE_ID_DAYLIGHT: t = tzi.Bias + tzi.DaylightBias; break; case TIME_ZONE_ID_UNKNOWN: t = tzi.Bias; break; default: t = 0; break; } return -t * cast(d_time)(60 * TicksPerSecond); --
Aug 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1436 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from bugzilla digitalmars.com 2007-09-28 22:13 ------- Fixed dmd 1.021 and 2.004 --
Sep 28 2007