Bug 973 – [std.date] DST (daylight savings time) not applied in southern hemisphere
Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-02-16T22:19:00Z
Last change time
2015-11-03T17:38:39Z
Keywords
patch
Assigned to
nobody
Creator
chrisp
Comments
Comment #0 by chrisp — 2007-02-16T22:19:22Z
The function DaylightSavingTA in Phobos' std.date module always returns 0 when run in a southern hemisphere locale, under Windows.
This is because it implicitly assumes that daylight saving time ends at a later date (in the year) than it begins. This is only true for the northern hemisphere. In Australia, for example, DST typically begins in October and ends in March.
The assumption is on line 803 of phobos/std/date.d:
if (td <= dt && dt <= ts) // line 803 containing incorrect assumption
{
t = -tzi.DaylightBias * (60 * TicksPerSecond);
//printf("DST is in effect, %d\n", t);
}
else
{
//printf("no DST\n");
}
Possible (but untested) fix:
if ((td <= dt && dt <= ts) || td <= ts || dt >= td)
{
t = -tzi.DaylightBias * (60 * TicksPerSecond);
//printf("DST is in effect, %d\n", t);
}
else
{
//printf("no DST\n");
}
Comment #1 by chrisp — 2007-02-16T22:27:24Z
Oops - typo in my suggested fix, plus it would actually break northern hemisphere usage. Here's a better one:
if ((td <= dt && dt <= ts) || (ts > td && (td <= dt || dt <= ts)))
I /think/ that's correct. Having trouble with all these 2-letter variable names. *g*
Comment #2 by chrisp — 2007-02-16T22:31:08Z
(In reply to comment #1)
Doh. Had a comparison sign the wrong way around. Sorry about this! Third time lucky?
if ((td <= dt && dt <= ts) || (ts < td && (dt <= ts || td <= dt)))
Comment #3 by andrej.mitrovich — 2011-05-24T23:34:38Z
Probably fixed in datetime. Close it?
Comment #4 by issues.dlang — 2011-05-24T23:44:21Z
It's a D1 bug, since std.date is still around in D1.
Comment #5 by andrei — 2015-11-03T17:38:39Z
It's unlikely this D1 issue will get worked on, if anyone plans to work on it feel free to reopen.