[Issue 2917] std.date fails for all years before 1970

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 14 17:06:15 PDT 2009


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





--- Comment #3 from Glenn Haecker <ghaecker at idworld.net>  2009-05-14 17:06:15 PDT ---
This bit of code shows the bug.  There are larger effects as well.

-------------------------------------------
    string[] testdt = [
        "1969-12-31 23:59:58 UTC",
        "1969-12-31 23:59:59 UTC",
        "1970-01-01 00:00:00 UTC", // epoch
        "1970-01-01 00:00:01 UTC",
        "1970-01-01 00:00:02 UTC"];

    foreach(int i, string s; testdt)
        writefln("%s = %5d", s, parse(s));

    d_time[] times = [-2000,-1000,0,1000,2000];
    foreach(tm; times)
        writefln("%5d = %s", tm, toUTCString(tm));
-------------------------------------------

Unpatched results:

1969-12-31 23:59:58 UTC = -9223372036854775808 (d_time_nan)
1969-12-31 23:59:59 UTC = -9223372036854775808 (d_time_nan)
1970-01-01 00:00:00 UTC =     0
1970-01-01 00:00:01 UTC =  1000
1970-01-01 00:00:02 UTC =  2000
-2000 = Wed, 31 Dec 1969 23:59:57 UTC  (off by 1 sec)
-1000 = Wed, 31 Dec 1969 23:59:58 UTC  (off by 1 sec)
    0 = Thu, 01 Jan 1970 00:00:00 UTC
 1000 = Thu, 01 Jan 1970 00:00:01 UTC
 2000 = Thu, 01 Jan 1970 00:00:02 UTC

Patched results:

1969-12-31 23:59:58 UTC = -2000
1969-12-31 23:59:59 UTC = -1000
1970-01-01 00:00:00 UTC =     0
1970-01-01 00:00:01 UTC =  1000
1970-01-01 00:00:02 UTC =  2000
-2000 = Wed, 31 Dec 1969 23:59:58 UTC
-1000 = Wed, 31 Dec 1969 23:59:59 UTC
    0 = Thu, 01 Jan 1970 00:00:00 UTC
 1000 = Thu, 01 Jan 1970 00:00:01 UTC
 2000 = Thu, 01 Jan 1970 00:00:02 UTC

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


More information about the Digitalmars-d-bugs mailing list