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