Changeset 44842 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Jun 18, 2009, 10:06:55 PM (16 years ago)
Author:
[email protected]
Message:

2009-06-18 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

Timezone calculation incorrect in Venezuela.

https://bugs.webkit.org/show_bug.cgi?id=26531
<rdar://problem/6646169> Time is incorrectly reported to JavaScript in both Safari 3 and Firefox 3

The problem is that we're calculating the timezone relative to 01/01/2000,
but the VET timezone changed from -4 hours to -4:30 hours on 12/09/2007.
According to the spec, section 15.9.1.9 states "the time since the beginning
of the year", presumably meaning the *current* year. Change the calculation
to be based on whatever the current year is, rather than a canned date.

No performance impact.

  • wtf/DateMath.cpp: (WTF::calculateUTCOffset):
File:
1 edited

Legend:

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

    r44765 r44842  
    362362static int32_t calculateUTCOffset()
    363363{
     364    time_t localTime = time(0);
    364365    tm localt;
    365     memset(&localt, 0, sizeof(localt));
    366  
    367     // get the difference between this time zone and UTC on Jan 01, 2000 12:00:00 AM
     366    getLocalTime(&localTime, &localt);
     367
     368    // Get the difference between this time zone and UTC on the 1st of January of this year.
     369    localt.tm_sec = 0;
     370    localt.tm_min = 0;
     371    localt.tm_hour = 0;
    368372    localt.tm_mday = 1;
    369     localt.tm_year = 100;
    370     time_t utcOffset = 946684800 - mktime(&localt);
     373    localt.tm_mon = 0;
     374    // Not setting localt.tm_year!
     375    localt.tm_wday = 0;
     376    localt.tm_yday = 0;
     377    localt.tm_isdst = 0;
     378    localt.tm_zone = 0;
     379    localt.tm_gmtoff = 0;
     380    time_t utcOffset = timegm(&localt) - mktime(&localt);
    371381
    372382    return static_cast<int32_t>(utcOffset * 1000);
Note: See TracChangeset for help on using the changeset viewer.