Thread overview
[Issue 973] New: [std.date] DST (daylight savings time) not applied in southern hemisphere
Feb 17, 2007
d-bugmail
Feb 17, 2007
d-bugmail
Feb 17, 2007
d-bugmail
May 25, 2011
Andrej Mitrovic
May 25, 2011
Jonathan M Davis
February 17, 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@digitalmars.com
        ReportedBy: chrisp@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");
}


-- 

February 17, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=973





------- Comment #1 from chrisp@inventivedingo.com  2007-02-16 22:27 -------
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*


-- 

February 17, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=973





------- Comment #2 from chrisp@inventivedingo.com  2007-02-16 22:31 -------
(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)))


-- 

May 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=973


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-24 23:34:38 PDT ---
Probably fixed in datetime. Close it?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=973


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-05-24 23:44:21 PDT ---
It's a D1 bug, since std.date is still around in D1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------