moment_timezone-rails 0.5.25 → 0.5.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moment_timezone/rails/version.rb +1 -1
- data/vendor/assets/javascripts/moment-timezone-with-data-10-year-range.js +563 -206
- data/vendor/assets/javascripts/moment-timezone-with-data-10-year-range.min.js +1 -1
- data/vendor/assets/javascripts/moment-timezone-with-data-1970-2030.js +497 -140
- data/vendor/assets/javascripts/moment-timezone-with-data-1970-2030.min.js +1 -1
- data/vendor/assets/javascripts/moment-timezone-with-data.js +619 -262
- data/vendor/assets/javascripts/moment-timezone-with-data.min.js +1 -1
- data/vendor/assets/javascripts/moment-timezone.js +124 -19
- data/vendor/assets/javascripts/moment-timezone.min.js +1 -1
- metadata +2 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
//! moment-timezone.js
|
2
|
-
//! version : 0.5.
|
2
|
+
//! version : 0.5.47
|
3
3
|
//! Copyright (c) JS Foundation and other contributors
|
4
4
|
//! license : MIT
|
5
5
|
//! github.com/moment/moment-timezone
|
@@ -18,15 +18,21 @@
|
|
18
18
|
}(this, function (moment) {
|
19
19
|
"use strict";
|
20
20
|
|
21
|
+
// Resolves es6 module loading issue
|
22
|
+
if (moment.version === undefined && moment.default) {
|
23
|
+
moment = moment.default;
|
24
|
+
}
|
25
|
+
|
21
26
|
// Do not load moment-timezone a second time.
|
22
27
|
// if (moment.tz !== undefined) {
|
23
28
|
// logError('Moment Timezone ' + moment.tz.version + ' was already loaded ' + (moment.tz.dataVersion ? 'with data from ' : 'without any data') + moment.tz.dataVersion);
|
24
29
|
// return moment;
|
25
30
|
// }
|
26
31
|
|
27
|
-
var VERSION = "0.5.
|
32
|
+
var VERSION = "0.5.47",
|
28
33
|
zones = {},
|
29
34
|
links = {},
|
35
|
+
countries = {},
|
30
36
|
names = {},
|
31
37
|
guesses = {},
|
32
38
|
cachedGuess;
|
@@ -144,6 +150,30 @@
|
|
144
150
|
}
|
145
151
|
}
|
146
152
|
|
153
|
+
function closest (num, arr) {
|
154
|
+
var len = arr.length;
|
155
|
+
if (num < arr[0]) {
|
156
|
+
return 0;
|
157
|
+
} else if (len > 1 && arr[len - 1] === Infinity && num >= arr[len - 2]) {
|
158
|
+
return len - 1;
|
159
|
+
} else if (num >= arr[len - 1]) {
|
160
|
+
return -1;
|
161
|
+
}
|
162
|
+
|
163
|
+
var mid;
|
164
|
+
var lo = 0;
|
165
|
+
var hi = len - 1;
|
166
|
+
while (hi - lo > 1) {
|
167
|
+
mid = Math.floor((lo + hi) / 2);
|
168
|
+
if (arr[mid] <= num) {
|
169
|
+
lo = mid;
|
170
|
+
} else {
|
171
|
+
hi = mid;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
return hi;
|
175
|
+
}
|
176
|
+
|
147
177
|
Zone.prototype = {
|
148
178
|
_set : function (unpacked) {
|
149
179
|
this.name = unpacked.name;
|
@@ -158,13 +188,19 @@
|
|
158
188
|
untils = this.untils,
|
159
189
|
i;
|
160
190
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
}
|
191
|
+
i = closest(target, untils);
|
192
|
+
if (i >= 0) {
|
193
|
+
return i;
|
165
194
|
}
|
166
195
|
},
|
167
196
|
|
197
|
+
countries : function () {
|
198
|
+
var zone_name = this.name;
|
199
|
+
return Object.keys(countries).filter(function (country_code) {
|
200
|
+
return countries[country_code].zones.indexOf(zone_name) !== -1;
|
201
|
+
});
|
202
|
+
},
|
203
|
+
|
168
204
|
parse : function (timestamp) {
|
169
205
|
var target = +timestamp,
|
170
206
|
offsets = this.offsets,
|
@@ -205,6 +241,15 @@
|
|
205
241
|
}
|
206
242
|
};
|
207
243
|
|
244
|
+
/************************************
|
245
|
+
Country object
|
246
|
+
************************************/
|
247
|
+
|
248
|
+
function Country (country_name, zone_names) {
|
249
|
+
this.name = country_name;
|
250
|
+
this.zones = zone_names;
|
251
|
+
}
|
252
|
+
|
208
253
|
/************************************
|
209
254
|
Current Timezone
|
210
255
|
************************************/
|
@@ -264,17 +309,21 @@
|
|
264
309
|
function userOffsets() {
|
265
310
|
var startYear = new Date().getFullYear() - 2,
|
266
311
|
last = new OffsetAt(new Date(startYear, 0, 1)),
|
312
|
+
lastOffset = last.offset,
|
267
313
|
offsets = [last],
|
268
|
-
change, next, i;
|
314
|
+
change, next, nextOffset, i;
|
269
315
|
|
270
316
|
for (i = 1; i < 48; i++) {
|
271
|
-
|
272
|
-
if (
|
317
|
+
nextOffset = new Date(startYear, i, 1).getTimezoneOffset();
|
318
|
+
if (nextOffset !== lastOffset) {
|
319
|
+
// Create OffsetAt here to avoid unnecessary abbr parsing before checking offsets
|
320
|
+
next = new OffsetAt(new Date(startYear, i, 1));
|
273
321
|
change = findChange(last, next);
|
274
322
|
offsets.push(change);
|
275
323
|
offsets.push(new OffsetAt(new Date(change.at + 6e4)));
|
324
|
+
last = next;
|
325
|
+
lastOffset = nextOffset;
|
276
326
|
}
|
277
|
-
last = next;
|
278
327
|
}
|
279
328
|
|
280
329
|
for (i = 0; i < 4; i++) {
|
@@ -292,7 +341,10 @@
|
|
292
341
|
if (a.abbrScore !== b.abbrScore) {
|
293
342
|
return a.abbrScore - b.abbrScore;
|
294
343
|
}
|
295
|
-
|
344
|
+
if (a.zone.population !== b.zone.population) {
|
345
|
+
return b.zone.population - a.zone.population;
|
346
|
+
}
|
347
|
+
return b.zone.name.localeCompare(a.zone.name);
|
296
348
|
}
|
297
349
|
|
298
350
|
function addToGuesses (name, offsets) {
|
@@ -309,15 +361,21 @@
|
|
309
361
|
var offsetsLength = offsets.length,
|
310
362
|
filteredGuesses = {},
|
311
363
|
out = [],
|
312
|
-
|
364
|
+
checkedOffsets = {},
|
365
|
+
i, j, offset, guessesOffset;
|
313
366
|
|
314
367
|
for (i = 0; i < offsetsLength; i++) {
|
315
|
-
|
368
|
+
offset = offsets[i].offset;
|
369
|
+
if (checkedOffsets.hasOwnProperty(offset)) {
|
370
|
+
continue;
|
371
|
+
}
|
372
|
+
guessesOffset = guesses[offset] || {};
|
316
373
|
for (j in guessesOffset) {
|
317
374
|
if (guessesOffset.hasOwnProperty(j)) {
|
318
375
|
filteredGuesses[j] = true;
|
319
376
|
}
|
320
377
|
}
|
378
|
+
checkedOffsets[offset] = true;
|
321
379
|
}
|
322
380
|
|
323
381
|
for (i in filteredGuesses) {
|
@@ -397,7 +455,7 @@
|
|
397
455
|
}
|
398
456
|
|
399
457
|
function getZone (name, caller) {
|
400
|
-
|
458
|
+
|
401
459
|
name = normalizeName(name);
|
402
460
|
|
403
461
|
var zone = zones[name];
|
@@ -436,6 +494,10 @@
|
|
436
494
|
return out.sort();
|
437
495
|
}
|
438
496
|
|
497
|
+
function getCountryNames () {
|
498
|
+
return Object.keys(countries);
|
499
|
+
}
|
500
|
+
|
439
501
|
function addLink (aliases) {
|
440
502
|
var i, alias, normal0, normal1;
|
441
503
|
|
@@ -457,9 +519,49 @@
|
|
457
519
|
}
|
458
520
|
}
|
459
521
|
|
522
|
+
function addCountries (data) {
|
523
|
+
var i, country_code, country_zones, split;
|
524
|
+
if (!data || !data.length) return;
|
525
|
+
for (i = 0; i < data.length; i++) {
|
526
|
+
split = data[i].split('|');
|
527
|
+
country_code = split[0].toUpperCase();
|
528
|
+
country_zones = split[1].split(' ');
|
529
|
+
countries[country_code] = new Country(
|
530
|
+
country_code,
|
531
|
+
country_zones
|
532
|
+
);
|
533
|
+
}
|
534
|
+
}
|
535
|
+
|
536
|
+
function getCountry (name) {
|
537
|
+
name = name.toUpperCase();
|
538
|
+
return countries[name] || null;
|
539
|
+
}
|
540
|
+
|
541
|
+
function zonesForCountry(country, with_offset) {
|
542
|
+
country = getCountry(country);
|
543
|
+
|
544
|
+
if (!country) return null;
|
545
|
+
|
546
|
+
var zones = country.zones.sort();
|
547
|
+
|
548
|
+
if (with_offset) {
|
549
|
+
return zones.map(function (zone_name) {
|
550
|
+
var zone = getZone(zone_name);
|
551
|
+
return {
|
552
|
+
name: zone_name,
|
553
|
+
offset: zone.utcOffset(new Date())
|
554
|
+
};
|
555
|
+
});
|
556
|
+
}
|
557
|
+
|
558
|
+
return zones;
|
559
|
+
}
|
560
|
+
|
460
561
|
function loadData (data) {
|
461
562
|
addZone(data.zones);
|
462
563
|
addLink(data.links);
|
564
|
+
addCountries(data.countries);
|
463
565
|
tz.dataVersion = data.version;
|
464
566
|
}
|
465
567
|
|
@@ -489,10 +591,10 @@
|
|
489
591
|
function tz (input) {
|
490
592
|
var args = Array.prototype.slice.call(arguments, 0, -1),
|
491
593
|
name = arguments[arguments.length - 1],
|
492
|
-
|
493
|
-
|
594
|
+
out = moment.utc.apply(null, args),
|
595
|
+
zone;
|
494
596
|
|
495
|
-
if (
|
597
|
+
if (!moment.isMoment(input) && needsOffset(out) && (zone = getZone(name))) {
|
496
598
|
out.add(zone.parse(out), 'minutes');
|
497
599
|
}
|
498
600
|
|
@@ -506,6 +608,7 @@
|
|
506
608
|
tz._zones = zones;
|
507
609
|
tz._links = links;
|
508
610
|
tz._names = names;
|
611
|
+
tz._countries = countries;
|
509
612
|
tz.add = addZone;
|
510
613
|
tz.link = addLink;
|
511
614
|
tz.load = loadData;
|
@@ -519,6 +622,8 @@
|
|
519
622
|
tz.needsOffset = needsOffset;
|
520
623
|
tz.moveInvalidForward = true;
|
521
624
|
tz.moveAmbiguousForward = false;
|
625
|
+
tz.countries = getCountryNames;
|
626
|
+
tz.zonesForCountry = zonesForCountry;
|
522
627
|
|
523
628
|
/************************************
|
524
629
|
Interface with Moment.js
|
@@ -535,7 +640,7 @@
|
|
535
640
|
offset;
|
536
641
|
|
537
642
|
if (mom._z === undefined) {
|
538
|
-
if (zone && needsOffset(mom) && !mom._isUTC) {
|
643
|
+
if (zone && needsOffset(mom) && !mom._isUTC && mom.isValid()) {
|
539
644
|
mom._d = moment.utc(mom._a)._d;
|
540
645
|
mom.utc().add(zone.parse(mom), 'minutes');
|
541
646
|
}
|
@@ -598,7 +703,7 @@
|
|
598
703
|
fn.utc = resetZoneWrap(fn.utc);
|
599
704
|
fn.local = resetZoneWrap(fn.local);
|
600
705
|
fn.utcOffset = resetZoneWrap2(fn.utcOffset);
|
601
|
-
|
706
|
+
|
602
707
|
moment.tz.setDefault = function(name) {
|
603
708
|
if (major < 2 || (major === 2 && minor < 9)) {
|
604
709
|
logError('Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js ' + moment.version + '.');
|
@@ -1 +1 @@
|
|
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(
|
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(r){"use strict";void 0===r.version&&r.default&&(r=r.default);var e,a={},i={},s={},c={},l={},t=(r&&"string"==typeof r.version||D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/"),r.version.split(".")),n=+t[0],o=+t[1];function f(t){return 96<t?t-87:64<t?t-29:t-48}function u(t){var e=0,n=t.split("."),o=n[0],r=n[1]||"",i=1,s=0,n=1;for(45===t.charCodeAt(0)&&(n=-(e=1));e<o.length;e++)s=60*s+f(o.charCodeAt(e));for(e=0;e<r.length;e++)i/=60,s+=f(r.charCodeAt(e))*i;return s*n}function h(t){for(var e=0;e<t.length;e++)t[e]=u(t[e])}function p(t,e){for(var n=[],o=0;o<e.length;o++)n[o]=t[e[o]];return n}function m(t){for(var t=t.split("|"),e=t[2].split(" "),n=t[3].split(""),o=t[4].split(" "),r=(h(e),h(n),h(o),o),i=n.length,s=0;s<i;s++)r[s]=Math.round((r[s-1]||0)+6e4*r[s]);return r[i-1]=1/0,{name:t[0],abbrs:p(t[1].split(" "),n),offsets:p(e,n),untils:o,population:0|t[5]}}function d(t){t&&this._set(m(t))}function z(t,e){this.name=t,this.zones=e}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(){for(var t,e,n,o=(new Date).getFullYear()-2,r=new v(new Date(o,0,1)),i=r.offset,s=[r],f=1;f<48;f++)(n=new Date(o,f,1).getTimezoneOffset())!==i&&(t=function(t,e){for(var n;n=6e4*((e.at-t.at)/12e4|0);)(n=new v(new Date(t.at+n))).offset===t.offset?t=n:e=n;return t}(r,e=new v(new Date(o,f,1))),s.push(t),s.push(new v(new Date(t.at+6e4))),r=e,i=n);for(f=0;f<4;f++)s.push(new v(new Date(o+f,0,1))),s.push(new v(new Date(o+f,6,1)));return s}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(){try{var t=Intl.DateTimeFormat().resolvedOptions().timeZone;if(t&&3<t.length){var e=c[y(t)];if(e)return e;D("Moment Timezone found "+t+" from the Intl api, but did not have that data loaded.")}}catch(t){}for(var n,o,r=g(),i=r.length,s=function(t){for(var e,n,o,r=t.length,i={},s=[],f={},u=0;u<r;u++)if(n=t[u].offset,!f.hasOwnProperty(n)){for(e in o=l[n]||{})o.hasOwnProperty(e)&&(i[e]=!0);f[n]=!0}for(u in i)i.hasOwnProperty(u)&&s.push(c[u]);return s}(r),f=[],u=0;u<s.length;u++){for(n=new b(S(s[u])),o=0;o<i;o++)n.scoreOffsetAt(r[o]);f.push(n)}return f.sort(_),0<f.length?f[0].zone.name:void 0}function y(t){return(t||"").toLowerCase().replace(/\//g,"_")}function O(t){var e,n,o,r;for("string"==typeof t&&(t=[t]),e=0;e<t.length;e++){r=y(n=(o=t[e].split("|"))[0]),a[r]=t[e],c[r]=n,s=i=u=f=void 0;var i,s,f=r,u=o[2].split(" ");for(h(u),i=0;i<u.length;i++)s=u[i],l[s]=l[s]||{},l[s][f]=!0}}function S(t,e){t=y(t);var n=a[t];return n instanceof d?n:"string"==typeof n?(n=new d(n),a[t]=n):i[t]&&e!==S&&(e=S(i[t],S))?((n=a[t]=new d)._set(e),n.name=c[t],n):null}function M(t){var e,n,o,r;for("string"==typeof t&&(t=[t]),e=0;e<t.length;e++)o=y((n=t[e].split("|"))[0]),r=y(n[1]),i[o]=r,c[o]=n[0],i[r]=o,c[r]=n[1]}function j(t){return j.didShowError||(j.didShowError=!0,D("moment.tz.zoneExists('"+t+"') has been deprecated in favor of !moment.tz.zone('"+t+"')")),!!S(t)}function A(t){var e="X"===t._f||"x"===t._f;return!(!t._a||void 0!==t._tzm||e)}function D(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t)}function T(t){var e=Array.prototype.slice.call(arguments,0,-1),n=arguments[arguments.length-1],e=r.utc.apply(null,e);return!r.isMoment(t)&&A(e)&&(t=S(n))&&e.add(t.parse(e),"minutes"),e.tz(n),e}(n<2||2==n&&o<6)&&D("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js "+r.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},_index:function(t){t=function(t,e){var n,o=e.length;if(t<e[0])return 0;if(1<o&&e[o-1]===1/0&&t>=e[o-2])return o-1;if(t>=e[o-1])return-1;for(var r=0,i=o-1;1<i-r;)e[n=Math.floor((r+i)/2)]<=t?r=n:i=n;return i}(+t,this.untils);if(0<=t)return t},countries:function(){var e=this.name;return Object.keys(s).filter(function(t){return-1!==s[t].zones.indexOf(e)})},parse:function(t){for(var e,n,o,r=+t,i=this.offsets,s=this.untils,f=s.length-1,u=0;u<f;u++)if(e=i[u],n=i[u+1],o=i[u&&u-1],e<n&&T.moveAmbiguousForward?e=n:o<e&&T.moveInvalidForward&&(e=o),r<s[u]-6e4*e)return i[u];return i[f]},abbr:function(t){return this.abbrs[this._index(t)]},offset:function(t){return D("zone.offset has been deprecated in favor of zone.utcOffset"),this.offsets[this._index(t)]},utcOffset:function(t){return this.offsets[this._index(t)]}},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++},T.version="0.5.47",T.dataVersion="",T._zones=a,T._links=i,T._names=c,T._countries=s,T.add=O,T.link=M,T.load=function(t){O(t.zones),M(t.links);var e,n,o,r=t.countries;if(r&&r.length)for(e=0;e<r.length;e++)n=(o=r[e].split("|"))[0].toUpperCase(),o=o[1].split(" "),s[n]=new z(n,o);T.dataVersion=t.version},T.zone=S,T.zoneExists=j,T.guess=function(t){return e=e&&!t?e:w()},T.names=function(){var t,e=[];for(t in c)c.hasOwnProperty(t)&&(a[t]||a[i[t]])&&c[t]&&e.push(c[t]);return e.sort()},T.Zone=d,T.unpack=m,T.unpackBase60=u,T.needsOffset=A,T.moveInvalidForward=!0,T.moveAmbiguousForward=!1,T.countries=function(){return Object.keys(s)},T.zonesForCountry=function(t,e){var n;return n=(n=t).toUpperCase(),(t=s[n]||null)?(n=t.zones.sort(),e?n.map(function(t){return{name:t,offset:S(t).utcOffset(new Date)}}):n):null};var x,t=r.fn;function C(t){return function(){return this._z?this._z.abbr(this):t.call(this)}}function Z(t){return function(){return this._z=null,t.apply(this,arguments)}}r.tz=T,r.defaultZone=null,r.updateOffset=function(t,e){var n,o=r.defaultZone;void 0===t._z&&(o&&A(t)&&!t._isUTC&&t.isValid()&&(t._d=r.utc(t._a)._d,t.utc().add(o.parse(t),"minutes")),t._z=o),t._z&&(o=t._z.utcOffset(t),Math.abs(o)<16&&(o/=60),void 0!==t.utcOffset?(n=t._z,t.utcOffset(-o,e),t._z=n):t.zone(o,e))},t.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=S(t),this._z?r.updateOffset(this,e):D("Moment Timezone has no data for "+t+". See http://momentjs.com/timezone/docs/#/data-loading/."),this}if(this._z)return this._z.name},t.zoneName=C(t.zoneName),t.zoneAbbr=C(t.zoneAbbr),t.utc=Z(t.utc),t.local=Z(t.local),t.utcOffset=(x=t.utcOffset,function(){return 0<arguments.length&&(this._z=null),x.apply(this,arguments)}),r.tz.setDefault=function(t){return(n<2||2==n&&o<9)&&D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js "+r.version+"."),r.defaultZone=t?S(t):null,r};t=r.momentProperties;return"[object Array]"===Object.prototype.toString.call(t)?(t.push("_z"),t.push("_a")):t&&(t._z=null),r});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moment_timezone-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lim Victor
|
@@ -90,5 +90,5 @@ requirements: []
|
|
90
90
|
rubygems_version: 3.5.22
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
|
-
summary: moment-timezone-0.5.
|
93
|
+
summary: moment-timezone-0.5.47
|
94
94
|
test_files: []
|