www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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");
}


-- 
Feb 16 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=973






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*


-- 
Feb 16 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=973








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)))


-- 
Feb 16 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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 24 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=973


Jonathan M Davis <jmdavisProg gmx.com> changed:

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



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: -------
May 24 2011