Changeset 18514 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jan 1, 2007, 8:19:35 PM (18 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/DateMath.cpp

    r17520 r18514  
    11/*
    22 * Copyright (C) 1999-2000 Harri Porten ([email protected])
    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.