Bug 12070 - REGRESSION: KJS::getUTCOffset() caches UTC offset but ignores time zone changes
Summary: REGRESSION: KJS::getUTCOffset() caches UTC offset but ignores time zone changes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: Regression
Depends on:
Blocks:
 
Reported: 2007-01-02 07:08 PST by David Kilzer (:ddkilzer)
Modified: 2007-06-24 12:04 PDT (History)
1 user (show)

See Also:


Attachments
Patch v1 (1.70 KB, patch)
2007-01-03 22:01 PST, David Kilzer (:ddkilzer)
kmccullough: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2007-01-02 07:08:28 PST
The KJS::getUTCOffset() method in JavaScriptCore/kjs/DateMath.cpp caches the UTC offset, but it never checks to see if the time zone has changed after caching the value (e.g., if a user opened the Date & Time system preference pane and changed their Mac's time zone).

This doesn't seem to cause any issues (e.g., when running the test for Bug 12057), but I'd like to do further testing.  This bug is a reminder to do that.
Comment 1 David Kilzer (:ddkilzer) 2007-01-02 20:14:52 PST
Caching the UTC offset does create problems when changing the time zone through the Date & Time system preferences pane.  It may be as simple as reporting the wrong time zone (reporting a daylight saving time zone when it's not daylight saving time) to reporting the wrong time zone offset (e.g., +1800 instead of -0600).

Steps to reproduce:

1. Quit WebKit.
2. Set time zone to "London - England" (GMT +0000) in Date & Time pane.
3. Open WebKit.
4. Open this URL:  javascript:alert(new Date())
5. Set time zone to "Chicago - U.S.A." (CST -0600) in Date & Time pane.
6. Open this URL again: javascript:alert(new Date())

Expected results:

Time zone should be reported as -0600 (CST) with the correct date and time.

Actual results:

Time zone is reported as +1800 (CDT) (or similar).

Comment 2 David Kilzer (:ddkilzer) 2007-01-02 20:22:19 PST
(In reply to comment #1)
> Caching the UTC offset does create problems when changing the time zone through
> the Date & Time system preferences pane.  It may be as simple as reporting the
> wrong time zone (reporting a daylight saving time zone when it's not daylight
> saving time) to reporting the wrong time zone offset (e.g., +1800 instead of
> -0600).

To be more specific, it may be as simple as the wrong time zone being reported (but the correct time), to reporting the wrong time zone offset, the wrong time zone (in DST when it shouldn't be) and a date in the future!

Comment 3 David Kilzer (:ddkilzer) 2007-01-02 20:27:10 PST
Confirmed that this is a regression from shipping Safari 2.0.4 (419.3) on Mac OS X 10.4.8 (8N1037).  Tested on locally-built debug build of WebKit r18541.

There are basically two solutions:

1. Don't cache the UTC offset.
2. Cache the UTC offset and check for time zone changes to determine if it needs to be recalculated.

Comment 4 David Kilzer (:ddkilzer) 2007-01-03 22:01:52 PST
Created attachment 12205 [details]
Patch v1

If the user changes time zones without restarting a WebKit application like Safari, the cached UTC offset will cause JavaScript to report the wrong time zone and/or the wrong time.  The simple solution is to stop caching the UTC offset and calculate it every time.  That's what this patch does.

Note that no performance testing has been done.
Comment 5 David Kilzer (:ddkilzer) 2007-01-04 21:57:26 PST
Committed by Kevin McCullough in r18584.

Comment 6 David Kilzer (:ddkilzer) 2007-06-24 12:04:45 PDT
Mass removal of NeedsRadar keyword from my bugs that have already been RESOLVED.