Changeset 18514 in webkit


Ignore:
Timestamp:
Jan 1, 2007 8:19:35 PM (17 years ago)
Author:
ddkilzer
Message:

JavaScriptCore:

Reviewed by Darin.

Because Mac OS X returns geographically and historically accurate time zone information,
converting Jan 02, 1970 12:00:00 AM to local time then subtracting 24 hours did not work
in GMT (London - England) since it was in BST (+0100) all year in 1970[1]. Instead, the
UTC offset is calculated by converting Jan 01, 2000 12:00:00 AM to local time then
subtracting that from the same date in UTC.

[1] http://en.wikipedia.org/wiki/British_Summer_Time

  • kjs/DateMath.cpp: (KJS::getUTCOffset): Updated UTC offset calculation. (KJS::getDSTOffset): Improved comment.
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r18498 r18514  
     12007-01-01  David Kilzer  <ddkilzer@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=12057
     6          REGRESSION: JavaScript Date Is One Day In The Future in GMT time zone
     7
     8        Because Mac OS X returns geographically and historically accurate time zone information,
     9        converting Jan 02, 1970 12:00:00 AM to local time then subtracting 24 hours did not work
     10        in GMT (London - England) since it was in BST (+0100) all year in 1970[1].  Instead, the
     11        UTC offset is calculated by converting Jan 01, 2000 12:00:00 AM to local time then
     12        subtracting that from the same date in UTC.
     13
     14        [1] http://en.wikipedia.org/wiki/British_Summer_Time
     15
     16        * kjs/DateMath.cpp:
     17        (KJS::getUTCOffset): Updated UTC offset calculation.
     18        (KJS::getDSTOffset): Improved comment.
     19
    1202006-12-31  David Kilzer  <ddkilzer@webkit.org>
    221
  • trunk/JavaScriptCore/kjs/DateMath.cpp

    r17520 r18514  
    11/*
    22 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  * Copyright (C) 2006 Apple Computer
     3 * Copyright (C) 2006-2007 Apple Computer
    44 *
    55 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
     
    300300
    301301        memset(&localt, 0, sizeof(localt));
    302        
    303         // get the difference between this time zone and GMT
    304         localt.tm_mday = 2;
    305         localt.tm_year = 70;
    306 
    307         utcOffset = mktime(&localt) - (hoursPerDay * secondsPerHour);
    308         utcOffset *= -msPerSecond;
     302
     303        // get the difference between this time zone and UTC on Jan 01, 2000 12:00:00 AM
     304        localt.tm_mday = 1;
     305        localt.tm_year = 100;
     306        utcOffset = 946684800.0 - mktime(&localt);
     307
     308        utcOffset *= msPerSecond;
    309309
    310310        utcOffsetInitialized = true;
     
    359359    // determining DST.  For this reason we shift years that localtime can handle but would
    360360    // return historically accurate information.
    361    
    362     //if before 2000 or after 2038
     361
     362    // if before Jan 01, 2000 12:00:00 AM UTC or after Jan 01, 2038 12:00:00 AM UTC
    363363    if (ms < 946684800000.0 || ms > 2145916800000.0) {
    364364        int year;
Note: See TracChangeset for help on using the changeset viewer.