-
Notifications
You must be signed in to change notification settings - Fork 0
/
timezone.min.js
5 lines (5 loc) · 1.93 KB
/
timezone.min.js
1
2
3
4
5
var mzone=mzone||{};
(function(r){function t(a){return 96<a?a-87:64<a?a-29:a-48}function q(a){for(var d=0;d<a.length;d++){var b=d,c=a[d],e=0,f=c.split("."),u=f[0],f=f[1]||"",g=1,h=0,k=1;45===c.charCodeAt(0)&&(e=1,k=-1);for(;e<u.length;e++)c=t(u.charCodeAt(e)),h=60*h+c;for(e=0;e<f.length;e++)g/=60,c=t(f.charCodeAt(e)),h+=c*g;a[b]=h*k}}function v(a,d){var b=[],c;for(c=0;c<d.length;c++)b[c]=a[d[c]];return b}function w(a){a=a.split("|");var d=a[2].split(" "),b=a[3].split(""),c=a[4].split(" ");q(d);q(b);q(c);for(var e=b.length,
f=0;f<e;f++)c[f]=Math.round((c[f-1]||0)+6E4*c[f]);c[e-1]=Infinity;return{name:a[0],abbrs:v(a[1].split(" "),b),offsets:v(d,b),untils:c,population:a[5]|0}}function h(a){a&&this._set(w(a))}function k(a){return(a||"").toLowerCase().replace(/\//g,"_")}function l(a,d){a=k(a);var b=m[a],c;return b instanceof h?b:"string"===typeof b?(b=new h(b),m[a]=b):n[a]&&d!==l&&(c=l(n[a],l))?(b=m[a]=new h,b._set(c),b.name=p[a],b):null}r.loadData=function(a){var d=a.zones,b,c,e;"string"===typeof d&&(d=[d]);for(b=0;b<d.length;b++)c=
d[b].split("|"),c=c[0],e=k(c),m[e]=d[b],p[e]=c;a=a.links;"string"===typeof a&&(a=[a]);for(d=0;d<a.length;d++)b=a[d].split("|"),c=k(b[0]),e=k(b[1]),n[c]=e,p[c]=b[0],n[e]=c,p[e]=b[1]};r.tz=function(a,d){"string"===typeof a&&(a=new Date(a));var b=new Date(a.getTime()+6E4*a.getTimezoneOffset()),c=l(d);if(!c)throw"Invalid timezone: "+d;c=c.parse(b);return new Date(b.getTime()-6E4*c)};var m={},n={},p={};h.prototype={_set:function(a){this.name=a.name;this.abbrs=a.abbrs;this.untils=a.untils;this.offsets=
a.offsets;this.population=a.population},_index:function(a){a=+a;var d=this.untils,b;for(b=0;b<d.length;b++)if(a<d[b])return b},parse:function(a){a=+a;var d=this.offsets,b=this.untils,c=b.length-1,e,f,h,g;for(g=0;g<c;g++)if(e=d[g],f=d[g+1],h=d[g?g-1:g],e<f?e=f:e>h&&(e=h),a<b[g]-6E4*e)return d[g];return d[c]},abbr:function(a){return this.abbrs[this._index(a)]},offset:function(a){return this.offsets[this._index(a)]}}})(mzone);