[Issue 973] New: [std.date] DST (daylight savings time) not applied in southern hemisphere

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 16 20:19:31 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=973

           Summary: [std.date] DST (daylight savings time) not applied in
                    southern hemisphere
           Product: D
           Version: 1.006
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: chrisp at inventivedingo.com


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");
}


-- 



More information about the Digitalmars-d-bugs mailing list