/
moment-timezone.min.js
6 lines (6 loc) · 6.6 KB
/
moment-timezone.min.js
1
2
3
4
5
6
//! moment-timezone.js
//! version : 0.5.10
//! Copyright (c) JS Foundation and other contributors
//! license : MIT
//! github.com/moment/moment-timezone
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(["moment"],b):"object"==typeof module&&module.exports?module.exports=b(require("moment")):b(a.moment)}(this,function(a){"use strict";function b(a){return a>96?a-87:a>64?a-29:a-48}function c(a){var c,d=0,e=a.split("."),f=e[0],g=e[1]||"",h=1,i=0,j=1;for(45===a.charCodeAt(0)&&(d=1,j=-1),d;d<f.length;d++)c=b(f.charCodeAt(d)),i=60*i+c;for(d=0;d<g.length;d++)h/=60,c=b(g.charCodeAt(d)),i+=c*h;return i*j}function d(a){for(var b=0;b<a.length;b++)a[b]=c(a[b])}function e(a,b){for(var c=0;c<b;c++)a[c]=Math.round((a[c-1]||0)+6e4*a[c]);a[b-1]=1/0}function f(a,b){var c,d=[];for(c=0;c<b.length;c++)d[c]=a[b[c]];return d}function g(a){var b=a.split("|"),c=b[2].split(" "),g=b[3].split(""),h=b[4].split(" "),i=b[6];return d(c),d(g),d(h),e(h,g.length),i=i?i.split(" "):"",{name:b[0],abbrs:f(b[1].split(" "),g),offsets:f(c,g),untils:h,population:0|b[5],countries:i}}function h(a){var b=a.split("|"),c=b[1].split(" ");return{name:b[0],zones:c}}function i(a){a&&this._set(g(a))}function j(a){a&&this._set(h(a))}function k(a){var b=a.toTimeString(),c=b.match(/\([a-z ]+\)/i);c&&c[0]?(c=c[0].match(/[A-Z]/g),c=c?c.join(""):void 0):(c=b.match(/[A-Z]{3,5}/g),c=c?c[0]:void 0),"GMT"===c&&(c=void 0),this.at=+a,this.abbr=c,this.offset=a.getTimezoneOffset()}function l(a){this.zone=a,this.offsetScore=0,this.abbrScore=0}function m(a,b){for(var c,d;d=6e4*((b.at-a.at)/12e4|0);)c=new k(new Date(a.at+d)),c.offset===a.offset?a=c:b=c;return a}function n(){var a,b,c,d=(new Date).getFullYear()-2,e=new k(new Date(d,0,1)),f=[e];for(c=1;c<48;c++)b=new k(new Date(d,c,1)),b.offset!==e.offset&&(a=m(e,b),f.push(a),f.push(new k(new Date(a.at+6e4)))),e=b;for(c=0;c<4;c++)f.push(new k(new Date(d+c,0,1))),f.push(new k(new Date(d+c,6,1)));return f}function o(a,b){return a.offsetScore!==b.offsetScore?a.offsetScore-b.offsetScore:a.abbrScore!==b.abbrScore?a.abbrScore-b.abbrScore:b.zone.population-a.zone.population}function p(a,b){var c,e;for(d(b),c=0;c<b.length;c++)e=b[c],O[e]=O[e]||{},O[e][a]=!0}function q(a){var b,c,d,e=a.length,f={},g=[];for(b=0;b<e;b++){d=O[a[b].offset]||{};for(c in d)d.hasOwnProperty(c)&&(f[c]=!0)}for(b in f)f.hasOwnProperty(b)&&g.push(N[b]);return g}function r(){try{var a=Intl.DateTimeFormat().resolvedOptions().timeZone;if(a){var b=N[t(a)];if(b)return b;E("Moment Timezone found "+a+" from the Intl api, but did not have that data loaded.")}}catch(c){}var d,e,f,g=n(),h=g.length,i=q(g),j=[];for(e=0;e<i.length;e++){for(d=new l(v(i[e]),h),f=0;f<h;f++)d.scoreOffsetAt(g[f]);j.push(d)}return j.sort(o),j.length>0?j[0].zone.name:void 0}function s(a){return I&&!a||(I=r()),I}function t(a){return(a||"").toLowerCase().replace(/\//g,"_")}function u(a){var b,c,d,e;for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)d=a[b].split("|"),c=d[0],e=t(c),K[e]=a[b],N[e]=c,d[5]&&p(e,d[2].split(" "))}function v(a,b){a=t(a);var c,d=K[a];return d instanceof i?d:"string"==typeof d?(d=new i(d),K[a]=d,d):L[a]&&b!==v&&(c=v(L[a],v))?(d=K[a]=new i,d._set(c),d.name=N[a],d):null}function w(){var a,b=[];for(a in N)N.hasOwnProperty(a)&&(K[a]||K[L[a]])&&N[a]&&b.push(N[a]);return b.sort()}function x(a){var b,c,d,e;for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)c=a[b].split("|"),d=t(c[0]),e=t(c[1]),L[d]=e,N[d]=c[0],L[e]=d,N[e]=c[1]}function y(a){var b,c,d,e;if(a)for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)d=a[b].split("|"),c=d[0],e=t(c),M[e]=a[b]}function z(a,b){a=t(a);var c=M[a];return c instanceof j?c:"string"==typeof c?(c=new j(c),M[a]=c,c):null}function A(a){return a=z(a),a?a.zones:null}function B(a){u(a.zones),x(a.links),y(a.countries),F.dataVersion=a.version}function C(a){return C.didShowError||(C.didShowError=!0,E("moment.tz.zoneExists('"+a+"') has been deprecated in favor of !moment.tz.zone('"+a+"')")),!!v(a)}function D(a){return!(!a._a||void 0!==a._tzm)}function E(a){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(a)}function F(b){var c=Array.prototype.slice.call(arguments,0,-1),d=arguments[arguments.length-1],e=v(d),f=a.utc.apply(null,c);return e&&!a.isMoment(b)&&D(f)&&f.add(e.parse(f),"minutes"),f.tz(d),f}function G(a){return function(){return this._z?this._z.abbr(this):a.call(this)}}function H(a){return function(){return this._z=null,a.apply(this,arguments)}}if(void 0!==a.tz)return E("Moment Timezone "+a.tz.version+" was already loaded "+(a.tz.dataVersion?"with data from ":"without any data")+a.tz.dataVersion),a;var I,J="0.5.10",K={},L={},M={},N={},O={},P=a.version.split("."),Q=+P[0],R=+P[1];(Q<2||2===Q&&R<6)&&E("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js "+a.version+". See momentjs.com"),i.prototype={_set:function(a){this.name=a.name,this.abbrs=a.abbrs,this.untils=a.untils,this.offsets=a.offsets,this.population=a.population,this.countries=a.countries},_index:function(a){var b,c=+a,d=this.untils;for(b=0;b<d.length;b++)if(c<d[b])return b},parse:function(a){var b,c,d,e,f=+a,g=this.offsets,h=this.untils,i=h.length-1;for(e=0;e<i;e++)if(b=g[e],c=g[e+1],d=g[e?e-1:e],b<c&&F.moveAmbiguousForward?b=c:b>d&&F.moveInvalidForward&&(b=d),f<h[e]-6e4*b)return g[e];return g[i]},abbr:function(a){return this.abbrs[this._index(a)]},offset:function(a){return this.offsets[this._index(a)]}},j.prototype={_set:function(a){this.name=a.name,this.zones=a.zones}},l.prototype.scoreOffsetAt=function(a){this.offsetScore+=Math.abs(this.zone.offset(a.at)-a.offset),this.zone.abbr(a.at).replace(/[^A-Z]/g,"")!==a.abbr&&this.abbrScore++},F.version=J,F.dataVersion="",F._zones=K,F._links=L,F._names=N,F._countries=M,F.add=u,F.link=x,F.load=B,F.zone=v,F.zoneExists=C,F.guess=s,F.names=w,F.Zone=i,F.unpack=g,F.unpackBase60=c,F.needsOffset=D,F.moveInvalidForward=!0,F.moveAmbiguousForward=!1,F.zonesForCountry=A;var S=a.fn;a.tz=F,a.defaultZone=null,a.updateOffset=function(b,c){var d,e=a.defaultZone;void 0===b._z&&(e&&D(b)&&!b._isUTC&&(b._d=a.utc(b._a)._d,b.utc().add(e.parse(b),"minutes")),b._z=e),b._z&&(d=b._z.offset(b),Math.abs(d)<16&&(d/=60),void 0!==b.utcOffset?b.utcOffset(-d,c):b.zone(d,c))},S.tz=function(b){return b?(this._z=v(b),this._z?a.updateOffset(this):E("Moment Timezone has no data for "+b+". See http://momentjs.com/timezone/docs/#/data-loading/."),this):this._z?this._z.name:void 0},S.zoneName=G(S.zoneName),S.zoneAbbr=G(S.zoneAbbr),S.utc=H(S.utc),a.tz.setDefault=function(b){return(Q<2||2===Q&&R<9)&&E("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js "+a.version+"."),a.defaultZone=b?v(b):null,a};var T=a.momentProperties;return"[object Array]"===Object.prototype.toString.call(T)?(T.push("_z"),T.push("_a")):T&&(T._z=null),a});