Bug 120556
| Summary: | Date#getTimezoneOffset should be dynamic | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | bga_ <bga.email> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | UNCONFIRMED | ||
| Severity: | Normal | CC: | ggaren, oliver, zan |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
bga_
alert((new Date()).getTimezoneOffset())
change TZ
alert((new Date()).getTimezoneOffset())
no changes
value changes in MSIE and Opera
value not changes in Webkit and Gecko
its important for web apps that you use in car/air traveling (and TZ changes continuasly), user want to see correct time
tested on WinXP SP2
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Zan Dobersek
In WTF::getLocalTime()[1], localtime_r() is called for platforms using compilers other than MinGW or MSVC to get the necessary time information. This doesn't take the timezone into consideration since tzset() isn't called beforehand and localtime_r() isn't required to call it (like localtime() is)[2].
To avoid that, tzset() should be called, or localtime() should be used instead.
[1] http://trac.webkit.org/browser/trunk/Source/WTF/wtf/DateMath.cpp#L135
[2] http://linux.die.net/man/3/localtime_r
Oliver Hunt
I believe this is a deliberate choice - re-fetching timezone information used to be a significant performance problem and TZ is not something that changes regularly.
Maybe this is worth reinvestigating?
Zan Dobersek
Note that when outputting the Date object as a string[1], format-printing the timezone abbreviation calls tzset(), so this occurs:
>>> (new Date())
Sat Aug 31 2013 11:34:06 GMT-0700 (PDT)
** timezone change **
>>> (new Date())
Sat Aug 31 2013 11:34:33 GMT-0700 (CEST) // Timezone name correct, offset not.
>>> (new Date())
Sat Aug 31 2013 20:34:38 GMT+0200 (CEST) // All fine.
[1] http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/DateConversion.cpp#L112