JavaScript
/*
This script (Javascript Timezone Detection) detects Olson timezone
ID of user's system's timezone using getTimezoneOffset(). Detection
is tested and passed 100% in the following conditions:
* Windows 7,Opera 11.00
* Windows 7,Firefox 3.6.13
* Windows 7,Safari 5.0.3
* Windows 7,Google Chrome 8.0.552.237
* Windows 7,Internet Explorer 8.0.7600.16385
* Mac OS X,Google Chrome 8.0.552.237
* Mac OS X,Firefox 3.6.13
* Mac OS X,Opera 11.01
* Mac OS X,Safari Version 5.0.3
* Centos 5,Firefox 3.6.13
* Centos 5,Safari
* Centos 5,Opera 11.00
The script has ability to detect 90 timezones.
Every row in zones-array consist of
0: Olson timezone ID,
1-6: Transition start time in UTC (usually summer time start and sometimes winter time start)
7: Utc offset in minutes
8: 1 = has transition,0 = has not transition
Timezones are listed in zones-array this way:
- first comes section of timezones, that have transitions and then section of timezones that have no transitions
- Both sections are then ordered by offset
- Finally the has transitions section is ordered by the transition start time.
If you add more timezones or replaces some, please be sure to maintain this order, otherwise the detection fails in some cases.
Minified size: about 4.46KB
*/
var zones = new Array(
// FIRST DST TIMEZONES
[ 'Pacific/Apia', 2011,3,3,11,0,0, -660, 1 ]/* For Opera Linux. Unexpectedly winter-offset. */,
[ 'Pacific/Apia', 2010,8,26,11,0,0, -600, 1 ]/* STD: -660 */,
[ 'America/Adak', 2011,2,13,12,0,0, -540, 1 ]/* STD: -600 */,
[ 'America/Anchorage', 2011,2,13,11,0,0, -480, 1 ]/* STD: -540 */,
[ 'America/Los_Angeles', 2011,2,13,10,0,0, -420, 1 ]/* STD: -480 */,
[ 'America/Santa_Isabel', 2011,3,3,10,0,0, -420, 1 ]/* STD: -480 */,
[ 'America/Denver', 2011,2,13,9,0,0, -360, 1 ]/* STD: -420 */,
[...