[Webkit-unassigned] [Bug 130967] erroneous date calculations on march 30, 2014 (CET/CEST time zone) the day on which daylight savings time changes

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Oct 21 12:05:26 PDT 2014


https://bugs.webkit.org/show_bug.cgi?id=130967

--- Comment #53 from Mark Lam <mark.lam at apple.com> ---
Comment on attachment 239986
  --> https://bugs.webkit.org/attachment.cgi?id=239986
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=239986&action=review

> Source/JavaScriptCore/runtime/JSDateMath.cpp:199
>      if (!inputIsUTC)

Also, now that you have the WTF::TimeType, please change the gregorianDateTimeToMS() to take a "WTF::TimeType inputTimeType" arg instead of the "bool inputIsUTC".

Similarly, please change msToGregorianDateTime() to take a "WTF::TimeType outputTimeType" arg instead the bool.
Also change setNewValueFromTimeArgs() and setNewValueFromDateArgs() in DatePrototype.cpp accordingly.
Also remove "__ZN3JSC21msToGregorianDateTimeEPNS_9ExecStateEdbRN3WTF17GregorianDateTimeE" and "__ZN3JSC21gregorianDateTimeToMSEPNS_9ExecStateERKN3WTF17GregorianDateTimeEdb" from the JavaScriptCore.order file.

I think this will increase code clarity.

>> Source/WTF/wtf/DateMath.cpp:479
>> +    // Convert local time milliseconds to UTC milliseconds, if input time type is LocalTime.
>> +    double inputTimeOffset = inputTimeType == LocalTime ? calculateUTCOffset() : 0;
>> +    if (inputTimeOffset)
>> +        ms -= inputTimeOffset;
> 
> I would remove this comment and rename “inputTimeOffset” to “localToUTCTimeOffset”.

Upon further review, I see what Darin was suggesting.  Let's re-write this (as Darin suggested) as:

#if HAVE(TM_GMTOFF)
    double utcOffset = inputTimeType == LocalTime ? calculateUTCOffset() : 0;
#else
    double utfOffset = calculateUTCOffset();
#endif

    if (inputTimeType == LocalTime)
        ms -= utcOffset;

This way the utfOffset value is initialized in only one place (for better clarity), and there's no chance of calculateUTCOffset() being called 2 times (for when the local time is UTC time).

> Source/WTF/wtf/DateMath.cpp:511
> -    double utcOffset = calculateUTCOffset();
> +    // If we alredy calculated UTC offset to convert input time, then use it as an offset.
> +    double utcOffset = inputTimeOffset ? inputTimeOffset : calculateUTCOffset();

You can remove this code with the above change.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20141021/728b1ea5/attachment-0002.html>


More information about the webkit-unassigned mailing list