Mercurial > hg > rc2
comparison program/js/jstz.min.js @ 8:bf99236cc5cd default tip
try to recover from upgrade fail
author | Charlie Root |
---|---|
date | Sat, 29 Dec 2018 07:07:34 -0500 |
parents | 4681f974d28b |
children |
comparison
equal
deleted
inserted
replaced
7:65fd7d441cf1 | 8:bf99236cc5cd |
---|---|
1 /** | 1 /** |
2 * jsTimezoneDetect - v1.0.6 | 2 * This script gives you the zone info key representing your device's time zone setting. |
3 * | 3 * |
4 * @source https://bitbucket.org/pellepim/jstimezonedetect/raw/6c427658686c664da52c6a87cd62ec910baab276/dist/jstz.js | 4 * @name jsTimezoneDetect |
5 * @version 1.0.5 | |
6 * @author Jon Nylander | |
7 * @license MIT License - http://www.opensource.org/licenses/mit-license.php | |
5 * | 8 * |
6 * @licstart The following is the entire license notice for the | 9 * For usage and examples, visit: |
7 * JavaScript code in this file. | 10 * http://pellepim.bitbucket.org/jstz/ |
8 * | 11 * |
9 * Copyright (c) Jon Nylander | 12 * Copyright (c) Jon Nylander |
10 * | |
11 * Licensed under the MIT licenses | |
12 * | |
13 * Permission is hereby granted, free of charge, to any person obtaining | |
14 * a copy of this software and associated documentation files (the | |
15 * "Software"), to deal in the Software without restriction, including | |
16 * without limitation the rights to use, copy, modify, merge, publish, | |
17 * distribute, sublicense, and/or sell copies of the Software, and to | |
18 * permit persons to whom the Software is furnished to do so, subject to | |
19 * the following conditions: | |
20 * | |
21 * The above copyright notice and this permission notice shall be | |
22 * included in all copies or substantial portions of the Software. | |
23 * | |
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
31 * | |
32 * @licend The above is the entire license notice | |
33 * for the JavaScript code in this file. | |
34 */ | 13 */ |
35 /* jstz.min.js Version: 1.0.6 Build date: 2015-11-04 */ | 14 |
36 !function(e){var a=function(){"use strict";var e="s",s={DAY:864e5,HOUR:36e5,MINUTE:6e4,SECOND:1e3,BASELINE_YEAR:2014,MAX_SCORE:864e6,AMBIGUITIES:{"America/Denver":["America/Mazatlan"],"Europe/London":["Africa/Casablanca"],"America/Chicago":["America/Mexico_City"],"America/Asuncion":["America/Campo_Grande","America/Santiago"],"America/Montevideo":["America/Sao_Paulo","America/Santiago"],"Asia/Beirut":["Asia/Amman","Asia/Jerusalem","Europe/Helsinki","Asia/Damascus","Africa/Cairo","Asia/Gaza","Europe/Minsk"],"Pacific/Auckland":["Pacific/Fiji"],"America/Los_Angeles":["America/Santa_Isabel"],"America/New_York":["America/Havana"],"America/Halifax":["America/Goose_Bay"],"America/Godthab":["America/Miquelon"],"Asia/Dubai":["Asia/Yerevan"],"Asia/Jakarta":["Asia/Krasnoyarsk"],"Asia/Shanghai":["Asia/Irkutsk","Australia/Perth"],"Australia/Sydney":["Australia/Lord_Howe"],"Asia/Tokyo":["Asia/Yakutsk"],"Asia/Dhaka":["Asia/Omsk"],"Asia/Baku":["Asia/Yerevan"],"Australia/Brisbane":["Asia/Vladivostok"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Majuro":["Asia/Kamchatka","Pacific/Fiji"],"Pacific/Tongatapu":["Pacific/Apia"],"Asia/Baghdad":["Europe/Minsk","Europe/Moscow"],"Asia/Karachi":["Asia/Yekaterinburg"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"]}},i=function(e){var a=-e.getTimezoneOffset();return null!==a?a:0},r=function(){var a=i(new Date(s.BASELINE_YEAR,0,2)),r=i(new Date(s.BASELINE_YEAR,5,2)),n=a-r;return 0>n?a+",1":n>0?r+",1,"+e:a+",0"},n=function(){var e,a;if("undefined"!=typeof Intl&&"undefined"!=typeof Intl.DateTimeFormat&&(e=Intl.DateTimeFormat(),"undefined"!=typeof e&&"undefined"!=typeof e.resolvedOptions))return a=e.resolvedOptions().timeZone,a&&(a.indexOf("/")>-1||"UTC"===a)?a:void 0},o=function(e){for(var a=new Date(e,0,1,0,0,1,0).getTime(),s=new Date(e,12,31,23,59,59).getTime(),i=a,r=new Date(i).getTimezoneOffset(),n=null,o=null;s-864e5>i;){var t=new Date(i),A=t.getTimezoneOffset();A!==r&&(r>A&&(n=t),A>r&&(o=t),r=A),i+=864e5}return n&&o?{s:u(n).getTime(),e:u(o).getTime()}:!1},u=function l(e,a,i){"undefined"==typeof a&&(a=s.DAY,i=s.HOUR);for(var r=new Date(e.getTime()-a).getTime(),n=e.getTime()+a,o=new Date(r).getTimezoneOffset(),u=r,t=null;n-i>u;){var A=new Date(u),c=A.getTimezoneOffset();if(c!==o){t=A;break}u+=i}return a===s.DAY?l(t,s.HOUR,s.MINUTE):a===s.HOUR?l(t,s.MINUTE,s.SECOND):t},t=function(e,a,s,i){if("N/A"!==s)return s;if("Asia/Beirut"===a){if("Africa/Cairo"===i.name&&13983768e5===e[6].s&&14116788e5===e[6].e)return 0;if("Asia/Jerusalem"===i.name&&13959648e5===e[6].s&&14118588e5===e[6].e)return 0}else if("America/Santiago"===a){if("America/Asuncion"===i.name&&14124816e5===e[6].s&&1397358e6===e[6].e)return 0;if("America/Campo_Grande"===i.name&&14136912e5===e[6].s&&13925196e5===e[6].e)return 0}else if("America/Montevideo"===a){if("America/Sao_Paulo"===i.name&&14136876e5===e[6].s&&1392516e6===e[6].e)return 0}else if("Pacific/Auckland"===a&&"Pacific/Fiji"===i.name&&14142456e5===e[6].s&&13961016e5===e[6].e)return 0;return s},A=function(e,i){for(var r=function(a){for(var r=0,n=0;n<e.length;n++)if(a.rules[n]&&e[n]){if(!(e[n].s>=a.rules[n].s&&e[n].e<=a.rules[n].e)){r="N/A";break}if(r=0,r+=Math.abs(e[n].s-a.rules[n].s),r+=Math.abs(a.rules[n].e-e[n].e),r>s.MAX_SCORE){r="N/A";break}}return r=t(e,i,r,a)},n={},o=a.olson.dst_rules.zones,u=o.length,A=s.AMBIGUITIES[i],c=0;u>c;c++){var m=o[c],l=r(o[c]);"N/A"!==l&&(n[m.name]=l)}for(var f in n)if(n.hasOwnProperty(f))for(var d=0;d<A.length;d++)if(A[d]===f)return f;return i},c=function(e){var s=function(){for(var e=[],s=0;s<a.olson.dst_rules.years.length;s++){var i=o(a.olson.dst_rules.years[s]);e.push(i)}return e},i=function(e){for(var a=0;a<e.length;a++)if(e[a]!==!1)return!0;return!1},r=s(),n=i(r);return n?A(r,e):e},m=function(){var e=n();return e||(e=a.olson.timezones[r()],"undefined"!=typeof s.AMBIGUITIES[e]&&(e=c(e))),{name:function(){return e}}};return{determine:m}}();a.olson=a.olson||{},a.olson.timezones={"-720,0":"Etc/GMT+12","-660,0":"Pacific/Pago_Pago","-660,1,s":"Pacific/Apia","-600,1":"America/Adak","-600,0":"Pacific/Honolulu","-570,0":"Pacific/Marquesas","-540,0":"Pacific/Gambier","-540,1":"America/Anchorage","-480,1":"America/Los_Angeles","-480,0":"Pacific/Pitcairn","-420,0":"America/Phoenix","-420,1":"America/Denver","-360,0":"America/Guatemala","-360,1":"America/Chicago","-360,1,s":"Pacific/Easter","-300,0":"America/Bogota","-300,1":"America/New_York","-270,0":"America/Caracas","-240,1":"America/Halifax","-240,0":"America/Santo_Domingo","-240,1,s":"America/Asuncion","-210,1":"America/St_Johns","-180,1":"America/Godthab","-180,0":"America/Argentina/Buenos_Aires","-180,1,s":"America/Montevideo","-120,0":"America/Noronha","-120,1":"America/Noronha","-60,1":"Atlantic/Azores","-60,0":"Atlantic/Cape_Verde","0,0":"UTC","0,1":"Europe/London","60,1":"Europe/Berlin","60,0":"Africa/Lagos","60,1,s":"Africa/Windhoek","120,1":"Asia/Beirut","120,0":"Africa/Johannesburg","180,0":"Asia/Baghdad","180,1":"Europe/Moscow","210,1":"Asia/Tehran","240,0":"Asia/Dubai","240,1":"Asia/Baku","270,0":"Asia/Kabul","300,1":"Asia/Yekaterinburg","300,0":"Asia/Karachi","330,0":"Asia/Kolkata","345,0":"Asia/Kathmandu","360,0":"Asia/Dhaka","360,1":"Asia/Omsk","390,0":"Asia/Rangoon","420,1":"Asia/Krasnoyarsk","420,0":"Asia/Jakarta","480,0":"Asia/Shanghai","480,1":"Asia/Irkutsk","525,0":"Australia/Eucla","525,1,s":"Australia/Eucla","540,1":"Asia/Yakutsk","540,0":"Asia/Tokyo","570,0":"Australia/Darwin","570,1,s":"Australia/Adelaide","600,0":"Australia/Brisbane","600,1":"Asia/Vladivostok","600,1,s":"Australia/Sydney","630,1,s":"Australia/Lord_Howe","660,1":"Asia/Kamchatka","660,0":"Pacific/Noumea","690,0":"Pacific/Norfolk","720,1,s":"Pacific/Auckland","720,0":"Pacific/Majuro","765,1,s":"Pacific/Chatham","780,0":"Pacific/Tongatapu","780,1,s":"Pacific/Apia","840,0":"Pacific/Kiritimati"},a.olson.dst_rules={years:[2008,2009,2010,2011,2012,2013,2014],zones:[{name:"Africa/Cairo",rules:[{e:12199572e5,s:12090744e5},{e:1250802e6,s:1240524e6},{e:12858804e5,s:12840696e5},!1,!1,!1,{e:14116788e5,s:1406844e6}]},{name:"Africa/Casablanca",rules:[{e:12202236e5,s:12122784e5},{e:12508092e5,s:12438144e5},{e:1281222e6,s:12727584e5},{e:13120668e5,s:13017888e5},{e:13489704e5,s:1345428e6},{e:13828392e5,s:13761e8},{e:14142888e5,s:14069448e5}]},{name:"America/Asuncion",rules:[{e:12050316e5,s:12243888e5},{e:12364812e5,s:12558384e5},{e:12709548e5,s:12860784e5},{e:13024044e5,s:1317528e6},{e:1333854e6,s:13495824e5},{e:1364094e6,s:1381032e6},{e:13955436e5,s:14124816e5}]},{name:"America/Campo_Grande",rules:[{e:12032172e5,s:12243888e5},{e:12346668e5,s:12558384e5},{e:12667212e5,s:1287288e6},{e:12981708e5,s:13187376e5},{e:13302252e5,s:1350792e6},{e:136107e7,s:13822416e5},{e:13925196e5,s:14136912e5}]},{name:"America/Goose_Bay",rules:[{e:122559486e4,s:120503526e4},{e:125704446e4,s:123648486e4},{e:128909886e4,s:126853926e4},{e:13205556e5,s:129998886e4},{e:13520052e5,s:13314456e5},{e:13834548e5,s:13628952e5},{e:14149044e5,s:13943448e5}]},{name:"America/Havana",rules:[{e:12249972e5,s:12056436e5},{e:12564468e5,s:12364884e5},{e:12885012e5,s:12685428e5},{e:13211604e5,s:13005972e5},{e:13520052e5,s:13332564e5},{e:13834548e5,s:13628916e5},{e:14149044e5,s:13943412e5}]},{name:"America/Mazatlan",rules:[{e:1225008e6,s:12074724e5},{e:12564576e5,s:1238922e6},{e:1288512e6,s:12703716e5},{e:13199616e5,s:13018212e5},{e:13514112e5,s:13332708e5},{e:13828608e5,s:13653252e5},{e:14143104e5,s:13967748e5}]},{name:"America/Mexico_City",rules:[{e:12250044e5,s:12074688e5},{e:1256454e6,s:12389184e5},{e:12885084e5,s:1270368e6},{e:1319958e6,s:13018176e5},{e:13514076e5,s:13332672e5},{e:13828572e5,s:13653216e5},{e:14143068e5,s:13967712e5}]},{name:"America/Miquelon",rules:[{e:12255984e5,s:12050388e5},{e:1257048e6,s:12364884e5},{e:12891024e5,s:12685428e5},{e:1320552e6,s:12999924e5},{e:13520016e5,s:1331442e6},{e:13834512e5,s:13628916e5},{e:14149008e5,s:13943412e5}]},{name:"America/Santa_Isabel",rules:[{e:12250116e5,s:1207476e6},{e:12564612e5,s:12389256e5},{e:12885156e5,s:12703752e5},{e:13199652e5,s:13018248e5},{e:13514148e5,s:13332744e5},{e:13828644e5,s:13653288e5},{e:1414314e6,s:13967784e5}]},{name:"America/Santiago",rules:[{e:1206846e6,s:1223784e6},{e:1237086e6,s:12552336e5},{e:127035e7,s:12866832e5},{e:13048236e5,s:13138992e5},{e:13356684e5,s:13465584e5},{e:1367118e6,s:13786128e5},{e:13985676e5,s:14100624e5}]},{name:"America/Sao_Paulo",rules:[{e:12032136e5,s:12243852e5},{e:12346632e5,s:12558348e5},{e:12667176e5,s:12872844e5},{e:12981672e5,s:1318734e6},{e:13302216e5,s:13507884e5},{e:13610664e5,s:1382238e6},{e:1392516e6,s:14136876e5}]},{name:"Asia/Amman",rules:[{e:1225404e6,s:12066552e5},{e:12568536e5,s:12381048e5},{e:12883032e5,s:12695544e5},{e:13197528e5,s:13016088e5},!1,!1,{e:14147064e5,s:13959576e5}]},{name:"Asia/Damascus",rules:[{e:12254868e5,s:120726e7},{e:125685e7,s:12381048e5},{e:12882996e5,s:12701592e5},{e:13197492e5,s:13016088e5},{e:13511988e5,s:13330584e5},{e:13826484e5,s:1364508e6},{e:14147028e5,s:13959576e5}]},{name:"Asia/Dubai",rules:[!1,!1,!1,!1,!1,!1,!1]},{name:"Asia/Gaza",rules:[{e:12199572e5,s:12066552e5},{e:12520152e5,s:12381048e5},{e:1281474e6,s:126964086e4},{e:1312146e6,s:130160886e4},{e:13481784e5,s:13330584e5},{e:13802292e5,s:1364508e6},{e:1414098e6,s:13959576e5}]},{name:"Asia/Irkutsk",rules:[{e:12249576e5,s:12068136e5},{e:12564072e5,s:12382632e5},{e:12884616e5,s:12697128e5},!1,!1,!1,!1]},{name:"Asia/Jerusalem",rules:[{e:12231612e5,s:12066624e5},{e:1254006e6,s:1238112e6},{e:1284246e6,s:12695616e5},{e:131751e7,s:1301616e6},{e:13483548e5,s:13330656e5},{e:13828284e5,s:13645152e5},{e:1414278e6,s:13959648e5}]},{name:"Asia/Kamchatka",rules:[{e:12249432e5,s:12067992e5},{e:12563928e5,s:12382488e5},{e:12884508e5,s:12696984e5},!1,!1,!1,!1]},{name:"Asia/Krasnoyarsk",rules:[{e:12249612e5,s:12068172e5},{e:12564108e5,s:12382668e5},{e:12884652e5,s:12697164e5},!1,!1,!1,!1]},{name:"Asia/Omsk",rules:[{e:12249648e5,s:12068208e5},{e:12564144e5,s:12382704e5},{e:12884688e5,s:126972e7},!1,!1,!1,!1]},{name:"Asia/Vladivostok",rules:[{e:12249504e5,s:12068064e5},{e:12564e8,s:1238256e6},{e:12884544e5,s:12697056e5},!1,!1,!1,!1]},{name:"Asia/Yakutsk",rules:[{e:1224954e6,s:120681e7},{e:12564036e5,s:12382596e5},{e:1288458e6,s:12697092e5},!1,!1,!1,!1]},{name:"Asia/Yekaterinburg",rules:[{e:12249684e5,s:12068244e5},{e:1256418e6,s:1238274e6},{e:12884724e5,s:12697236e5},!1,!1,!1,!1]},{name:"Asia/Yerevan",rules:[{e:1224972e6,s:1206828e6},{e:12564216e5,s:12382776e5},{e:1288476e6,s:12697272e5},{e:13199256e5,s:13011768e5},!1,!1,!1]},{name:"Australia/Lord_Howe",rules:[{e:12074076e5,s:12231342e5},{e:12388572e5,s:12545838e5},{e:12703068e5,s:12860334e5},{e:13017564e5,s:1317483e6},{e:1333206e6,s:13495374e5},{e:13652604e5,s:1380987e6},{e:139671e7,s:14124366e5}]},{name:"Australia/Perth",rules:[{e:12068136e5,s:12249576e5},!1,!1,!1,!1,!1,!1]},{name:"Europe/Helsinki",rules:[{e:12249828e5,s:12068388e5},{e:12564324e5,s:12382884e5},{e:12884868e5,s:1269738e6},{e:13199364e5,s:13011876e5},{e:1351386e6,s:13326372e5},{e:13828356e5,s:13646916e5},{e:14142852e5,s:13961412e5}]},{name:"Europe/Minsk",rules:[{e:12249792e5,s:12068352e5},{e:12564288e5,s:12382848e5},{e:12884832e5,s:12697344e5},!1,!1,!1,!1]},{name:"Europe/Moscow",rules:[{e:12249756e5,s:12068316e5},{e:12564252e5,s:12382812e5},{e:12884796e5,s:12697308e5},!1,!1,!1,!1]},{name:"Pacific/Apia",rules:[!1,!1,!1,{e:13017528e5,s:13168728e5},{e:13332024e5,s:13489272e5},{e:13652568e5,s:13803768e5},{e:13967064e5,s:14118264e5}]},{name:"Pacific/Fiji",rules:[!1,!1,{e:12696984e5,s:12878424e5},{e:13271544e5,s:1319292e6},{e:1358604e6,s:13507416e5},{e:139005e7,s:1382796e6},{e:14215032e5,s:14148504e5}]},{name:"Europe/London",rules:[{e:12249828e5,s:12068388e5},{e:12564324e5,s:12382884e5},{e:12884868e5,s:1269738e6},{e:13199364e5,s:13011876e5},{e:1351386e6,s:13326372e5},{e:13828356e5,s:13646916e5},{e:14142852e5,s:13961412e5}]}]},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a:"undefined"!=typeof define&&null!==define&&null!=define.amd?define([],function(){return a}):"undefined"==typeof e?window.jstz=a:e.jstz=a}(); | 15 /*jslint undef: true */ |
16 /*global console, exports*/ | |
17 | |
18 (function(root) { | |
19 /** | |
20 * Namespace to hold all the code for timezone detection. | |
21 */ | |
22 var jstz = (function () { | |
23 'use strict'; | |
24 var HEMISPHERE_SOUTH = 's', | |
25 | |
26 /** | |
27 * Gets the offset in minutes from UTC for a certain date. | |
28 * @param {Date} date | |
29 * @returns {Number} | |
30 */ | |
31 get_date_offset = function (date) { | |
32 var offset = -date.getTimezoneOffset(); | |
33 return (offset !== null ? offset : 0); | |
34 }, | |
35 | |
36 get_date = function (year, month, date) { | |
37 var d = new Date(); | |
38 if (year !== undefined) { | |
39 d.setFullYear(year); | |
40 } | |
41 d.setMonth(month); | |
42 d.setDate(date); | |
43 return d; | |
44 }, | |
45 | |
46 get_january_offset = function (year) { | |
47 return get_date_offset(get_date(year, 0 ,2)); | |
48 }, | |
49 | |
50 get_june_offset = function (year) { | |
51 return get_date_offset(get_date(year, 5, 2)); | |
52 }, | |
53 | |
54 /** | |
55 * Private method. | |
56 * Checks whether a given date is in daylight saving time. | |
57 * If the date supplied is after august, we assume that we're checking | |
58 * for southern hemisphere DST. | |
59 * @param {Date} date | |
60 * @returns {Boolean} | |
61 */ | |
62 date_is_dst = function (date) { | |
63 var is_southern = date.getMonth() > 7, | |
64 base_offset = is_southern ? get_june_offset(date.getFullYear()) : | |
65 get_january_offset(date.getFullYear()), | |
66 date_offset = get_date_offset(date), | |
67 is_west = base_offset < 0, | |
68 dst_offset = base_offset - date_offset; | |
69 | |
70 if (!is_west && !is_southern) { | |
71 return dst_offset < 0; | |
72 } | |
73 | |
74 return dst_offset !== 0; | |
75 }, | |
76 | |
77 /** | |
78 * This function does some basic calculations to create information about | |
79 * the user's timezone. It uses REFERENCE_YEAR as a solid year for which | |
80 * the script has been tested rather than depend on the year set by the | |
81 * client device. | |
82 * | |
83 * Returns a key that can be used to do lookups in jstz.olson.timezones. | |
84 * eg: "720,1,2". | |
85 * | |
86 * @returns {String} | |
87 */ | |
88 | |
89 lookup_key = function () { | |
90 var january_offset = get_january_offset(), | |
91 june_offset = get_june_offset(), | |
92 diff = january_offset - june_offset; | |
93 | |
94 if (diff < 0) { | |
95 return january_offset + ",1"; | |
96 } else if (diff > 0) { | |
97 return june_offset + ",1," + HEMISPHERE_SOUTH; | |
98 } | |
99 | |
100 return january_offset + ",0"; | |
101 }, | |
102 | |
103 /** | |
104 * Uses get_timezone_info() to formulate a key to use in the olson.timezones dictionary. | |
105 * | |
106 * Returns a primitive object on the format: | |
107 * {'timezone': TimeZone, 'key' : 'the key used to find the TimeZone object'} | |
108 * | |
109 * @returns Object | |
110 */ | |
111 determine = function () { | |
112 var key = lookup_key(); | |
113 return new jstz.TimeZone(jstz.olson.timezones[key]); | |
114 }, | |
115 | |
116 /** | |
117 * This object contains information on when daylight savings starts for | |
118 * different timezones. | |
119 * | |
120 * The list is short for a reason. Often we do not have to be very specific | |
121 * to single out the correct timezone. But when we do, this list comes in | |
122 * handy. | |
123 * | |
124 * Each value is a date denoting when daylight savings starts for that timezone. | |
125 */ | |
126 dst_start_for = function (tz_name) { | |
127 | |
128 var ru_pre_dst_change = new Date(2010, 6, 15, 1, 0, 0, 0), // In 2010 Russia had DST, this allows us to detect Russia :) | |
129 dst_starts = { | |
130 'America/Denver': new Date(2011, 2, 13, 3, 0, 0, 0), | |
131 'America/Mazatlan': new Date(2011, 3, 3, 3, 0, 0, 0), | |
132 'America/Chicago': new Date(2011, 2, 13, 3, 0, 0, 0), | |
133 'America/Mexico_City': new Date(2011, 3, 3, 3, 0, 0, 0), | |
134 'America/Asuncion': new Date(2012, 9, 7, 3, 0, 0, 0), | |
135 'America/Santiago': new Date(2012, 9, 3, 3, 0, 0, 0), | |
136 'America/Campo_Grande': new Date(2012, 9, 21, 5, 0, 0, 0), | |
137 'America/Montevideo': new Date(2011, 9, 2, 3, 0, 0, 0), | |
138 'America/Sao_Paulo': new Date(2011, 9, 16, 5, 0, 0, 0), | |
139 'America/Los_Angeles': new Date(2011, 2, 13, 8, 0, 0, 0), | |
140 'America/Santa_Isabel': new Date(2011, 3, 5, 8, 0, 0, 0), | |
141 'America/Havana': new Date(2012, 2, 10, 2, 0, 0, 0), | |
142 'America/New_York': new Date(2012, 2, 10, 7, 0, 0, 0), | |
143 'Europe/Helsinki': new Date(2013, 2, 31, 5, 0, 0, 0), | |
144 'Pacific/Auckland': new Date(2011, 8, 26, 7, 0, 0, 0), | |
145 'America/Halifax': new Date(2011, 2, 13, 6, 0, 0, 0), | |
146 'America/Goose_Bay': new Date(2011, 2, 13, 2, 1, 0, 0), | |
147 'America/Miquelon': new Date(2011, 2, 13, 5, 0, 0, 0), | |
148 'America/Godthab': new Date(2011, 2, 27, 1, 0, 0, 0), | |
149 'Europe/Moscow': ru_pre_dst_change, | |
150 'Asia/Amman': new Date(2013, 2, 29, 1, 0, 0, 0), | |
151 'Asia/Beirut': new Date(2013, 2, 31, 2, 0, 0, 0), | |
152 'Asia/Damascus': new Date(2013, 3, 6, 2, 0, 0, 0), | |
153 'Asia/Jerusalem': new Date(2013, 2, 29, 5, 0, 0, 0), | |
154 'Asia/Yekaterinburg': ru_pre_dst_change, | |
155 'Asia/Omsk': ru_pre_dst_change, | |
156 'Asia/Krasnoyarsk': ru_pre_dst_change, | |
157 'Asia/Irkutsk': ru_pre_dst_change, | |
158 'Asia/Yakutsk': ru_pre_dst_change, | |
159 'Asia/Vladivostok': ru_pre_dst_change, | |
160 'Asia/Baku': new Date(2013, 2, 31, 4, 0, 0), | |
161 'Asia/Yerevan': new Date(2013, 2, 31, 3, 0, 0), | |
162 'Asia/Kamchatka': ru_pre_dst_change, | |
163 'Asia/Gaza': new Date(2010, 2, 27, 4, 0, 0), | |
164 'Africa/Cairo': new Date(2010, 4, 1, 3, 0, 0), | |
165 'Europe/Minsk': ru_pre_dst_change, | |
166 'Pacific/Apia': new Date(2010, 10, 1, 1, 0, 0, 0), | |
167 'Pacific/Fiji': new Date(2010, 11, 1, 0, 0, 0), | |
168 'Australia/Perth': new Date(2008, 10, 1, 1, 0, 0, 0) | |
169 }; | |
170 | |
171 return dst_starts[tz_name]; | |
172 }; | |
173 | |
174 return { | |
175 determine: determine, | |
176 date_is_dst: date_is_dst, | |
177 dst_start_for: dst_start_for | |
178 }; | |
179 }()); | |
180 | |
181 /** | |
182 * Simple object to perform ambiguity check and to return name of time zone. | |
183 */ | |
184 jstz.TimeZone = function (tz_name) { | |
185 'use strict'; | |
186 /** | |
187 * The keys in this object are timezones that we know may be ambiguous after | |
188 * a preliminary scan through the olson_tz object. | |
189 * | |
190 * The array of timezones to compare must be in the order that daylight savings | |
191 * starts for the regions. | |
192 */ | |
193 var AMBIGUITIES = { | |
194 'America/Denver': ['America/Denver', 'America/Mazatlan'], | |
195 'America/Chicago': ['America/Chicago', 'America/Mexico_City'], | |
196 'America/Santiago': ['America/Santiago', 'America/Asuncion', 'America/Campo_Grande'], | |
197 'America/Montevideo': ['America/Montevideo', 'America/Sao_Paulo'], | |
198 'Asia/Beirut': ['Asia/Amman', 'Asia/Jerusalem', 'Asia/Beirut', 'Europe/Helsinki','Asia/Damascus'], | |
199 'Pacific/Auckland': ['Pacific/Auckland', 'Pacific/Fiji'], | |
200 'America/Los_Angeles': ['America/Los_Angeles', 'America/Santa_Isabel'], | |
201 'America/New_York': ['America/Havana', 'America/New_York'], | |
202 'America/Halifax': ['America/Goose_Bay', 'America/Halifax'], | |
203 'America/Godthab': ['America/Miquelon', 'America/Godthab'], | |
204 'Asia/Dubai': ['Europe/Moscow'], | |
205 'Asia/Dhaka': ['Asia/Yekaterinburg'], | |
206 'Asia/Jakarta': ['Asia/Omsk'], | |
207 'Asia/Shanghai': ['Asia/Krasnoyarsk', 'Australia/Perth'], | |
208 'Asia/Tokyo': ['Asia/Irkutsk'], | |
209 'Australia/Brisbane': ['Asia/Yakutsk'], | |
210 'Pacific/Noumea': ['Asia/Vladivostok'], | |
211 'Pacific/Tarawa': ['Asia/Kamchatka', 'Pacific/Fiji'], | |
212 'Pacific/Tongatapu': ['Pacific/Apia'], | |
213 'Asia/Baghdad': ['Europe/Minsk'], | |
214 'Asia/Baku': ['Asia/Yerevan','Asia/Baku'], | |
215 'Africa/Johannesburg': ['Asia/Gaza', 'Africa/Cairo'] | |
216 }, | |
217 | |
218 timezone_name = tz_name, | |
219 | |
220 /** | |
221 * Checks if a timezone has possible ambiguities. I.e timezones that are similar. | |
222 * | |
223 * For example, if the preliminary scan determines that we're in America/Denver. | |
224 * We double check here that we're really there and not in America/Mazatlan. | |
225 * | |
226 * This is done by checking known dates for when daylight savings start for different | |
227 * timezones during 2010 and 2011. | |
228 */ | |
229 ambiguity_check = function () { | |
230 var ambiguity_list = AMBIGUITIES[timezone_name], | |
231 length = ambiguity_list.length, | |
232 i = 0, | |
233 tz = ambiguity_list[0]; | |
234 | |
235 for (; i < length; i += 1) { | |
236 tz = ambiguity_list[i]; | |
237 | |
238 if (jstz.date_is_dst(jstz.dst_start_for(tz))) { | |
239 timezone_name = tz; | |
240 return; | |
241 } | |
242 } | |
243 }, | |
244 | |
245 /** | |
246 * Checks if it is possible that the timezone is ambiguous. | |
247 */ | |
248 is_ambiguous = function () { | |
249 return typeof (AMBIGUITIES[timezone_name]) !== 'undefined'; | |
250 }; | |
251 | |
252 if (is_ambiguous()) { | |
253 ambiguity_check(); | |
254 } | |
255 | |
256 return { | |
257 name: function () { | |
258 return timezone_name; | |
259 } | |
260 }; | |
261 }; | |
262 | |
263 jstz.olson = {}; | |
264 | |
265 /* | |
266 * The keys in this dictionary are comma separated as such: | |
267 * | |
268 * First the offset compared to UTC time in minutes. | |
269 * | |
270 * Then a flag which is 0 if the timezone does not take daylight savings into account and 1 if it | |
271 * does. | |
272 * | |
273 * Thirdly an optional 's' signifies that the timezone is in the southern hemisphere, | |
274 * only interesting for timezones with DST. | |
275 * | |
276 * The mapped arrays is used for constructing the jstz.TimeZone object from within | |
277 * jstz.determine_timezone(); | |
278 */ | |
279 jstz.olson.timezones = { | |
280 '-720,0' : 'Pacific/Majuro', | |
281 '-660,0' : 'Pacific/Pago_Pago', | |
282 '-600,1' : 'America/Adak', | |
283 '-600,0' : 'Pacific/Honolulu', | |
284 '-570,0' : 'Pacific/Marquesas', | |
285 '-540,0' : 'Pacific/Gambier', | |
286 '-540,1' : 'America/Anchorage', | |
287 '-480,1' : 'America/Los_Angeles', | |
288 '-480,0' : 'Pacific/Pitcairn', | |
289 '-420,0' : 'America/Phoenix', | |
290 '-420,1' : 'America/Denver', | |
291 '-360,0' : 'America/Guatemala', | |
292 '-360,1' : 'America/Chicago', | |
293 '-360,1,s' : 'Pacific/Easter', | |
294 '-300,0' : 'America/Bogota', | |
295 '-300,1' : 'America/New_York', | |
296 '-270,0' : 'America/Caracas', | |
297 '-240,1' : 'America/Halifax', | |
298 '-240,0' : 'America/Santo_Domingo', | |
299 '-240,1,s' : 'America/Santiago', | |
300 '-210,1' : 'America/St_Johns', | |
301 '-180,1' : 'America/Godthab', | |
302 '-180,0' : 'America/Argentina/Buenos_Aires', | |
303 '-180,1,s' : 'America/Montevideo', | |
304 '-120,0' : 'America/Noronha', | |
305 '-120,1' : 'America/Noronha', | |
306 '-60,1' : 'Atlantic/Azores', | |
307 '-60,0' : 'Atlantic/Cape_Verde', | |
308 '0,0' : 'UTC', | |
309 '0,1' : 'Europe/London', | |
310 '60,1' : 'Europe/Berlin', | |
311 '60,0' : 'Africa/Lagos', | |
312 '60,1,s' : 'Africa/Windhoek', | |
313 '120,1' : 'Asia/Beirut', | |
314 '120,0' : 'Africa/Johannesburg', | |
315 '180,0' : 'Asia/Baghdad', | |
316 '180,1' : 'Europe/Moscow', | |
317 '210,1' : 'Asia/Tehran', | |
318 '240,0' : 'Asia/Dubai', | |
319 '240,1' : 'Asia/Baku', | |
320 '270,0' : 'Asia/Kabul', | |
321 '300,1' : 'Asia/Yekaterinburg', | |
322 '300,0' : 'Asia/Karachi', | |
323 '330,0' : 'Asia/Kolkata', | |
324 '345,0' : 'Asia/Kathmandu', | |
325 '360,0' : 'Asia/Dhaka', | |
326 '360,1' : 'Asia/Omsk', | |
327 '390,0' : 'Asia/Rangoon', | |
328 '420,1' : 'Asia/Krasnoyarsk', | |
329 '420,0' : 'Asia/Jakarta', | |
330 '480,0' : 'Asia/Shanghai', | |
331 '480,1' : 'Asia/Irkutsk', | |
332 '525,0' : 'Australia/Eucla', | |
333 '525,1,s' : 'Australia/Eucla', | |
334 '540,1' : 'Asia/Yakutsk', | |
335 '540,0' : 'Asia/Tokyo', | |
336 '570,0' : 'Australia/Darwin', | |
337 '570,1,s' : 'Australia/Adelaide', | |
338 '600,0' : 'Australia/Brisbane', | |
339 '600,1' : 'Asia/Vladivostok', | |
340 '600,1,s' : 'Australia/Sydney', | |
341 '630,1,s' : 'Australia/Lord_Howe', | |
342 '660,1' : 'Asia/Kamchatka', | |
343 '660,0' : 'Pacific/Noumea', | |
344 '690,0' : 'Pacific/Norfolk', | |
345 '720,1,s' : 'Pacific/Auckland', | |
346 '720,0' : 'Pacific/Tarawa', | |
347 '765,1,s' : 'Pacific/Chatham', | |
348 '780,0' : 'Pacific/Tongatapu', | |
349 '780,1,s' : 'Pacific/Apia', | |
350 '840,0' : 'Pacific/Kiritimati' | |
351 }; | |
352 | |
353 if (typeof exports !== 'undefined') { | |
354 exports.jstz = jstz; | |
355 } else { | |
356 root.jstz = jstz; | |
357 } | |
358 })(this); |