momentjs-rails 2.11.1 → 2.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/news.md +3 -0
- data/test/dummy/tmp/cache/assets/D1C/680/sprockets%2F16ed4d5afdb2919596e6f8790e2116c2 +0 -0
- data/test/dummy/tmp/cache/assets/D35/CA0/sprockets%2F493e64bce2d302801dc01cf7cd096a58 +0 -0
- data/test/dummy/tmp/cache/assets/D3F/5F0/sprockets%2F4a6c53eae7c6e41a69a191578bbb6417 +0 -0
- data/test/dummy/tmp/cache/assets/D58/BD0/sprockets%2F4de9ddc9b725c715a54c98697b2528fe +0 -0
- data/test/dummy/tmp/cache/assets/D75/510/sprockets%2Fe690787ac522f47a6be024bfcc1767ee +0 -0
- data/test/dummy/tmp/cache/assets/E10/250/sprockets%2Fe4badb9ddfda484eb9671bf88567be61 +0 -0
- data/test/integration/navigation_test.rb +1 -1
- data/vendor/assets/javascripts/moment.js +1517 -889
- data/vendor/assets/javascripts/moment/af.js +3 -3
- data/vendor/assets/javascripts/moment/ar-ly.js +122 -0
- data/vendor/assets/javascripts/moment/ar-ma.js +3 -2
- data/vendor/assets/javascripts/moment/ar-sa.js +3 -2
- data/vendor/assets/javascripts/moment/ar-tn.js +4 -2
- data/vendor/assets/javascripts/moment/ar.js +6 -5
- data/vendor/assets/javascripts/moment/az.js +3 -2
- data/vendor/assets/javascripts/moment/be.js +21 -21
- data/vendor/assets/javascripts/moment/bg.js +11 -11
- data/vendor/assets/javascripts/moment/bn.js +18 -12
- data/vendor/assets/javascripts/moment/bo.js +13 -4
- data/vendor/assets/javascripts/moment/br.js +11 -10
- data/vendor/assets/javascripts/moment/bs.js +73 -71
- data/vendor/assets/javascripts/moment/ca.js +4 -2
- data/vendor/assets/javascripts/moment/cs.js +76 -75
- data/vendor/assets/javascripts/moment/cv.js +2 -2
- data/vendor/assets/javascripts/moment/cy.js +5 -3
- data/vendor/assets/javascripts/moment/da.js +2 -2
- data/vendor/assets/javascripts/moment/de-at.js +4 -2
- data/vendor/assets/javascripts/moment/de.js +4 -2
- data/vendor/assets/javascripts/moment/dv.js +3 -3
- data/vendor/assets/javascripts/moment/el.js +2 -2
- data/vendor/assets/javascripts/moment/en-au.js +3 -2
- data/vendor/assets/javascripts/moment/en-ca.js +5 -5
- data/vendor/assets/javascripts/moment/en-gb.js +2 -2
- data/vendor/assets/javascripts/moment/en-ie.js +2 -2
- data/vendor/assets/javascripts/moment/en-nz.js +3 -2
- data/vendor/assets/javascripts/moment/eo.js +2 -2
- data/vendor/assets/javascripts/moment/es-do.js +80 -0
- data/vendor/assets/javascripts/moment/es.js +4 -2
- data/vendor/assets/javascripts/moment/et.js +2 -2
- data/vendor/assets/javascripts/moment/eu.js +4 -2
- data/vendor/assets/javascripts/moment/fa.js +3 -2
- data/vendor/assets/javascripts/moment/fi.js +29 -29
- data/vendor/assets/javascripts/moment/fo.js +2 -2
- data/vendor/assets/javascripts/moment/fr-ca.js +4 -2
- data/vendor/assets/javascripts/moment/fr-ch.js +4 -2
- data/vendor/assets/javascripts/moment/fr.js +4 -2
- data/vendor/assets/javascripts/moment/fy.js +4 -2
- data/vendor/assets/javascripts/moment/gd.js +2 -2
- data/vendor/assets/javascripts/moment/gl.js +15 -13
- data/vendor/assets/javascripts/moment/he.js +19 -2
- data/vendor/assets/javascripts/moment/hi.js +3 -2
- data/vendor/assets/javascripts/moment/hr.js +73 -71
- data/vendor/assets/javascripts/moment/hu.js +24 -24
- data/vendor/assets/javascripts/moment/hy-am.js +12 -12
- data/vendor/assets/javascripts/moment/id.js +2 -2
- data/vendor/assets/javascripts/moment/is.js +52 -52
- data/vendor/assets/javascripts/moment/it.js +2 -2
- data/vendor/assets/javascripts/moment/ja.js +13 -2
- data/vendor/assets/javascripts/moment/jv.js +2 -2
- data/vendor/assets/javascripts/moment/ka.js +2 -2
- data/vendor/assets/javascripts/moment/kk.js +7 -7
- data/vendor/assets/javascripts/moment/km.js +4 -4
- data/vendor/assets/javascripts/moment/ko.js +8 -11
- data/vendor/assets/javascripts/moment/ky.js +88 -0
- data/vendor/assets/javascripts/moment/lb.js +6 -3
- data/vendor/assets/javascripts/moment/lo.js +3 -2
- data/vendor/assets/javascripts/moment/lt.js +5 -3
- data/vendor/assets/javascripts/moment/lv.js +5 -4
- data/vendor/assets/javascripts/moment/me.js +21 -19
- data/vendor/assets/javascripts/moment/mi.js +64 -0
- data/vendor/assets/javascripts/moment/mk.js +11 -11
- data/vendor/assets/javascripts/moment/ml.js +14 -4
- data/vendor/assets/javascripts/moment/mr.js +3 -2
- data/vendor/assets/javascripts/moment/ms-my.js +3 -2
- data/vendor/assets/javascripts/moment/ms.js +2 -2
- data/vendor/assets/javascripts/moment/my.js +4 -2
- data/vendor/assets/javascripts/moment/nb.js +5 -3
- data/vendor/assets/javascripts/moment/ne.js +4 -2
- data/vendor/assets/javascripts/moment/nl.js +18 -3
- data/vendor/assets/javascripts/moment/nn.js +3 -3
- data/vendor/assets/javascripts/moment/pa-in.js +124 -0
- data/vendor/assets/javascripts/moment/pl.js +22 -22
- data/vendor/assets/javascripts/moment/pt-br.js +4 -3
- data/vendor/assets/javascripts/moment/pt.js +3 -2
- data/vendor/assets/javascripts/moment/ro.js +3 -2
- data/vendor/assets/javascripts/moment/ru.js +59 -42
- data/vendor/assets/javascripts/moment/se.js +2 -2
- data/vendor/assets/javascripts/moment/si.js +7 -2
- data/vendor/assets/javascripts/moment/sk.js +74 -74
- data/vendor/assets/javascripts/moment/sl.js +92 -90
- data/vendor/assets/javascripts/moment/sq.js +5 -4
- data/vendor/assets/javascripts/moment/sr-cyrl.js +21 -19
- data/vendor/assets/javascripts/moment/sr.js +21 -19
- data/vendor/assets/javascripts/moment/ss.js +89 -0
- data/vendor/assets/javascripts/moment/sv.js +6 -4
- data/vendor/assets/javascripts/moment/sw.js +3 -2
- data/vendor/assets/javascripts/moment/ta.js +2 -2
- data/vendor/assets/javascripts/moment/te.js +3 -2
- data/vendor/assets/javascripts/moment/th.js +9 -7
- data/vendor/assets/javascripts/moment/tl-ph.js +3 -3
- data/vendor/assets/javascripts/moment/tlh.js +18 -17
- data/vendor/assets/javascripts/moment/tr.js +2 -2
- data/vendor/assets/javascripts/moment/tzl.js +8 -4
- data/vendor/assets/javascripts/moment/tzm-latn.js +2 -2
- data/vendor/assets/javascripts/moment/tzm.js +2 -2
- data/vendor/assets/javascripts/moment/uk.js +21 -21
- data/vendor/assets/javascripts/moment/uz.js +2 -2
- data/vendor/assets/javascripts/moment/vi.js +15 -2
- data/vendor/assets/javascripts/moment/x-pseudo.js +68 -0
- data/vendor/assets/javascripts/moment/zh-cn.js +14 -14
- data/vendor/assets/javascripts/moment/zh-hk.js +105 -0
- data/vendor/assets/javascripts/moment/zh-tw.js +29 -26
- metadata +10 -4
- data/test/dummy/log/test.log +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64a317a47d77fc687d3379cb4c23287ae4d4ebe8
|
4
|
+
data.tar.gz: 6e5c73d259710d85c9375539b7e24a820a948887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07630497991d261938162ff755a88afb44d0c971e83c05e5bf3b80f86d50b807b0cb2fc6d70057ae630e839da45a9091463b80c9f5ac23824fe26e2c0347c097
|
7
|
+
data.tar.gz: 01263b52391c3354faaab0c532768d31db40345f04b2d5d2e5ca8cc6dcb15abd3d9a57b73daa01e66f15870dce7be2f8a885ef53d326739cd998d5921f215b60
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ If you want to include a localization file, also add the following directive:
|
|
26
26
|
|
27
27
|
## Versioning
|
28
28
|
|
29
|
-
momentjs-rails 2.
|
29
|
+
momentjs-rails 2.15.1 == Moment.js 2.15.1
|
30
30
|
|
31
31
|
Every attempt is made to mirror the currently shipping Moment.js version number
|
32
32
|
wherever possible. The major, minor, and patch version numbers will always
|
data/news.md
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -8,7 +8,7 @@ class NavigationTest < ActionDispatch::IntegrationTest
|
|
8
8
|
|
9
9
|
test 'momentjs response is for the expected version' do
|
10
10
|
get '/assets/moment.js'
|
11
|
-
assert_match(/utils_hooks__hooks.version = '2\.
|
11
|
+
assert_match(/utils_hooks__hooks.version = '2\.15\.1'/, @response.body)
|
12
12
|
end
|
13
13
|
|
14
14
|
test 'can access momentjs translation' do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
//! moment.js
|
2
|
-
//! version : 2.
|
2
|
+
//! version : 2.15.1
|
3
3
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
4
4
|
//! license : MIT
|
5
5
|
//! momentjs.com
|
@@ -23,7 +23,22 @@
|
|
23
23
|
}
|
24
24
|
|
25
25
|
function isArray(input) {
|
26
|
-
return Object.prototype.toString.call(input) === '[object Array]';
|
26
|
+
return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
27
|
+
}
|
28
|
+
|
29
|
+
function isObject(input) {
|
30
|
+
// IE8 will treat undefined and null as object if it wasn't for
|
31
|
+
// input != null
|
32
|
+
return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
33
|
+
}
|
34
|
+
|
35
|
+
function isObjectEmpty(obj) {
|
36
|
+
var k;
|
37
|
+
for (k in obj) {
|
38
|
+
// even if its not own property I'd still call it non-empty
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
return true;
|
27
42
|
}
|
28
43
|
|
29
44
|
function isDate(input) {
|
@@ -76,7 +91,9 @@
|
|
76
91
|
invalidMonth : null,
|
77
92
|
invalidFormat : false,
|
78
93
|
userInvalidated : false,
|
79
|
-
iso : false
|
94
|
+
iso : false,
|
95
|
+
parsedDateParts : [],
|
96
|
+
meridiem : null
|
80
97
|
};
|
81
98
|
}
|
82
99
|
|
@@ -87,24 +104,53 @@
|
|
87
104
|
return m._pf;
|
88
105
|
}
|
89
106
|
|
107
|
+
var some;
|
108
|
+
if (Array.prototype.some) {
|
109
|
+
some = Array.prototype.some;
|
110
|
+
} else {
|
111
|
+
some = function (fun) {
|
112
|
+
var t = Object(this);
|
113
|
+
var len = t.length >>> 0;
|
114
|
+
|
115
|
+
for (var i = 0; i < len; i++) {
|
116
|
+
if (i in t && fun.call(this, t[i], i, t)) {
|
117
|
+
return true;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
return false;
|
122
|
+
};
|
123
|
+
}
|
124
|
+
|
90
125
|
function valid__isValid(m) {
|
91
126
|
if (m._isValid == null) {
|
92
127
|
var flags = getParsingFlags(m);
|
93
|
-
|
128
|
+
var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
129
|
+
return i != null;
|
130
|
+
});
|
131
|
+
var isNowValid = !isNaN(m._d.getTime()) &&
|
94
132
|
flags.overflow < 0 &&
|
95
133
|
!flags.empty &&
|
96
134
|
!flags.invalidMonth &&
|
97
135
|
!flags.invalidWeekday &&
|
98
136
|
!flags.nullInput &&
|
99
137
|
!flags.invalidFormat &&
|
100
|
-
!flags.userInvalidated
|
138
|
+
!flags.userInvalidated &&
|
139
|
+
(!flags.meridiem || (flags.meridiem && parsedParts));
|
101
140
|
|
102
141
|
if (m._strict) {
|
103
|
-
|
142
|
+
isNowValid = isNowValid &&
|
104
143
|
flags.charsLeftOver === 0 &&
|
105
144
|
flags.unusedTokens.length === 0 &&
|
106
145
|
flags.bigHour === undefined;
|
107
146
|
}
|
147
|
+
|
148
|
+
if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
149
|
+
m._isValid = isNowValid;
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
return isNowValid;
|
153
|
+
}
|
108
154
|
}
|
109
155
|
return m._isValid;
|
110
156
|
}
|
@@ -197,7 +243,8 @@
|
|
197
243
|
|
198
244
|
function absFloor (number) {
|
199
245
|
if (number < 0) {
|
200
|
-
|
246
|
+
// -0 -> 0
|
247
|
+
return Math.ceil(number) || 0;
|
201
248
|
} else {
|
202
249
|
return Math.floor(number);
|
203
250
|
}
|
@@ -229,121 +276,203 @@
|
|
229
276
|
return diffs + lengthDiff;
|
230
277
|
}
|
231
278
|
|
232
|
-
function
|
279
|
+
function warn(msg) {
|
280
|
+
if (utils_hooks__hooks.suppressDeprecationWarnings === false &&
|
281
|
+
(typeof console !== 'undefined') && console.warn) {
|
282
|
+
console.warn('Deprecation warning: ' + msg);
|
283
|
+
}
|
233
284
|
}
|
234
285
|
|
235
|
-
|
236
|
-
|
237
|
-
var globalLocale;
|
286
|
+
function deprecate(msg, fn) {
|
287
|
+
var firstTime = true;
|
238
288
|
|
239
|
-
|
240
|
-
|
289
|
+
return extend(function () {
|
290
|
+
if (utils_hooks__hooks.deprecationHandler != null) {
|
291
|
+
utils_hooks__hooks.deprecationHandler(null, msg);
|
292
|
+
}
|
293
|
+
if (firstTime) {
|
294
|
+
var args = [];
|
295
|
+
var arg;
|
296
|
+
for (var i = 0; i < arguments.length; i++) {
|
297
|
+
arg = '';
|
298
|
+
if (typeof arguments[i] === 'object') {
|
299
|
+
arg += '\n[' + i + '] ';
|
300
|
+
for (var key in arguments[0]) {
|
301
|
+
arg += key + ': ' + arguments[0][key] + ', ';
|
302
|
+
}
|
303
|
+
arg = arg.slice(0, -2); // Remove trailing comma and space
|
304
|
+
} else {
|
305
|
+
arg = arguments[i];
|
306
|
+
}
|
307
|
+
args.push(arg);
|
308
|
+
}
|
309
|
+
warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
|
310
|
+
firstTime = false;
|
311
|
+
}
|
312
|
+
return fn.apply(this, arguments);
|
313
|
+
}, fn);
|
241
314
|
}
|
242
315
|
|
243
|
-
|
244
|
-
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
|
245
|
-
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
|
246
|
-
function chooseLocale(names) {
|
247
|
-
var i = 0, j, next, locale, split;
|
316
|
+
var deprecations = {};
|
248
317
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
if (locale) {
|
257
|
-
return locale;
|
258
|
-
}
|
259
|
-
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
260
|
-
//the next array item is better than a shallower substring of this one
|
261
|
-
break;
|
262
|
-
}
|
263
|
-
j--;
|
264
|
-
}
|
265
|
-
i++;
|
318
|
+
function deprecateSimple(name, msg) {
|
319
|
+
if (utils_hooks__hooks.deprecationHandler != null) {
|
320
|
+
utils_hooks__hooks.deprecationHandler(name, msg);
|
321
|
+
}
|
322
|
+
if (!deprecations[name]) {
|
323
|
+
warn(msg);
|
324
|
+
deprecations[name] = true;
|
266
325
|
}
|
267
|
-
return null;
|
268
326
|
}
|
269
327
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
328
|
+
utils_hooks__hooks.suppressDeprecationWarnings = false;
|
329
|
+
utils_hooks__hooks.deprecationHandler = null;
|
330
|
+
|
331
|
+
function isFunction(input) {
|
332
|
+
return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
333
|
+
}
|
334
|
+
|
335
|
+
function locale_set__set (config) {
|
336
|
+
var prop, i;
|
337
|
+
for (i in config) {
|
338
|
+
prop = config[i];
|
339
|
+
if (isFunction(prop)) {
|
340
|
+
this[i] = prop;
|
341
|
+
} else {
|
342
|
+
this['_' + i] = prop;
|
343
|
+
}
|
282
344
|
}
|
283
|
-
|
345
|
+
this._config = config;
|
346
|
+
// Lenient ordinal parsing accepts just a number in addition to
|
347
|
+
// number + (possibly) stuff coming from _ordinalParseLenient.
|
348
|
+
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
|
284
349
|
}
|
285
350
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
351
|
+
function mergeConfigs(parentConfig, childConfig) {
|
352
|
+
var res = extend({}, parentConfig), prop;
|
353
|
+
for (prop in childConfig) {
|
354
|
+
if (hasOwnProp(childConfig, prop)) {
|
355
|
+
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
356
|
+
res[prop] = {};
|
357
|
+
extend(res[prop], parentConfig[prop]);
|
358
|
+
extend(res[prop], childConfig[prop]);
|
359
|
+
} else if (childConfig[prop] != null) {
|
360
|
+
res[prop] = childConfig[prop];
|
361
|
+
} else {
|
362
|
+
delete res[prop];
|
363
|
+
}
|
294
364
|
}
|
295
|
-
|
296
|
-
|
365
|
+
}
|
366
|
+
for (prop in parentConfig) {
|
367
|
+
if (hasOwnProp(parentConfig, prop) &&
|
368
|
+
!hasOwnProp(childConfig, prop) &&
|
369
|
+
isObject(parentConfig[prop])) {
|
370
|
+
// make sure changes to properties don't modify parent config
|
371
|
+
res[prop] = extend({}, res[prop]);
|
297
372
|
}
|
373
|
+
}
|
374
|
+
return res;
|
375
|
+
}
|
298
376
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
}
|
377
|
+
function Locale(config) {
|
378
|
+
if (config != null) {
|
379
|
+
this.set(config);
|
303
380
|
}
|
381
|
+
}
|
304
382
|
|
305
|
-
|
383
|
+
var keys;
|
384
|
+
|
385
|
+
if (Object.keys) {
|
386
|
+
keys = Object.keys;
|
387
|
+
} else {
|
388
|
+
keys = function (obj) {
|
389
|
+
var i, res = [];
|
390
|
+
for (i in obj) {
|
391
|
+
if (hasOwnProp(obj, i)) {
|
392
|
+
res.push(i);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
return res;
|
396
|
+
};
|
306
397
|
}
|
307
398
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
399
|
+
var defaultCalendar = {
|
400
|
+
sameDay : '[Today at] LT',
|
401
|
+
nextDay : '[Tomorrow at] LT',
|
402
|
+
nextWeek : 'dddd [at] LT',
|
403
|
+
lastDay : '[Yesterday at] LT',
|
404
|
+
lastWeek : '[Last] dddd [at] LT',
|
405
|
+
sameElse : 'L'
|
406
|
+
};
|
313
407
|
|
314
|
-
|
315
|
-
|
408
|
+
function locale_calendar__calendar (key, mom, now) {
|
409
|
+
var output = this._calendar[key] || this._calendar['sameElse'];
|
410
|
+
return isFunction(output) ? output.call(mom, now) : output;
|
411
|
+
}
|
316
412
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
413
|
+
var defaultLongDateFormat = {
|
414
|
+
LTS : 'h:mm:ss A',
|
415
|
+
LT : 'h:mm A',
|
416
|
+
L : 'MM/DD/YYYY',
|
417
|
+
LL : 'MMMM D, YYYY',
|
418
|
+
LLL : 'MMMM D, YYYY h:mm A',
|
419
|
+
LLLL : 'dddd, MMMM D, YYYY h:mm A'
|
420
|
+
};
|
421
|
+
|
422
|
+
function longDateFormat (key) {
|
423
|
+
var format = this._longDateFormat[key],
|
424
|
+
formatUpper = this._longDateFormat[key.toUpperCase()];
|
425
|
+
|
426
|
+
if (format || !formatUpper) {
|
427
|
+
return format;
|
322
428
|
}
|
429
|
+
|
430
|
+
this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
431
|
+
return val.slice(1);
|
432
|
+
});
|
433
|
+
|
434
|
+
return this._longDateFormat[key];
|
323
435
|
}
|
324
436
|
|
325
|
-
|
326
|
-
function locale_locales__getLocale (key) {
|
327
|
-
var locale;
|
437
|
+
var defaultInvalidDate = 'Invalid date';
|
328
438
|
|
329
|
-
|
330
|
-
|
331
|
-
|
439
|
+
function invalidDate () {
|
440
|
+
return this._invalidDate;
|
441
|
+
}
|
332
442
|
|
333
|
-
|
334
|
-
|
335
|
-
}
|
443
|
+
var defaultOrdinal = '%d';
|
444
|
+
var defaultOrdinalParse = /\d{1,2}/;
|
336
445
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
if (locale) {
|
341
|
-
return locale;
|
342
|
-
}
|
343
|
-
key = [key];
|
344
|
-
}
|
446
|
+
function ordinal (number) {
|
447
|
+
return this._ordinal.replace('%d', number);
|
448
|
+
}
|
345
449
|
|
346
|
-
|
450
|
+
var defaultRelativeTime = {
|
451
|
+
future : 'in %s',
|
452
|
+
past : '%s ago',
|
453
|
+
s : 'a few seconds',
|
454
|
+
m : 'a minute',
|
455
|
+
mm : '%d minutes',
|
456
|
+
h : 'an hour',
|
457
|
+
hh : '%d hours',
|
458
|
+
d : 'a day',
|
459
|
+
dd : '%d days',
|
460
|
+
M : 'a month',
|
461
|
+
MM : '%d months',
|
462
|
+
y : 'a year',
|
463
|
+
yy : '%d years'
|
464
|
+
};
|
465
|
+
|
466
|
+
function relative__relativeTime (number, withoutSuffix, string, isFuture) {
|
467
|
+
var output = this._relativeTime[string];
|
468
|
+
return (isFunction(output)) ?
|
469
|
+
output(number, withoutSuffix, string, isFuture) :
|
470
|
+
output.replace(/%d/i, number);
|
471
|
+
}
|
472
|
+
|
473
|
+
function pastFuture (diff, output) {
|
474
|
+
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
475
|
+
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
347
476
|
}
|
348
477
|
|
349
478
|
var aliases = {};
|
@@ -374,8 +503,21 @@
|
|
374
503
|
return normalizedInput;
|
375
504
|
}
|
376
505
|
|
377
|
-
|
378
|
-
|
506
|
+
var priorities = {};
|
507
|
+
|
508
|
+
function addUnitPriority(unit, priority) {
|
509
|
+
priorities[unit] = priority;
|
510
|
+
}
|
511
|
+
|
512
|
+
function getPrioritizedUnits(unitsObj) {
|
513
|
+
var units = [];
|
514
|
+
for (var u in unitsObj) {
|
515
|
+
units.push({unit: u, priority: priorities[u]});
|
516
|
+
}
|
517
|
+
units.sort(function (a, b) {
|
518
|
+
return a.priority - b.priority;
|
519
|
+
});
|
520
|
+
return units;
|
379
521
|
}
|
380
522
|
|
381
523
|
function makeGetSet (unit, keepTime) {
|
@@ -403,11 +545,21 @@
|
|
403
545
|
|
404
546
|
// MOMENTS
|
405
547
|
|
406
|
-
function
|
407
|
-
|
548
|
+
function stringGet (units) {
|
549
|
+
units = normalizeUnits(units);
|
550
|
+
if (isFunction(this[units])) {
|
551
|
+
return this[units]();
|
552
|
+
}
|
553
|
+
return this;
|
554
|
+
}
|
555
|
+
|
556
|
+
|
557
|
+
function stringSet (units, value) {
|
408
558
|
if (typeof units === 'object') {
|
409
|
-
|
410
|
-
|
559
|
+
units = normalizeObjectUnits(units);
|
560
|
+
var prioritized = getPrioritizedUnits(units);
|
561
|
+
for (var i = 0; i < prioritized.length; i++) {
|
562
|
+
this[prioritized[i].unit](units[prioritized[i].unit]);
|
411
563
|
}
|
412
564
|
} else {
|
413
565
|
units = normalizeUnits(units);
|
@@ -426,7 +578,7 @@
|
|
426
578
|
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
427
579
|
}
|
428
580
|
|
429
|
-
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
581
|
+
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
430
582
|
|
431
583
|
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
432
584
|
|
@@ -479,7 +631,7 @@
|
|
479
631
|
}
|
480
632
|
|
481
633
|
return function (mom) {
|
482
|
-
var output = '';
|
634
|
+
var output = '', i;
|
483
635
|
for (i = 0; i < length; i++) {
|
484
636
|
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
|
485
637
|
}
|
@@ -608,6 +760,23 @@
|
|
608
760
|
var WEEK = 7;
|
609
761
|
var WEEKDAY = 8;
|
610
762
|
|
763
|
+
var indexOf;
|
764
|
+
|
765
|
+
if (Array.prototype.indexOf) {
|
766
|
+
indexOf = Array.prototype.indexOf;
|
767
|
+
} else {
|
768
|
+
indexOf = function (o) {
|
769
|
+
// I know
|
770
|
+
var i;
|
771
|
+
for (i = 0; i < this.length; ++i) {
|
772
|
+
if (this[i] === o) {
|
773
|
+
return i;
|
774
|
+
}
|
775
|
+
}
|
776
|
+
return -1;
|
777
|
+
};
|
778
|
+
}
|
779
|
+
|
611
780
|
function daysInMonth(year, month) {
|
612
781
|
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
613
782
|
}
|
@@ -630,6 +799,10 @@
|
|
630
799
|
|
631
800
|
addUnitAlias('month', 'M');
|
632
801
|
|
802
|
+
// PRIORITY
|
803
|
+
|
804
|
+
addUnitPriority('month', 8);
|
805
|
+
|
633
806
|
// PARSING
|
634
807
|
|
635
808
|
addRegexToken('M', match1to2);
|
@@ -660,34 +833,88 @@
|
|
660
833
|
var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/;
|
661
834
|
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
662
835
|
function localeMonths (m, format) {
|
836
|
+
if (!m) {
|
837
|
+
return this._months;
|
838
|
+
}
|
663
839
|
return isArray(this._months) ? this._months[m.month()] :
|
664
|
-
this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
840
|
+
this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
665
841
|
}
|
666
842
|
|
667
843
|
var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
668
844
|
function localeMonthsShort (m, format) {
|
845
|
+
if (!m) {
|
846
|
+
return this._monthsShort;
|
847
|
+
}
|
669
848
|
return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
|
670
849
|
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
671
850
|
}
|
672
851
|
|
673
|
-
function
|
674
|
-
var i, mom,
|
675
|
-
|
852
|
+
function units_month__handleStrictParse(monthName, format, strict) {
|
853
|
+
var i, ii, mom, llc = monthName.toLocaleLowerCase();
|
676
854
|
if (!this._monthsParse) {
|
855
|
+
// this is not used
|
677
856
|
this._monthsParse = [];
|
678
857
|
this._longMonthsParse = [];
|
679
858
|
this._shortMonthsParse = [];
|
859
|
+
for (i = 0; i < 12; ++i) {
|
860
|
+
mom = create_utc__createUTC([2000, i]);
|
861
|
+
this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
862
|
+
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
863
|
+
}
|
680
864
|
}
|
681
865
|
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
866
|
+
if (strict) {
|
867
|
+
if (format === 'MMM') {
|
868
|
+
ii = indexOf.call(this._shortMonthsParse, llc);
|
869
|
+
return ii !== -1 ? ii : null;
|
870
|
+
} else {
|
871
|
+
ii = indexOf.call(this._longMonthsParse, llc);
|
872
|
+
return ii !== -1 ? ii : null;
|
688
873
|
}
|
689
|
-
|
690
|
-
|
874
|
+
} else {
|
875
|
+
if (format === 'MMM') {
|
876
|
+
ii = indexOf.call(this._shortMonthsParse, llc);
|
877
|
+
if (ii !== -1) {
|
878
|
+
return ii;
|
879
|
+
}
|
880
|
+
ii = indexOf.call(this._longMonthsParse, llc);
|
881
|
+
return ii !== -1 ? ii : null;
|
882
|
+
} else {
|
883
|
+
ii = indexOf.call(this._longMonthsParse, llc);
|
884
|
+
if (ii !== -1) {
|
885
|
+
return ii;
|
886
|
+
}
|
887
|
+
ii = indexOf.call(this._shortMonthsParse, llc);
|
888
|
+
return ii !== -1 ? ii : null;
|
889
|
+
}
|
890
|
+
}
|
891
|
+
}
|
892
|
+
|
893
|
+
function localeMonthsParse (monthName, format, strict) {
|
894
|
+
var i, mom, regex;
|
895
|
+
|
896
|
+
if (this._monthsParseExact) {
|
897
|
+
return units_month__handleStrictParse.call(this, monthName, format, strict);
|
898
|
+
}
|
899
|
+
|
900
|
+
if (!this._monthsParse) {
|
901
|
+
this._monthsParse = [];
|
902
|
+
this._longMonthsParse = [];
|
903
|
+
this._shortMonthsParse = [];
|
904
|
+
}
|
905
|
+
|
906
|
+
// TODO: add sorting
|
907
|
+
// Sorting makes sure if one month (or abbr) is a prefix of another
|
908
|
+
// see sorting in computeMonthsParse
|
909
|
+
for (i = 0; i < 12; i++) {
|
910
|
+
// make the regex if we don't have it already
|
911
|
+
mom = create_utc__createUTC([2000, i]);
|
912
|
+
if (strict && !this._longMonthsParse[i]) {
|
913
|
+
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
914
|
+
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
915
|
+
}
|
916
|
+
if (!strict && !this._monthsParse[i]) {
|
917
|
+
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
691
918
|
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
692
919
|
}
|
693
920
|
// test the regex
|
@@ -711,12 +938,15 @@
|
|
711
938
|
return mom;
|
712
939
|
}
|
713
940
|
|
714
|
-
// TODO: Move this out of here!
|
715
941
|
if (typeof value === 'string') {
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
942
|
+
if (/^\d+$/.test(value)) {
|
943
|
+
value = toInt(value);
|
944
|
+
} else {
|
945
|
+
value = mom.localeData().monthsParse(value);
|
946
|
+
// TODO: Another silent failure?
|
947
|
+
if (typeof value !== 'number') {
|
948
|
+
return mom;
|
949
|
+
}
|
720
950
|
}
|
721
951
|
}
|
722
952
|
|
@@ -751,6 +981,9 @@
|
|
751
981
|
return this._monthsShortRegex;
|
752
982
|
}
|
753
983
|
} else {
|
984
|
+
if (!hasOwnProp(this, '_monthsShortRegex')) {
|
985
|
+
this._monthsShortRegex = defaultMonthsShortRegex;
|
986
|
+
}
|
754
987
|
return this._monthsShortStrictRegex && isStrict ?
|
755
988
|
this._monthsShortStrictRegex : this._monthsShortRegex;
|
756
989
|
}
|
@@ -768,41 +1001,916 @@
|
|
768
1001
|
return this._monthsRegex;
|
769
1002
|
}
|
770
1003
|
} else {
|
1004
|
+
if (!hasOwnProp(this, '_monthsRegex')) {
|
1005
|
+
this._monthsRegex = defaultMonthsRegex;
|
1006
|
+
}
|
771
1007
|
return this._monthsStrictRegex && isStrict ?
|
772
1008
|
this._monthsStrictRegex : this._monthsRegex;
|
773
1009
|
}
|
774
1010
|
}
|
775
1011
|
|
776
|
-
function computeMonthsParse () {
|
777
|
-
function cmpLenRev(a, b) {
|
778
|
-
return b.length - a.length;
|
1012
|
+
function computeMonthsParse () {
|
1013
|
+
function cmpLenRev(a, b) {
|
1014
|
+
return b.length - a.length;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
var shortPieces = [], longPieces = [], mixedPieces = [],
|
1018
|
+
i, mom;
|
1019
|
+
for (i = 0; i < 12; i++) {
|
1020
|
+
// make the regex if we don't have it already
|
1021
|
+
mom = create_utc__createUTC([2000, i]);
|
1022
|
+
shortPieces.push(this.monthsShort(mom, ''));
|
1023
|
+
longPieces.push(this.months(mom, ''));
|
1024
|
+
mixedPieces.push(this.months(mom, ''));
|
1025
|
+
mixedPieces.push(this.monthsShort(mom, ''));
|
1026
|
+
}
|
1027
|
+
// Sorting makes sure if one month (or abbr) is a prefix of another it
|
1028
|
+
// will match the longer piece.
|
1029
|
+
shortPieces.sort(cmpLenRev);
|
1030
|
+
longPieces.sort(cmpLenRev);
|
1031
|
+
mixedPieces.sort(cmpLenRev);
|
1032
|
+
for (i = 0; i < 12; i++) {
|
1033
|
+
shortPieces[i] = regexEscape(shortPieces[i]);
|
1034
|
+
longPieces[i] = regexEscape(longPieces[i]);
|
1035
|
+
}
|
1036
|
+
for (i = 0; i < 24; i++) {
|
1037
|
+
mixedPieces[i] = regexEscape(mixedPieces[i]);
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
1041
|
+
this._monthsShortRegex = this._monthsRegex;
|
1042
|
+
this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
1043
|
+
this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
// FORMATTING
|
1047
|
+
|
1048
|
+
addFormatToken('Y', 0, 0, function () {
|
1049
|
+
var y = this.year();
|
1050
|
+
return y <= 9999 ? '' + y : '+' + y;
|
1051
|
+
});
|
1052
|
+
|
1053
|
+
addFormatToken(0, ['YY', 2], 0, function () {
|
1054
|
+
return this.year() % 100;
|
1055
|
+
});
|
1056
|
+
|
1057
|
+
addFormatToken(0, ['YYYY', 4], 0, 'year');
|
1058
|
+
addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
1059
|
+
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
1060
|
+
|
1061
|
+
// ALIASES
|
1062
|
+
|
1063
|
+
addUnitAlias('year', 'y');
|
1064
|
+
|
1065
|
+
// PRIORITIES
|
1066
|
+
|
1067
|
+
addUnitPriority('year', 1);
|
1068
|
+
|
1069
|
+
// PARSING
|
1070
|
+
|
1071
|
+
addRegexToken('Y', matchSigned);
|
1072
|
+
addRegexToken('YY', match1to2, match2);
|
1073
|
+
addRegexToken('YYYY', match1to4, match4);
|
1074
|
+
addRegexToken('YYYYY', match1to6, match6);
|
1075
|
+
addRegexToken('YYYYYY', match1to6, match6);
|
1076
|
+
|
1077
|
+
addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
1078
|
+
addParseToken('YYYY', function (input, array) {
|
1079
|
+
array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
|
1080
|
+
});
|
1081
|
+
addParseToken('YY', function (input, array) {
|
1082
|
+
array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
|
1083
|
+
});
|
1084
|
+
addParseToken('Y', function (input, array) {
|
1085
|
+
array[YEAR] = parseInt(input, 10);
|
1086
|
+
});
|
1087
|
+
|
1088
|
+
// HELPERS
|
1089
|
+
|
1090
|
+
function daysInYear(year) {
|
1091
|
+
return isLeapYear(year) ? 366 : 365;
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
function isLeapYear(year) {
|
1095
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
// HOOKS
|
1099
|
+
|
1100
|
+
utils_hooks__hooks.parseTwoDigitYear = function (input) {
|
1101
|
+
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
1102
|
+
};
|
1103
|
+
|
1104
|
+
// MOMENTS
|
1105
|
+
|
1106
|
+
var getSetYear = makeGetSet('FullYear', true);
|
1107
|
+
|
1108
|
+
function getIsLeapYear () {
|
1109
|
+
return isLeapYear(this.year());
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
function createDate (y, m, d, h, M, s, ms) {
|
1113
|
+
//can't just apply() to create a date:
|
1114
|
+
//http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
|
1115
|
+
var date = new Date(y, m, d, h, M, s, ms);
|
1116
|
+
|
1117
|
+
//the date constructor remaps years 0-99 to 1900-1999
|
1118
|
+
if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
|
1119
|
+
date.setFullYear(y);
|
1120
|
+
}
|
1121
|
+
return date;
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
function createUTCDate (y) {
|
1125
|
+
var date = new Date(Date.UTC.apply(null, arguments));
|
1126
|
+
|
1127
|
+
//the Date.UTC function remaps years 0-99 to 1900-1999
|
1128
|
+
if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
|
1129
|
+
date.setUTCFullYear(y);
|
1130
|
+
}
|
1131
|
+
return date;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
// start-of-first-week - start-of-year
|
1135
|
+
function firstWeekOffset(year, dow, doy) {
|
1136
|
+
var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
|
1137
|
+
fwd = 7 + dow - doy,
|
1138
|
+
// first-week day local weekday -- which local weekday is fwd
|
1139
|
+
fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
1140
|
+
|
1141
|
+
return -fwdlw + fwd - 1;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
|
1145
|
+
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
1146
|
+
var localWeekday = (7 + weekday - dow) % 7,
|
1147
|
+
weekOffset = firstWeekOffset(year, dow, doy),
|
1148
|
+
dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
1149
|
+
resYear, resDayOfYear;
|
1150
|
+
|
1151
|
+
if (dayOfYear <= 0) {
|
1152
|
+
resYear = year - 1;
|
1153
|
+
resDayOfYear = daysInYear(resYear) + dayOfYear;
|
1154
|
+
} else if (dayOfYear > daysInYear(year)) {
|
1155
|
+
resYear = year + 1;
|
1156
|
+
resDayOfYear = dayOfYear - daysInYear(year);
|
1157
|
+
} else {
|
1158
|
+
resYear = year;
|
1159
|
+
resDayOfYear = dayOfYear;
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
return {
|
1163
|
+
year: resYear,
|
1164
|
+
dayOfYear: resDayOfYear
|
1165
|
+
};
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
function weekOfYear(mom, dow, doy) {
|
1169
|
+
var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
1170
|
+
week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
1171
|
+
resWeek, resYear;
|
1172
|
+
|
1173
|
+
if (week < 1) {
|
1174
|
+
resYear = mom.year() - 1;
|
1175
|
+
resWeek = week + weeksInYear(resYear, dow, doy);
|
1176
|
+
} else if (week > weeksInYear(mom.year(), dow, doy)) {
|
1177
|
+
resWeek = week - weeksInYear(mom.year(), dow, doy);
|
1178
|
+
resYear = mom.year() + 1;
|
1179
|
+
} else {
|
1180
|
+
resYear = mom.year();
|
1181
|
+
resWeek = week;
|
1182
|
+
}
|
1183
|
+
|
1184
|
+
return {
|
1185
|
+
week: resWeek,
|
1186
|
+
year: resYear
|
1187
|
+
};
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
function weeksInYear(year, dow, doy) {
|
1191
|
+
var weekOffset = firstWeekOffset(year, dow, doy),
|
1192
|
+
weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
1193
|
+
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
// FORMATTING
|
1197
|
+
|
1198
|
+
addFormatToken('w', ['ww', 2], 'wo', 'week');
|
1199
|
+
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
1200
|
+
|
1201
|
+
// ALIASES
|
1202
|
+
|
1203
|
+
addUnitAlias('week', 'w');
|
1204
|
+
addUnitAlias('isoWeek', 'W');
|
1205
|
+
|
1206
|
+
// PRIORITIES
|
1207
|
+
|
1208
|
+
addUnitPriority('week', 5);
|
1209
|
+
addUnitPriority('isoWeek', 5);
|
1210
|
+
|
1211
|
+
// PARSING
|
1212
|
+
|
1213
|
+
addRegexToken('w', match1to2);
|
1214
|
+
addRegexToken('ww', match1to2, match2);
|
1215
|
+
addRegexToken('W', match1to2);
|
1216
|
+
addRegexToken('WW', match1to2, match2);
|
1217
|
+
|
1218
|
+
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
1219
|
+
week[token.substr(0, 1)] = toInt(input);
|
1220
|
+
});
|
1221
|
+
|
1222
|
+
// HELPERS
|
1223
|
+
|
1224
|
+
// LOCALES
|
1225
|
+
|
1226
|
+
function localeWeek (mom) {
|
1227
|
+
return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
1228
|
+
}
|
1229
|
+
|
1230
|
+
var defaultLocaleWeek = {
|
1231
|
+
dow : 0, // Sunday is the first day of the week.
|
1232
|
+
doy : 6 // The week that contains Jan 1st is the first week of the year.
|
1233
|
+
};
|
1234
|
+
|
1235
|
+
function localeFirstDayOfWeek () {
|
1236
|
+
return this._week.dow;
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
function localeFirstDayOfYear () {
|
1240
|
+
return this._week.doy;
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
// MOMENTS
|
1244
|
+
|
1245
|
+
function getSetWeek (input) {
|
1246
|
+
var week = this.localeData().week(this);
|
1247
|
+
return input == null ? week : this.add((input - week) * 7, 'd');
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
function getSetISOWeek (input) {
|
1251
|
+
var week = weekOfYear(this, 1, 4).week;
|
1252
|
+
return input == null ? week : this.add((input - week) * 7, 'd');
|
1253
|
+
}
|
1254
|
+
|
1255
|
+
// FORMATTING
|
1256
|
+
|
1257
|
+
addFormatToken('d', 0, 'do', 'day');
|
1258
|
+
|
1259
|
+
addFormatToken('dd', 0, 0, function (format) {
|
1260
|
+
return this.localeData().weekdaysMin(this, format);
|
1261
|
+
});
|
1262
|
+
|
1263
|
+
addFormatToken('ddd', 0, 0, function (format) {
|
1264
|
+
return this.localeData().weekdaysShort(this, format);
|
1265
|
+
});
|
1266
|
+
|
1267
|
+
addFormatToken('dddd', 0, 0, function (format) {
|
1268
|
+
return this.localeData().weekdays(this, format);
|
1269
|
+
});
|
1270
|
+
|
1271
|
+
addFormatToken('e', 0, 0, 'weekday');
|
1272
|
+
addFormatToken('E', 0, 0, 'isoWeekday');
|
1273
|
+
|
1274
|
+
// ALIASES
|
1275
|
+
|
1276
|
+
addUnitAlias('day', 'd');
|
1277
|
+
addUnitAlias('weekday', 'e');
|
1278
|
+
addUnitAlias('isoWeekday', 'E');
|
1279
|
+
|
1280
|
+
// PRIORITY
|
1281
|
+
addUnitPriority('day', 11);
|
1282
|
+
addUnitPriority('weekday', 11);
|
1283
|
+
addUnitPriority('isoWeekday', 11);
|
1284
|
+
|
1285
|
+
// PARSING
|
1286
|
+
|
1287
|
+
addRegexToken('d', match1to2);
|
1288
|
+
addRegexToken('e', match1to2);
|
1289
|
+
addRegexToken('E', match1to2);
|
1290
|
+
addRegexToken('dd', function (isStrict, locale) {
|
1291
|
+
return locale.weekdaysMinRegex(isStrict);
|
1292
|
+
});
|
1293
|
+
addRegexToken('ddd', function (isStrict, locale) {
|
1294
|
+
return locale.weekdaysShortRegex(isStrict);
|
1295
|
+
});
|
1296
|
+
addRegexToken('dddd', function (isStrict, locale) {
|
1297
|
+
return locale.weekdaysRegex(isStrict);
|
1298
|
+
});
|
1299
|
+
|
1300
|
+
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
1301
|
+
var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
1302
|
+
// if we didn't get a weekday name, mark the date as invalid
|
1303
|
+
if (weekday != null) {
|
1304
|
+
week.d = weekday;
|
1305
|
+
} else {
|
1306
|
+
getParsingFlags(config).invalidWeekday = input;
|
1307
|
+
}
|
1308
|
+
});
|
1309
|
+
|
1310
|
+
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
1311
|
+
week[token] = toInt(input);
|
1312
|
+
});
|
1313
|
+
|
1314
|
+
// HELPERS
|
1315
|
+
|
1316
|
+
function parseWeekday(input, locale) {
|
1317
|
+
if (typeof input !== 'string') {
|
1318
|
+
return input;
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
if (!isNaN(input)) {
|
1322
|
+
return parseInt(input, 10);
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
input = locale.weekdaysParse(input);
|
1326
|
+
if (typeof input === 'number') {
|
1327
|
+
return input;
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
return null;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
function parseIsoWeekday(input, locale) {
|
1334
|
+
if (typeof input === 'string') {
|
1335
|
+
return locale.weekdaysParse(input) % 7 || 7;
|
1336
|
+
}
|
1337
|
+
return isNaN(input) ? null : input;
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
// LOCALES
|
1341
|
+
|
1342
|
+
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
1343
|
+
function localeWeekdays (m, format) {
|
1344
|
+
if (!m) {
|
1345
|
+
return this._weekdays;
|
1346
|
+
}
|
1347
|
+
return isArray(this._weekdays) ? this._weekdays[m.day()] :
|
1348
|
+
this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
1352
|
+
function localeWeekdaysShort (m) {
|
1353
|
+
return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
1357
|
+
function localeWeekdaysMin (m) {
|
1358
|
+
return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
1359
|
+
}
|
1360
|
+
|
1361
|
+
function day_of_week__handleStrictParse(weekdayName, format, strict) {
|
1362
|
+
var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
|
1363
|
+
if (!this._weekdaysParse) {
|
1364
|
+
this._weekdaysParse = [];
|
1365
|
+
this._shortWeekdaysParse = [];
|
1366
|
+
this._minWeekdaysParse = [];
|
1367
|
+
|
1368
|
+
for (i = 0; i < 7; ++i) {
|
1369
|
+
mom = create_utc__createUTC([2000, 1]).day(i);
|
1370
|
+
this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
1371
|
+
this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
1372
|
+
this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
1373
|
+
}
|
1374
|
+
}
|
1375
|
+
|
1376
|
+
if (strict) {
|
1377
|
+
if (format === 'dddd') {
|
1378
|
+
ii = indexOf.call(this._weekdaysParse, llc);
|
1379
|
+
return ii !== -1 ? ii : null;
|
1380
|
+
} else if (format === 'ddd') {
|
1381
|
+
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1382
|
+
return ii !== -1 ? ii : null;
|
1383
|
+
} else {
|
1384
|
+
ii = indexOf.call(this._minWeekdaysParse, llc);
|
1385
|
+
return ii !== -1 ? ii : null;
|
1386
|
+
}
|
1387
|
+
} else {
|
1388
|
+
if (format === 'dddd') {
|
1389
|
+
ii = indexOf.call(this._weekdaysParse, llc);
|
1390
|
+
if (ii !== -1) {
|
1391
|
+
return ii;
|
1392
|
+
}
|
1393
|
+
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1394
|
+
if (ii !== -1) {
|
1395
|
+
return ii;
|
1396
|
+
}
|
1397
|
+
ii = indexOf.call(this._minWeekdaysParse, llc);
|
1398
|
+
return ii !== -1 ? ii : null;
|
1399
|
+
} else if (format === 'ddd') {
|
1400
|
+
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1401
|
+
if (ii !== -1) {
|
1402
|
+
return ii;
|
1403
|
+
}
|
1404
|
+
ii = indexOf.call(this._weekdaysParse, llc);
|
1405
|
+
if (ii !== -1) {
|
1406
|
+
return ii;
|
1407
|
+
}
|
1408
|
+
ii = indexOf.call(this._minWeekdaysParse, llc);
|
1409
|
+
return ii !== -1 ? ii : null;
|
1410
|
+
} else {
|
1411
|
+
ii = indexOf.call(this._minWeekdaysParse, llc);
|
1412
|
+
if (ii !== -1) {
|
1413
|
+
return ii;
|
1414
|
+
}
|
1415
|
+
ii = indexOf.call(this._weekdaysParse, llc);
|
1416
|
+
if (ii !== -1) {
|
1417
|
+
return ii;
|
1418
|
+
}
|
1419
|
+
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1420
|
+
return ii !== -1 ? ii : null;
|
1421
|
+
}
|
1422
|
+
}
|
1423
|
+
}
|
1424
|
+
|
1425
|
+
function localeWeekdaysParse (weekdayName, format, strict) {
|
1426
|
+
var i, mom, regex;
|
1427
|
+
|
1428
|
+
if (this._weekdaysParseExact) {
|
1429
|
+
return day_of_week__handleStrictParse.call(this, weekdayName, format, strict);
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
if (!this._weekdaysParse) {
|
1433
|
+
this._weekdaysParse = [];
|
1434
|
+
this._minWeekdaysParse = [];
|
1435
|
+
this._shortWeekdaysParse = [];
|
1436
|
+
this._fullWeekdaysParse = [];
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
for (i = 0; i < 7; i++) {
|
1440
|
+
// make the regex if we don't have it already
|
1441
|
+
|
1442
|
+
mom = create_utc__createUTC([2000, 1]).day(i);
|
1443
|
+
if (strict && !this._fullWeekdaysParse[i]) {
|
1444
|
+
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
|
1445
|
+
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
|
1446
|
+
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
|
1447
|
+
}
|
1448
|
+
if (!this._weekdaysParse[i]) {
|
1449
|
+
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
1450
|
+
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
1451
|
+
}
|
1452
|
+
// test the regex
|
1453
|
+
if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
1454
|
+
return i;
|
1455
|
+
} else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
1456
|
+
return i;
|
1457
|
+
} else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
1458
|
+
return i;
|
1459
|
+
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
1460
|
+
return i;
|
1461
|
+
}
|
1462
|
+
}
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
// MOMENTS
|
1466
|
+
|
1467
|
+
function getSetDayOfWeek (input) {
|
1468
|
+
if (!this.isValid()) {
|
1469
|
+
return input != null ? this : NaN;
|
1470
|
+
}
|
1471
|
+
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
1472
|
+
if (input != null) {
|
1473
|
+
input = parseWeekday(input, this.localeData());
|
1474
|
+
return this.add(input - day, 'd');
|
1475
|
+
} else {
|
1476
|
+
return day;
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
|
1480
|
+
function getSetLocaleDayOfWeek (input) {
|
1481
|
+
if (!this.isValid()) {
|
1482
|
+
return input != null ? this : NaN;
|
1483
|
+
}
|
1484
|
+
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
1485
|
+
return input == null ? weekday : this.add(input - weekday, 'd');
|
1486
|
+
}
|
1487
|
+
|
1488
|
+
function getSetISODayOfWeek (input) {
|
1489
|
+
if (!this.isValid()) {
|
1490
|
+
return input != null ? this : NaN;
|
1491
|
+
}
|
1492
|
+
|
1493
|
+
// behaves the same as moment#day except
|
1494
|
+
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
|
1495
|
+
// as a setter, sunday should belong to the previous week.
|
1496
|
+
|
1497
|
+
if (input != null) {
|
1498
|
+
var weekday = parseIsoWeekday(input, this.localeData());
|
1499
|
+
return this.day(this.day() % 7 ? weekday : weekday - 7);
|
1500
|
+
} else {
|
1501
|
+
return this.day() || 7;
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
var defaultWeekdaysRegex = matchWord;
|
1506
|
+
function weekdaysRegex (isStrict) {
|
1507
|
+
if (this._weekdaysParseExact) {
|
1508
|
+
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1509
|
+
computeWeekdaysParse.call(this);
|
1510
|
+
}
|
1511
|
+
if (isStrict) {
|
1512
|
+
return this._weekdaysStrictRegex;
|
1513
|
+
} else {
|
1514
|
+
return this._weekdaysRegex;
|
1515
|
+
}
|
1516
|
+
} else {
|
1517
|
+
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1518
|
+
this._weekdaysRegex = defaultWeekdaysRegex;
|
1519
|
+
}
|
1520
|
+
return this._weekdaysStrictRegex && isStrict ?
|
1521
|
+
this._weekdaysStrictRegex : this._weekdaysRegex;
|
1522
|
+
}
|
1523
|
+
}
|
1524
|
+
|
1525
|
+
var defaultWeekdaysShortRegex = matchWord;
|
1526
|
+
function weekdaysShortRegex (isStrict) {
|
1527
|
+
if (this._weekdaysParseExact) {
|
1528
|
+
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1529
|
+
computeWeekdaysParse.call(this);
|
1530
|
+
}
|
1531
|
+
if (isStrict) {
|
1532
|
+
return this._weekdaysShortStrictRegex;
|
1533
|
+
} else {
|
1534
|
+
return this._weekdaysShortRegex;
|
1535
|
+
}
|
1536
|
+
} else {
|
1537
|
+
if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
1538
|
+
this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
1539
|
+
}
|
1540
|
+
return this._weekdaysShortStrictRegex && isStrict ?
|
1541
|
+
this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
1542
|
+
}
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
var defaultWeekdaysMinRegex = matchWord;
|
1546
|
+
function weekdaysMinRegex (isStrict) {
|
1547
|
+
if (this._weekdaysParseExact) {
|
1548
|
+
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1549
|
+
computeWeekdaysParse.call(this);
|
1550
|
+
}
|
1551
|
+
if (isStrict) {
|
1552
|
+
return this._weekdaysMinStrictRegex;
|
1553
|
+
} else {
|
1554
|
+
return this._weekdaysMinRegex;
|
1555
|
+
}
|
1556
|
+
} else {
|
1557
|
+
if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
1558
|
+
this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
1559
|
+
}
|
1560
|
+
return this._weekdaysMinStrictRegex && isStrict ?
|
1561
|
+
this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
1562
|
+
}
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
|
1566
|
+
function computeWeekdaysParse () {
|
1567
|
+
function cmpLenRev(a, b) {
|
1568
|
+
return b.length - a.length;
|
1569
|
+
}
|
1570
|
+
|
1571
|
+
var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
|
1572
|
+
i, mom, minp, shortp, longp;
|
1573
|
+
for (i = 0; i < 7; i++) {
|
1574
|
+
// make the regex if we don't have it already
|
1575
|
+
mom = create_utc__createUTC([2000, 1]).day(i);
|
1576
|
+
minp = this.weekdaysMin(mom, '');
|
1577
|
+
shortp = this.weekdaysShort(mom, '');
|
1578
|
+
longp = this.weekdays(mom, '');
|
1579
|
+
minPieces.push(minp);
|
1580
|
+
shortPieces.push(shortp);
|
1581
|
+
longPieces.push(longp);
|
1582
|
+
mixedPieces.push(minp);
|
1583
|
+
mixedPieces.push(shortp);
|
1584
|
+
mixedPieces.push(longp);
|
1585
|
+
}
|
1586
|
+
// Sorting makes sure if one weekday (or abbr) is a prefix of another it
|
1587
|
+
// will match the longer piece.
|
1588
|
+
minPieces.sort(cmpLenRev);
|
1589
|
+
shortPieces.sort(cmpLenRev);
|
1590
|
+
longPieces.sort(cmpLenRev);
|
1591
|
+
mixedPieces.sort(cmpLenRev);
|
1592
|
+
for (i = 0; i < 7; i++) {
|
1593
|
+
shortPieces[i] = regexEscape(shortPieces[i]);
|
1594
|
+
longPieces[i] = regexEscape(longPieces[i]);
|
1595
|
+
mixedPieces[i] = regexEscape(mixedPieces[i]);
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
1599
|
+
this._weekdaysShortRegex = this._weekdaysRegex;
|
1600
|
+
this._weekdaysMinRegex = this._weekdaysRegex;
|
1601
|
+
|
1602
|
+
this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
1603
|
+
this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
1604
|
+
this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
1605
|
+
}
|
1606
|
+
|
1607
|
+
// FORMATTING
|
1608
|
+
|
1609
|
+
function hFormat() {
|
1610
|
+
return this.hours() % 12 || 12;
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
function kFormat() {
|
1614
|
+
return this.hours() || 24;
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
addFormatToken('H', ['HH', 2], 0, 'hour');
|
1618
|
+
addFormatToken('h', ['hh', 2], 0, hFormat);
|
1619
|
+
addFormatToken('k', ['kk', 2], 0, kFormat);
|
1620
|
+
|
1621
|
+
addFormatToken('hmm', 0, 0, function () {
|
1622
|
+
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
1623
|
+
});
|
1624
|
+
|
1625
|
+
addFormatToken('hmmss', 0, 0, function () {
|
1626
|
+
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
|
1627
|
+
zeroFill(this.seconds(), 2);
|
1628
|
+
});
|
1629
|
+
|
1630
|
+
addFormatToken('Hmm', 0, 0, function () {
|
1631
|
+
return '' + this.hours() + zeroFill(this.minutes(), 2);
|
1632
|
+
});
|
1633
|
+
|
1634
|
+
addFormatToken('Hmmss', 0, 0, function () {
|
1635
|
+
return '' + this.hours() + zeroFill(this.minutes(), 2) +
|
1636
|
+
zeroFill(this.seconds(), 2);
|
1637
|
+
});
|
1638
|
+
|
1639
|
+
function meridiem (token, lowercase) {
|
1640
|
+
addFormatToken(token, 0, 0, function () {
|
1641
|
+
return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
1642
|
+
});
|
1643
|
+
}
|
1644
|
+
|
1645
|
+
meridiem('a', true);
|
1646
|
+
meridiem('A', false);
|
1647
|
+
|
1648
|
+
// ALIASES
|
1649
|
+
|
1650
|
+
addUnitAlias('hour', 'h');
|
1651
|
+
|
1652
|
+
// PRIORITY
|
1653
|
+
addUnitPriority('hour', 13);
|
1654
|
+
|
1655
|
+
// PARSING
|
1656
|
+
|
1657
|
+
function matchMeridiem (isStrict, locale) {
|
1658
|
+
return locale._meridiemParse;
|
1659
|
+
}
|
1660
|
+
|
1661
|
+
addRegexToken('a', matchMeridiem);
|
1662
|
+
addRegexToken('A', matchMeridiem);
|
1663
|
+
addRegexToken('H', match1to2);
|
1664
|
+
addRegexToken('h', match1to2);
|
1665
|
+
addRegexToken('HH', match1to2, match2);
|
1666
|
+
addRegexToken('hh', match1to2, match2);
|
1667
|
+
|
1668
|
+
addRegexToken('hmm', match3to4);
|
1669
|
+
addRegexToken('hmmss', match5to6);
|
1670
|
+
addRegexToken('Hmm', match3to4);
|
1671
|
+
addRegexToken('Hmmss', match5to6);
|
1672
|
+
|
1673
|
+
addParseToken(['H', 'HH'], HOUR);
|
1674
|
+
addParseToken(['a', 'A'], function (input, array, config) {
|
1675
|
+
config._isPm = config._locale.isPM(input);
|
1676
|
+
config._meridiem = input;
|
1677
|
+
});
|
1678
|
+
addParseToken(['h', 'hh'], function (input, array, config) {
|
1679
|
+
array[HOUR] = toInt(input);
|
1680
|
+
getParsingFlags(config).bigHour = true;
|
1681
|
+
});
|
1682
|
+
addParseToken('hmm', function (input, array, config) {
|
1683
|
+
var pos = input.length - 2;
|
1684
|
+
array[HOUR] = toInt(input.substr(0, pos));
|
1685
|
+
array[MINUTE] = toInt(input.substr(pos));
|
1686
|
+
getParsingFlags(config).bigHour = true;
|
1687
|
+
});
|
1688
|
+
addParseToken('hmmss', function (input, array, config) {
|
1689
|
+
var pos1 = input.length - 4;
|
1690
|
+
var pos2 = input.length - 2;
|
1691
|
+
array[HOUR] = toInt(input.substr(0, pos1));
|
1692
|
+
array[MINUTE] = toInt(input.substr(pos1, 2));
|
1693
|
+
array[SECOND] = toInt(input.substr(pos2));
|
1694
|
+
getParsingFlags(config).bigHour = true;
|
1695
|
+
});
|
1696
|
+
addParseToken('Hmm', function (input, array, config) {
|
1697
|
+
var pos = input.length - 2;
|
1698
|
+
array[HOUR] = toInt(input.substr(0, pos));
|
1699
|
+
array[MINUTE] = toInt(input.substr(pos));
|
1700
|
+
});
|
1701
|
+
addParseToken('Hmmss', function (input, array, config) {
|
1702
|
+
var pos1 = input.length - 4;
|
1703
|
+
var pos2 = input.length - 2;
|
1704
|
+
array[HOUR] = toInt(input.substr(0, pos1));
|
1705
|
+
array[MINUTE] = toInt(input.substr(pos1, 2));
|
1706
|
+
array[SECOND] = toInt(input.substr(pos2));
|
1707
|
+
});
|
1708
|
+
|
1709
|
+
// LOCALES
|
1710
|
+
|
1711
|
+
function localeIsPM (input) {
|
1712
|
+
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
|
1713
|
+
// Using charAt should be more compatible.
|
1714
|
+
return ((input + '').toLowerCase().charAt(0) === 'p');
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
1718
|
+
function localeMeridiem (hours, minutes, isLower) {
|
1719
|
+
if (hours > 11) {
|
1720
|
+
return isLower ? 'pm' : 'PM';
|
1721
|
+
} else {
|
1722
|
+
return isLower ? 'am' : 'AM';
|
1723
|
+
}
|
1724
|
+
}
|
1725
|
+
|
1726
|
+
|
1727
|
+
// MOMENTS
|
1728
|
+
|
1729
|
+
// Setting the hour should keep the time, because the user explicitly
|
1730
|
+
// specified which hour he wants. So trying to maintain the same hour (in
|
1731
|
+
// a new timezone) makes sense. Adding/subtracting hours does not follow
|
1732
|
+
// this rule.
|
1733
|
+
var getSetHour = makeGetSet('Hours', true);
|
1734
|
+
|
1735
|
+
var baseConfig = {
|
1736
|
+
calendar: defaultCalendar,
|
1737
|
+
longDateFormat: defaultLongDateFormat,
|
1738
|
+
invalidDate: defaultInvalidDate,
|
1739
|
+
ordinal: defaultOrdinal,
|
1740
|
+
ordinalParse: defaultOrdinalParse,
|
1741
|
+
relativeTime: defaultRelativeTime,
|
1742
|
+
|
1743
|
+
months: defaultLocaleMonths,
|
1744
|
+
monthsShort: defaultLocaleMonthsShort,
|
1745
|
+
|
1746
|
+
week: defaultLocaleWeek,
|
1747
|
+
|
1748
|
+
weekdays: defaultLocaleWeekdays,
|
1749
|
+
weekdaysMin: defaultLocaleWeekdaysMin,
|
1750
|
+
weekdaysShort: defaultLocaleWeekdaysShort,
|
1751
|
+
|
1752
|
+
meridiemParse: defaultLocaleMeridiemParse
|
1753
|
+
};
|
1754
|
+
|
1755
|
+
// internal storage for locale config files
|
1756
|
+
var locales = {};
|
1757
|
+
var globalLocale;
|
1758
|
+
|
1759
|
+
function normalizeLocale(key) {
|
1760
|
+
return key ? key.toLowerCase().replace('_', '-') : key;
|
1761
|
+
}
|
1762
|
+
|
1763
|
+
// pick the locale from the array
|
1764
|
+
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
|
1765
|
+
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
|
1766
|
+
function chooseLocale(names) {
|
1767
|
+
var i = 0, j, next, locale, split;
|
1768
|
+
|
1769
|
+
while (i < names.length) {
|
1770
|
+
split = normalizeLocale(names[i]).split('-');
|
1771
|
+
j = split.length;
|
1772
|
+
next = normalizeLocale(names[i + 1]);
|
1773
|
+
next = next ? next.split('-') : null;
|
1774
|
+
while (j > 0) {
|
1775
|
+
locale = loadLocale(split.slice(0, j).join('-'));
|
1776
|
+
if (locale) {
|
1777
|
+
return locale;
|
1778
|
+
}
|
1779
|
+
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
1780
|
+
//the next array item is better than a shallower substring of this one
|
1781
|
+
break;
|
1782
|
+
}
|
1783
|
+
j--;
|
1784
|
+
}
|
1785
|
+
i++;
|
1786
|
+
}
|
1787
|
+
return null;
|
1788
|
+
}
|
1789
|
+
|
1790
|
+
function loadLocale(name) {
|
1791
|
+
var oldLocale = null;
|
1792
|
+
// TODO: Find a better way to register and load all the locales in Node
|
1793
|
+
if (!locales[name] && (typeof module !== 'undefined') &&
|
1794
|
+
module && module.exports) {
|
1795
|
+
try {
|
1796
|
+
oldLocale = globalLocale._abbr;
|
1797
|
+
require('./locale/' + name);
|
1798
|
+
// because defineLocale currently also sets the global locale, we
|
1799
|
+
// want to undo that for lazy loaded locales
|
1800
|
+
locale_locales__getSetGlobalLocale(oldLocale);
|
1801
|
+
} catch (e) { }
|
1802
|
+
}
|
1803
|
+
return locales[name];
|
1804
|
+
}
|
1805
|
+
|
1806
|
+
// This function will load locale and then set the global locale. If
|
1807
|
+
// no arguments are passed in, it will simply return the current global
|
1808
|
+
// locale key.
|
1809
|
+
function locale_locales__getSetGlobalLocale (key, values) {
|
1810
|
+
var data;
|
1811
|
+
if (key) {
|
1812
|
+
if (isUndefined(values)) {
|
1813
|
+
data = locale_locales__getLocale(key);
|
1814
|
+
}
|
1815
|
+
else {
|
1816
|
+
data = defineLocale(key, values);
|
1817
|
+
}
|
1818
|
+
|
1819
|
+
if (data) {
|
1820
|
+
// moment.duration._locale = moment._locale = data;
|
1821
|
+
globalLocale = data;
|
1822
|
+
}
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
return globalLocale._abbr;
|
1826
|
+
}
|
1827
|
+
|
1828
|
+
function defineLocale (name, config) {
|
1829
|
+
if (config !== null) {
|
1830
|
+
var parentConfig = baseConfig;
|
1831
|
+
config.abbr = name;
|
1832
|
+
if (locales[name] != null) {
|
1833
|
+
deprecateSimple('defineLocaleOverride',
|
1834
|
+
'use moment.updateLocale(localeName, config) to change ' +
|
1835
|
+
'an existing locale. moment.defineLocale(localeName, ' +
|
1836
|
+
'config) should only be used for creating a new locale ' +
|
1837
|
+
'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
1838
|
+
parentConfig = locales[name]._config;
|
1839
|
+
} else if (config.parentLocale != null) {
|
1840
|
+
if (locales[config.parentLocale] != null) {
|
1841
|
+
parentConfig = locales[config.parentLocale]._config;
|
1842
|
+
} else {
|
1843
|
+
// treat as if there is no base config
|
1844
|
+
deprecateSimple('parentLocaleUndefined',
|
1845
|
+
'specified parentLocale is not defined yet. See http://momentjs.com/guides/#/warnings/parent-locale/');
|
1846
|
+
}
|
1847
|
+
}
|
1848
|
+
locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
1849
|
+
|
1850
|
+
// backwards compat for now: also set the locale
|
1851
|
+
locale_locales__getSetGlobalLocale(name);
|
1852
|
+
|
1853
|
+
return locales[name];
|
1854
|
+
} else {
|
1855
|
+
// useful for testing
|
1856
|
+
delete locales[name];
|
1857
|
+
return null;
|
1858
|
+
}
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
function updateLocale(name, config) {
|
1862
|
+
if (config != null) {
|
1863
|
+
var locale, parentConfig = baseConfig;
|
1864
|
+
// MERGE
|
1865
|
+
if (locales[name] != null) {
|
1866
|
+
parentConfig = locales[name]._config;
|
1867
|
+
}
|
1868
|
+
config = mergeConfigs(parentConfig, config);
|
1869
|
+
locale = new Locale(config);
|
1870
|
+
locale.parentLocale = locales[name];
|
1871
|
+
locales[name] = locale;
|
1872
|
+
|
1873
|
+
// backwards compat for now: also set the locale
|
1874
|
+
locale_locales__getSetGlobalLocale(name);
|
1875
|
+
} else {
|
1876
|
+
// pass null for config to unupdate, useful for tests
|
1877
|
+
if (locales[name] != null) {
|
1878
|
+
if (locales[name].parentLocale != null) {
|
1879
|
+
locales[name] = locales[name].parentLocale;
|
1880
|
+
} else if (locales[name] != null) {
|
1881
|
+
delete locales[name];
|
1882
|
+
}
|
1883
|
+
}
|
1884
|
+
}
|
1885
|
+
return locales[name];
|
1886
|
+
}
|
1887
|
+
|
1888
|
+
// returns locale data
|
1889
|
+
function locale_locales__getLocale (key) {
|
1890
|
+
var locale;
|
1891
|
+
|
1892
|
+
if (key && key._locale && key._locale._abbr) {
|
1893
|
+
key = key._locale._abbr;
|
779
1894
|
}
|
780
1895
|
|
781
|
-
|
782
|
-
|
783
|
-
for (i = 0; i < 12; i++) {
|
784
|
-
// make the regex if we don't have it already
|
785
|
-
mom = create_utc__createUTC([2000, i]);
|
786
|
-
shortPieces.push(this.monthsShort(mom, ''));
|
787
|
-
longPieces.push(this.months(mom, ''));
|
788
|
-
mixedPieces.push(this.months(mom, ''));
|
789
|
-
mixedPieces.push(this.monthsShort(mom, ''));
|
1896
|
+
if (!key) {
|
1897
|
+
return globalLocale;
|
790
1898
|
}
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
mixedPieces[i] = regexEscape(mixedPieces[i]);
|
1899
|
+
|
1900
|
+
if (!isArray(key)) {
|
1901
|
+
//short-circuit everything else
|
1902
|
+
locale = loadLocale(key);
|
1903
|
+
if (locale) {
|
1904
|
+
return locale;
|
1905
|
+
}
|
1906
|
+
key = [key];
|
800
1907
|
}
|
801
1908
|
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
1909
|
+
return chooseLocale(key);
|
1910
|
+
}
|
1911
|
+
|
1912
|
+
function locale_locales__listLocales() {
|
1913
|
+
return keys(locales);
|
806
1914
|
}
|
807
1915
|
|
808
1916
|
function checkOverflow (m) {
|
@@ -835,36 +1943,6 @@
|
|
835
1943
|
return m;
|
836
1944
|
}
|
837
1945
|
|
838
|
-
function warn(msg) {
|
839
|
-
if (utils_hooks__hooks.suppressDeprecationWarnings === false &&
|
840
|
-
(typeof console !== 'undefined') && console.warn) {
|
841
|
-
console.warn('Deprecation warning: ' + msg);
|
842
|
-
}
|
843
|
-
}
|
844
|
-
|
845
|
-
function deprecate(msg, fn) {
|
846
|
-
var firstTime = true;
|
847
|
-
|
848
|
-
return extend(function () {
|
849
|
-
if (firstTime) {
|
850
|
-
warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
|
851
|
-
firstTime = false;
|
852
|
-
}
|
853
|
-
return fn.apply(this, arguments);
|
854
|
-
}, fn);
|
855
|
-
}
|
856
|
-
|
857
|
-
var deprecations = {};
|
858
|
-
|
859
|
-
function deprecateSimple(name, msg) {
|
860
|
-
if (!deprecations[name]) {
|
861
|
-
warn(msg);
|
862
|
-
deprecations[name] = true;
|
863
|
-
}
|
864
|
-
}
|
865
|
-
|
866
|
-
utils_hooks__hooks.suppressDeprecationWarnings = false;
|
867
|
-
|
868
1946
|
// iso 8601 regex
|
869
1947
|
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
|
870
1948
|
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/;
|
@@ -972,161 +2050,15 @@
|
|
972
2050
|
}
|
973
2051
|
|
974
2052
|
utils_hooks__hooks.createFromInputFallback = deprecate(
|
975
|
-
'moment construction falls back to js Date
|
976
|
-
'
|
977
|
-
'release. Please refer to ' +
|
978
|
-
'
|
2053
|
+
'value provided is not in a recognized ISO format. moment construction falls back to js Date(), ' +
|
2054
|
+
'which is not reliable across all browsers and versions. Non ISO date formats are ' +
|
2055
|
+
'discouraged and will be removed in an upcoming major release. Please refer to ' +
|
2056
|
+
'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
|
979
2057
|
function (config) {
|
980
2058
|
config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
981
2059
|
}
|
982
2060
|
);
|
983
2061
|
|
984
|
-
function createDate (y, m, d, h, M, s, ms) {
|
985
|
-
//can't just apply() to create a date:
|
986
|
-
//http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
|
987
|
-
var date = new Date(y, m, d, h, M, s, ms);
|
988
|
-
|
989
|
-
//the date constructor remaps years 0-99 to 1900-1999
|
990
|
-
if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
|
991
|
-
date.setFullYear(y);
|
992
|
-
}
|
993
|
-
return date;
|
994
|
-
}
|
995
|
-
|
996
|
-
function createUTCDate (y) {
|
997
|
-
var date = new Date(Date.UTC.apply(null, arguments));
|
998
|
-
|
999
|
-
//the Date.UTC function remaps years 0-99 to 1900-1999
|
1000
|
-
if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
|
1001
|
-
date.setUTCFullYear(y);
|
1002
|
-
}
|
1003
|
-
return date;
|
1004
|
-
}
|
1005
|
-
|
1006
|
-
// FORMATTING
|
1007
|
-
|
1008
|
-
addFormatToken('Y', 0, 0, function () {
|
1009
|
-
var y = this.year();
|
1010
|
-
return y <= 9999 ? '' + y : '+' + y;
|
1011
|
-
});
|
1012
|
-
|
1013
|
-
addFormatToken(0, ['YY', 2], 0, function () {
|
1014
|
-
return this.year() % 100;
|
1015
|
-
});
|
1016
|
-
|
1017
|
-
addFormatToken(0, ['YYYY', 4], 0, 'year');
|
1018
|
-
addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
1019
|
-
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
1020
|
-
|
1021
|
-
// ALIASES
|
1022
|
-
|
1023
|
-
addUnitAlias('year', 'y');
|
1024
|
-
|
1025
|
-
// PARSING
|
1026
|
-
|
1027
|
-
addRegexToken('Y', matchSigned);
|
1028
|
-
addRegexToken('YY', match1to2, match2);
|
1029
|
-
addRegexToken('YYYY', match1to4, match4);
|
1030
|
-
addRegexToken('YYYYY', match1to6, match6);
|
1031
|
-
addRegexToken('YYYYYY', match1to6, match6);
|
1032
|
-
|
1033
|
-
addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
1034
|
-
addParseToken('YYYY', function (input, array) {
|
1035
|
-
array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
|
1036
|
-
});
|
1037
|
-
addParseToken('YY', function (input, array) {
|
1038
|
-
array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
|
1039
|
-
});
|
1040
|
-
addParseToken('Y', function (input, array) {
|
1041
|
-
array[YEAR] = parseInt(input, 10);
|
1042
|
-
});
|
1043
|
-
|
1044
|
-
// HELPERS
|
1045
|
-
|
1046
|
-
function daysInYear(year) {
|
1047
|
-
return isLeapYear(year) ? 366 : 365;
|
1048
|
-
}
|
1049
|
-
|
1050
|
-
function isLeapYear(year) {
|
1051
|
-
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
// HOOKS
|
1055
|
-
|
1056
|
-
utils_hooks__hooks.parseTwoDigitYear = function (input) {
|
1057
|
-
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
1058
|
-
};
|
1059
|
-
|
1060
|
-
// MOMENTS
|
1061
|
-
|
1062
|
-
var getSetYear = makeGetSet('FullYear', false);
|
1063
|
-
|
1064
|
-
function getIsLeapYear () {
|
1065
|
-
return isLeapYear(this.year());
|
1066
|
-
}
|
1067
|
-
|
1068
|
-
// start-of-first-week - start-of-year
|
1069
|
-
function firstWeekOffset(year, dow, doy) {
|
1070
|
-
var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
|
1071
|
-
fwd = 7 + dow - doy,
|
1072
|
-
// first-week day local weekday -- which local weekday is fwd
|
1073
|
-
fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
1074
|
-
|
1075
|
-
return -fwdlw + fwd - 1;
|
1076
|
-
}
|
1077
|
-
|
1078
|
-
//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
|
1079
|
-
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
1080
|
-
var localWeekday = (7 + weekday - dow) % 7,
|
1081
|
-
weekOffset = firstWeekOffset(year, dow, doy),
|
1082
|
-
dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
1083
|
-
resYear, resDayOfYear;
|
1084
|
-
|
1085
|
-
if (dayOfYear <= 0) {
|
1086
|
-
resYear = year - 1;
|
1087
|
-
resDayOfYear = daysInYear(resYear) + dayOfYear;
|
1088
|
-
} else if (dayOfYear > daysInYear(year)) {
|
1089
|
-
resYear = year + 1;
|
1090
|
-
resDayOfYear = dayOfYear - daysInYear(year);
|
1091
|
-
} else {
|
1092
|
-
resYear = year;
|
1093
|
-
resDayOfYear = dayOfYear;
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
return {
|
1097
|
-
year: resYear,
|
1098
|
-
dayOfYear: resDayOfYear
|
1099
|
-
};
|
1100
|
-
}
|
1101
|
-
|
1102
|
-
function weekOfYear(mom, dow, doy) {
|
1103
|
-
var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
1104
|
-
week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
1105
|
-
resWeek, resYear;
|
1106
|
-
|
1107
|
-
if (week < 1) {
|
1108
|
-
resYear = mom.year() - 1;
|
1109
|
-
resWeek = week + weeksInYear(resYear, dow, doy);
|
1110
|
-
} else if (week > weeksInYear(mom.year(), dow, doy)) {
|
1111
|
-
resWeek = week - weeksInYear(mom.year(), dow, doy);
|
1112
|
-
resYear = mom.year() + 1;
|
1113
|
-
} else {
|
1114
|
-
resYear = mom.year();
|
1115
|
-
resWeek = week;
|
1116
|
-
}
|
1117
|
-
|
1118
|
-
return {
|
1119
|
-
week: resWeek,
|
1120
|
-
year: resYear
|
1121
|
-
};
|
1122
|
-
}
|
1123
|
-
|
1124
|
-
function weeksInYear(year, dow, doy) {
|
1125
|
-
var weekOffset = firstWeekOffset(year, dow, doy),
|
1126
|
-
weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
1127
|
-
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
1128
|
-
}
|
1129
|
-
|
1130
2062
|
// Pick the first defined of two or three arguments.
|
1131
2063
|
function defaults(a, b, c) {
|
1132
2064
|
if (a != null) {
|
@@ -1323,11 +2255,14 @@
|
|
1323
2255
|
}
|
1324
2256
|
|
1325
2257
|
// clear _12h flag if hour is <= 12
|
1326
|
-
if (
|
1327
|
-
|
1328
|
-
|
2258
|
+
if (config._a[HOUR] <= 12 &&
|
2259
|
+
getParsingFlags(config).bigHour === true &&
|
2260
|
+
config._a[HOUR] > 0) {
|
1329
2261
|
getParsingFlags(config).bigHour = undefined;
|
1330
2262
|
}
|
2263
|
+
|
2264
|
+
getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
2265
|
+
getParsingFlags(config).meridiem = config._meridiem;
|
1331
2266
|
// handle meridiem
|
1332
2267
|
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
1333
2268
|
|
@@ -1448,11 +2383,11 @@
|
|
1448
2383
|
return new Moment(checkOverflow(input));
|
1449
2384
|
} else if (isArray(format)) {
|
1450
2385
|
configFromStringAndArray(config);
|
1451
|
-
} else if (format) {
|
1452
|
-
configFromStringAndFormat(config);
|
1453
2386
|
} else if (isDate(input)) {
|
1454
2387
|
config._d = input;
|
1455
|
-
} else {
|
2388
|
+
} else if (format) {
|
2389
|
+
configFromStringAndFormat(config);
|
2390
|
+
} else {
|
1456
2391
|
configFromInput(config);
|
1457
2392
|
}
|
1458
2393
|
|
@@ -1468,7 +2403,7 @@
|
|
1468
2403
|
if (input === undefined) {
|
1469
2404
|
config._d = new Date(utils_hooks__hooks.now());
|
1470
2405
|
} else if (isDate(input)) {
|
1471
|
-
config._d = new Date(
|
2406
|
+
config._d = new Date(input.valueOf());
|
1472
2407
|
} else if (typeof input === 'string') {
|
1473
2408
|
configFromString(config);
|
1474
2409
|
} else if (isArray(input)) {
|
@@ -1493,6 +2428,11 @@
|
|
1493
2428
|
strict = locale;
|
1494
2429
|
locale = undefined;
|
1495
2430
|
}
|
2431
|
+
|
2432
|
+
if ((isObject(input) && isObjectEmpty(input)) ||
|
2433
|
+
(isArray(input) && input.length === 0)) {
|
2434
|
+
input = undefined;
|
2435
|
+
}
|
1496
2436
|
// object construction must be done this way.
|
1497
2437
|
// https://github.com/moment/moment/issues/1423
|
1498
2438
|
c._isAMomentObject = true;
|
@@ -1510,19 +2450,19 @@
|
|
1510
2450
|
}
|
1511
2451
|
|
1512
2452
|
var prototypeMin = deprecate(
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
2453
|
+
'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
|
2454
|
+
function () {
|
2455
|
+
var other = local__createLocal.apply(null, arguments);
|
2456
|
+
if (this.isValid() && other.isValid()) {
|
2457
|
+
return other < this ? this : other;
|
2458
|
+
} else {
|
2459
|
+
return valid__createInvalid();
|
2460
|
+
}
|
2461
|
+
}
|
2462
|
+
);
|
1523
2463
|
|
1524
2464
|
var prototypeMax = deprecate(
|
1525
|
-
'moment().max is deprecated, use moment.
|
2465
|
+
'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
|
1526
2466
|
function () {
|
1527
2467
|
var other = local__createLocal.apply(null, arguments);
|
1528
2468
|
if (this.isValid() && other.isValid()) {
|
@@ -1588,7 +2528,7 @@
|
|
1588
2528
|
this._milliseconds = +milliseconds +
|
1589
2529
|
seconds * 1e3 + // 1000
|
1590
2530
|
minutes * 6e4 + // 1000 * 60
|
1591
|
-
hours *
|
2531
|
+
hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
|
1592
2532
|
// Because of dateAddRemove treats 24 hours as different from a
|
1593
2533
|
// day when working around DST, we need to store them separately
|
1594
2534
|
this._days = +days +
|
@@ -1611,6 +2551,14 @@
|
|
1611
2551
|
return obj instanceof Duration;
|
1612
2552
|
}
|
1613
2553
|
|
2554
|
+
function absRound (number) {
|
2555
|
+
if (number < 0) {
|
2556
|
+
return Math.round(-1 * number) * -1;
|
2557
|
+
} else {
|
2558
|
+
return Math.round(number);
|
2559
|
+
}
|
2560
|
+
}
|
2561
|
+
|
1614
2562
|
// FORMATTING
|
1615
2563
|
|
1616
2564
|
function offset (token, separator) {
|
@@ -1658,9 +2606,9 @@
|
|
1658
2606
|
var res, diff;
|
1659
2607
|
if (model._isUTC) {
|
1660
2608
|
res = model.clone();
|
1661
|
-
diff = (isMoment(input) || isDate(input) ?
|
2609
|
+
diff = (isMoment(input) || isDate(input) ? input.valueOf() : local__createLocal(input).valueOf()) - res.valueOf();
|
1662
2610
|
// Use low-level api, because this fn is low-level api.
|
1663
|
-
res._d.setTime(
|
2611
|
+
res._d.setTime(res._d.valueOf() + diff);
|
1664
2612
|
utils_hooks__hooks.updateOffset(res, false);
|
1665
2613
|
return res;
|
1666
2614
|
} else {
|
@@ -1761,7 +2709,13 @@
|
|
1761
2709
|
if (this._tzm) {
|
1762
2710
|
this.utcOffset(this._tzm);
|
1763
2711
|
} else if (typeof this._i === 'string') {
|
1764
|
-
|
2712
|
+
var tZone = offsetFromString(matchOffset, this._i);
|
2713
|
+
|
2714
|
+
if (tZone === 0) {
|
2715
|
+
this.utcOffset(0, true);
|
2716
|
+
} else {
|
2717
|
+
this.utcOffset(offsetFromString(matchOffset, this._i));
|
2718
|
+
}
|
1765
2719
|
}
|
1766
2720
|
return this;
|
1767
2721
|
}
|
@@ -1816,11 +2770,12 @@
|
|
1816
2770
|
}
|
1817
2771
|
|
1818
2772
|
// ASP.NET json date format regex
|
1819
|
-
var aspNetRegex =
|
2773
|
+
var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
1820
2774
|
|
1821
2775
|
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
|
1822
2776
|
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
|
1823
|
-
|
2777
|
+
// and further modified to allow for strings containing both week and day
|
2778
|
+
var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
|
1824
2779
|
|
1825
2780
|
function create__createDuration (input, key) {
|
1826
2781
|
var duration = input,
|
@@ -1847,22 +2802,22 @@
|
|
1847
2802
|
sign = (match[1] === '-') ? -1 : 1;
|
1848
2803
|
duration = {
|
1849
2804
|
y : 0,
|
1850
|
-
d : toInt(match[DATE])
|
1851
|
-
h : toInt(match[HOUR])
|
1852
|
-
m : toInt(match[MINUTE])
|
1853
|
-
s : toInt(match[SECOND])
|
1854
|
-
ms : toInt(match[MILLISECOND]) * sign
|
2805
|
+
d : toInt(match[DATE]) * sign,
|
2806
|
+
h : toInt(match[HOUR]) * sign,
|
2807
|
+
m : toInt(match[MINUTE]) * sign,
|
2808
|
+
s : toInt(match[SECOND]) * sign,
|
2809
|
+
ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
|
1855
2810
|
};
|
1856
2811
|
} else if (!!(match = isoRegex.exec(input))) {
|
1857
2812
|
sign = (match[1] === '-') ? -1 : 1;
|
1858
2813
|
duration = {
|
1859
2814
|
y : parseIso(match[2], sign),
|
1860
2815
|
M : parseIso(match[3], sign),
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
2816
|
+
w : parseIso(match[4], sign),
|
2817
|
+
d : parseIso(match[5], sign),
|
2818
|
+
h : parseIso(match[6], sign),
|
2819
|
+
m : parseIso(match[7], sign),
|
2820
|
+
s : parseIso(match[8], sign)
|
1866
2821
|
};
|
1867
2822
|
} else if (duration == null) {// checks for null or undefined
|
1868
2823
|
duration = {};
|
@@ -1932,7 +2887,8 @@
|
|
1932
2887
|
var dur, tmp;
|
1933
2888
|
//invert the arguments, but complain about it
|
1934
2889
|
if (period !== null && !isNaN(+period)) {
|
1935
|
-
deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).'
|
2890
|
+
deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
|
2891
|
+
'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
1936
2892
|
tmp = val; val = period; period = tmp;
|
1937
2893
|
}
|
1938
2894
|
|
@@ -1945,8 +2901,8 @@
|
|
1945
2901
|
|
1946
2902
|
function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
|
1947
2903
|
var milliseconds = duration._milliseconds,
|
1948
|
-
days = duration._days,
|
1949
|
-
months = duration._months;
|
2904
|
+
days = absRound(duration._days),
|
2905
|
+
months = absRound(duration._months);
|
1950
2906
|
|
1951
2907
|
if (!mom.isValid()) {
|
1952
2908
|
// No op
|
@@ -1956,7 +2912,7 @@
|
|
1956
2912
|
updateOffset = updateOffset == null ? true : updateOffset;
|
1957
2913
|
|
1958
2914
|
if (milliseconds) {
|
1959
|
-
mom._d.setTime(
|
2915
|
+
mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
1960
2916
|
}
|
1961
2917
|
if (days) {
|
1962
2918
|
get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
|
@@ -1972,20 +2928,24 @@
|
|
1972
2928
|
var add_subtract__add = createAdder(1, 'add');
|
1973
2929
|
var add_subtract__subtract = createAdder(-1, 'subtract');
|
1974
2930
|
|
1975
|
-
function
|
1976
|
-
|
1977
|
-
|
1978
|
-
var now = time || local__createLocal(),
|
1979
|
-
sod = cloneWithOffset(now, this).startOf('day'),
|
1980
|
-
diff = this.diff(sod, 'days', true),
|
1981
|
-
format = diff < -6 ? 'sameElse' :
|
2931
|
+
function getCalendarFormat(myMoment, now) {
|
2932
|
+
var diff = myMoment.diff(now, 'days', true);
|
2933
|
+
return diff < -6 ? 'sameElse' :
|
1982
2934
|
diff < -1 ? 'lastWeek' :
|
1983
2935
|
diff < 0 ? 'lastDay' :
|
1984
2936
|
diff < 1 ? 'sameDay' :
|
1985
2937
|
diff < 2 ? 'nextDay' :
|
1986
2938
|
diff < 7 ? 'nextWeek' : 'sameElse';
|
2939
|
+
}
|
2940
|
+
|
2941
|
+
function moment_calendar__calendar (time, formats) {
|
2942
|
+
// We want to compare the start of today, vs this.
|
2943
|
+
// Getting start-of-today depends on whether we're local/utc/offset or not.
|
2944
|
+
var now = time || local__createLocal(),
|
2945
|
+
sod = cloneWithOffset(now, this).startOf('day'),
|
2946
|
+
format = utils_hooks__hooks.calendarFormat(this, sod) || 'sameElse';
|
1987
2947
|
|
1988
|
-
var output = formats && (isFunction(formats[format]) ? formats[format]() : formats[format]);
|
2948
|
+
var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
1989
2949
|
|
1990
2950
|
return this.format(output || this.localeData().calendar(format, this, local__createLocal(now)));
|
1991
2951
|
}
|
@@ -2001,9 +2961,9 @@
|
|
2001
2961
|
}
|
2002
2962
|
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
|
2003
2963
|
if (units === 'millisecond') {
|
2004
|
-
return
|
2964
|
+
return this.valueOf() > localInput.valueOf();
|
2005
2965
|
} else {
|
2006
|
-
return
|
2966
|
+
return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
2007
2967
|
}
|
2008
2968
|
}
|
2009
2969
|
|
@@ -2014,14 +2974,16 @@
|
|
2014
2974
|
}
|
2015
2975
|
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
|
2016
2976
|
if (units === 'millisecond') {
|
2017
|
-
return
|
2977
|
+
return this.valueOf() < localInput.valueOf();
|
2018
2978
|
} else {
|
2019
|
-
return
|
2979
|
+
return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
2020
2980
|
}
|
2021
2981
|
}
|
2022
2982
|
|
2023
|
-
function isBetween (from, to, units) {
|
2024
|
-
|
2983
|
+
function isBetween (from, to, units, inclusivity) {
|
2984
|
+
inclusivity = inclusivity || '()';
|
2985
|
+
return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
|
2986
|
+
(inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
|
2025
2987
|
}
|
2026
2988
|
|
2027
2989
|
function isSame (input, units) {
|
@@ -2032,10 +2994,10 @@
|
|
2032
2994
|
}
|
2033
2995
|
units = normalizeUnits(units || 'millisecond');
|
2034
2996
|
if (units === 'millisecond') {
|
2035
|
-
return
|
2997
|
+
return this.valueOf() === localInput.valueOf();
|
2036
2998
|
} else {
|
2037
|
-
inputMs =
|
2038
|
-
return
|
2999
|
+
inputMs = localInput.valueOf();
|
3000
|
+
return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
2039
3001
|
}
|
2040
3002
|
}
|
2041
3003
|
|
@@ -2102,10 +3064,12 @@
|
|
2102
3064
|
adjust = (b - anchor) / (anchor2 - anchor);
|
2103
3065
|
}
|
2104
3066
|
|
2105
|
-
return
|
3067
|
+
//check for negative zero, return zero if negative zero
|
3068
|
+
return -(wholeMonthDiff + adjust) || 0;
|
2106
3069
|
}
|
2107
3070
|
|
2108
3071
|
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
3072
|
+
utils_hooks__hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
2109
3073
|
|
2110
3074
|
function toString () {
|
2111
3075
|
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
@@ -2126,7 +3090,10 @@
|
|
2126
3090
|
}
|
2127
3091
|
|
2128
3092
|
function format (inputString) {
|
2129
|
-
|
3093
|
+
if (!inputString) {
|
3094
|
+
inputString = this.isUtc() ? utils_hooks__hooks.defaultFormatUtc : utils_hooks__hooks.defaultFormat;
|
3095
|
+
}
|
3096
|
+
var output = formatMoment(this, inputString);
|
2130
3097
|
return this.localeData().postformat(output);
|
2131
3098
|
}
|
2132
3099
|
|
@@ -2195,26 +3162,27 @@
|
|
2195
3162
|
// the following switch intentionally omits break keywords
|
2196
3163
|
// to utilize falling through the cases.
|
2197
3164
|
switch (units) {
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
3165
|
+
case 'year':
|
3166
|
+
this.month(0);
|
3167
|
+
/* falls through */
|
3168
|
+
case 'quarter':
|
3169
|
+
case 'month':
|
3170
|
+
this.date(1);
|
3171
|
+
/* falls through */
|
3172
|
+
case 'week':
|
3173
|
+
case 'isoWeek':
|
3174
|
+
case 'day':
|
3175
|
+
case 'date':
|
3176
|
+
this.hours(0);
|
3177
|
+
/* falls through */
|
3178
|
+
case 'hour':
|
3179
|
+
this.minutes(0);
|
3180
|
+
/* falls through */
|
3181
|
+
case 'minute':
|
3182
|
+
this.seconds(0);
|
3183
|
+
/* falls through */
|
3184
|
+
case 'second':
|
3185
|
+
this.milliseconds(0);
|
2218
3186
|
}
|
2219
3187
|
|
2220
3188
|
// weeks are a special case
|
@@ -2238,19 +3206,25 @@
|
|
2238
3206
|
if (units === undefined || units === 'millisecond') {
|
2239
3207
|
return this;
|
2240
3208
|
}
|
3209
|
+
|
3210
|
+
// 'date' is an alias for 'day', so it should be considered as such.
|
3211
|
+
if (units === 'date') {
|
3212
|
+
units = 'day';
|
3213
|
+
}
|
3214
|
+
|
2241
3215
|
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
|
2242
3216
|
}
|
2243
3217
|
|
2244
3218
|
function to_type__valueOf () {
|
2245
|
-
return
|
3219
|
+
return this._d.valueOf() - ((this._offset || 0) * 60000);
|
2246
3220
|
}
|
2247
3221
|
|
2248
3222
|
function unix () {
|
2249
|
-
return Math.floor(
|
3223
|
+
return Math.floor(this.valueOf() / 1000);
|
2250
3224
|
}
|
2251
3225
|
|
2252
3226
|
function toDate () {
|
2253
|
-
return
|
3227
|
+
return new Date(this.valueOf());
|
2254
3228
|
}
|
2255
3229
|
|
2256
3230
|
function toArray () {
|
@@ -2272,8 +3246,8 @@
|
|
2272
3246
|
}
|
2273
3247
|
|
2274
3248
|
function toJSON () {
|
2275
|
-
//
|
2276
|
-
return this.isValid() ? this.toISOString() :
|
3249
|
+
// new Date(NaN).toJSON() === null
|
3250
|
+
return this.isValid() ? this.toISOString() : null;
|
2277
3251
|
}
|
2278
3252
|
|
2279
3253
|
function moment_valid__isValid () {
|
@@ -2322,6 +3296,12 @@
|
|
2322
3296
|
addUnitAlias('weekYear', 'gg');
|
2323
3297
|
addUnitAlias('isoWeekYear', 'GG');
|
2324
3298
|
|
3299
|
+
// PRIORITY
|
3300
|
+
|
3301
|
+
addUnitPriority('weekYear', 1);
|
3302
|
+
addUnitPriority('isoWeekYear', 1);
|
3303
|
+
|
3304
|
+
|
2325
3305
|
// PARSING
|
2326
3306
|
|
2327
3307
|
addRegexToken('G', matchSigned);
|
@@ -2383,7 +3363,6 @@
|
|
2383
3363
|
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
2384
3364
|
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
2385
3365
|
|
2386
|
-
// console.log("got", weekYear, week, weekday, "set", date.toISOString());
|
2387
3366
|
this.year(date.getUTCFullYear());
|
2388
3367
|
this.month(date.getUTCMonth());
|
2389
3368
|
this.date(date.getUTCDate());
|
@@ -2398,6 +3377,10 @@
|
|
2398
3377
|
|
2399
3378
|
addUnitAlias('quarter', 'Q');
|
2400
3379
|
|
3380
|
+
// PRIORITY
|
3381
|
+
|
3382
|
+
addUnitPriority('quarter', 7);
|
3383
|
+
|
2401
3384
|
// PARSING
|
2402
3385
|
|
2403
3386
|
addRegexToken('Q', match1);
|
@@ -2407,387 +3390,65 @@
|
|
2407
3390
|
|
2408
3391
|
// MOMENTS
|
2409
3392
|
|
2410
|
-
function getSetQuarter (input) {
|
2411
|
-
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
2412
|
-
}
|
2413
|
-
|
2414
|
-
// FORMATTING
|
2415
|
-
|
2416
|
-
addFormatToken('w', ['ww', 2], 'wo', 'week');
|
2417
|
-
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
2418
|
-
|
2419
|
-
// ALIASES
|
2420
|
-
|
2421
|
-
addUnitAlias('week', 'w');
|
2422
|
-
addUnitAlias('isoWeek', 'W');
|
2423
|
-
|
2424
|
-
// PARSING
|
2425
|
-
|
2426
|
-
addRegexToken('w', match1to2);
|
2427
|
-
addRegexToken('ww', match1to2, match2);
|
2428
|
-
addRegexToken('W', match1to2);
|
2429
|
-
addRegexToken('WW', match1to2, match2);
|
2430
|
-
|
2431
|
-
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
2432
|
-
week[token.substr(0, 1)] = toInt(input);
|
2433
|
-
});
|
2434
|
-
|
2435
|
-
// HELPERS
|
2436
|
-
|
2437
|
-
// LOCALES
|
2438
|
-
|
2439
|
-
function localeWeek (mom) {
|
2440
|
-
return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
2441
|
-
}
|
2442
|
-
|
2443
|
-
var defaultLocaleWeek = {
|
2444
|
-
dow : 0, // Sunday is the first day of the week.
|
2445
|
-
doy : 6 // The week that contains Jan 1st is the first week of the year.
|
2446
|
-
};
|
2447
|
-
|
2448
|
-
function localeFirstDayOfWeek () {
|
2449
|
-
return this._week.dow;
|
2450
|
-
}
|
2451
|
-
|
2452
|
-
function localeFirstDayOfYear () {
|
2453
|
-
return this._week.doy;
|
2454
|
-
}
|
2455
|
-
|
2456
|
-
// MOMENTS
|
2457
|
-
|
2458
|
-
function getSetWeek (input) {
|
2459
|
-
var week = this.localeData().week(this);
|
2460
|
-
return input == null ? week : this.add((input - week) * 7, 'd');
|
2461
|
-
}
|
2462
|
-
|
2463
|
-
function getSetISOWeek (input) {
|
2464
|
-
var week = weekOfYear(this, 1, 4).week;
|
2465
|
-
return input == null ? week : this.add((input - week) * 7, 'd');
|
2466
|
-
}
|
2467
|
-
|
2468
|
-
// FORMATTING
|
2469
|
-
|
2470
|
-
addFormatToken('D', ['DD', 2], 'Do', 'date');
|
2471
|
-
|
2472
|
-
// ALIASES
|
2473
|
-
|
2474
|
-
addUnitAlias('date', 'D');
|
2475
|
-
|
2476
|
-
// PARSING
|
2477
|
-
|
2478
|
-
addRegexToken('D', match1to2);
|
2479
|
-
addRegexToken('DD', match1to2, match2);
|
2480
|
-
addRegexToken('Do', function (isStrict, locale) {
|
2481
|
-
return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
|
2482
|
-
});
|
2483
|
-
|
2484
|
-
addParseToken(['D', 'DD'], DATE);
|
2485
|
-
addParseToken('Do', function (input, array) {
|
2486
|
-
array[DATE] = toInt(input.match(match1to2)[0], 10);
|
2487
|
-
});
|
2488
|
-
|
2489
|
-
// MOMENTS
|
2490
|
-
|
2491
|
-
var getSetDayOfMonth = makeGetSet('Date', true);
|
2492
|
-
|
2493
|
-
// FORMATTING
|
2494
|
-
|
2495
|
-
addFormatToken('d', 0, 'do', 'day');
|
2496
|
-
|
2497
|
-
addFormatToken('dd', 0, 0, function (format) {
|
2498
|
-
return this.localeData().weekdaysMin(this, format);
|
2499
|
-
});
|
2500
|
-
|
2501
|
-
addFormatToken('ddd', 0, 0, function (format) {
|
2502
|
-
return this.localeData().weekdaysShort(this, format);
|
2503
|
-
});
|
2504
|
-
|
2505
|
-
addFormatToken('dddd', 0, 0, function (format) {
|
2506
|
-
return this.localeData().weekdays(this, format);
|
2507
|
-
});
|
2508
|
-
|
2509
|
-
addFormatToken('e', 0, 0, 'weekday');
|
2510
|
-
addFormatToken('E', 0, 0, 'isoWeekday');
|
2511
|
-
|
2512
|
-
// ALIASES
|
2513
|
-
|
2514
|
-
addUnitAlias('day', 'd');
|
2515
|
-
addUnitAlias('weekday', 'e');
|
2516
|
-
addUnitAlias('isoWeekday', 'E');
|
2517
|
-
|
2518
|
-
// PARSING
|
2519
|
-
|
2520
|
-
addRegexToken('d', match1to2);
|
2521
|
-
addRegexToken('e', match1to2);
|
2522
|
-
addRegexToken('E', match1to2);
|
2523
|
-
addRegexToken('dd', matchWord);
|
2524
|
-
addRegexToken('ddd', matchWord);
|
2525
|
-
addRegexToken('dddd', matchWord);
|
2526
|
-
|
2527
|
-
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
2528
|
-
var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
2529
|
-
// if we didn't get a weekday name, mark the date as invalid
|
2530
|
-
if (weekday != null) {
|
2531
|
-
week.d = weekday;
|
2532
|
-
} else {
|
2533
|
-
getParsingFlags(config).invalidWeekday = input;
|
2534
|
-
}
|
2535
|
-
});
|
2536
|
-
|
2537
|
-
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
2538
|
-
week[token] = toInt(input);
|
2539
|
-
});
|
2540
|
-
|
2541
|
-
// HELPERS
|
2542
|
-
|
2543
|
-
function parseWeekday(input, locale) {
|
2544
|
-
if (typeof input !== 'string') {
|
2545
|
-
return input;
|
2546
|
-
}
|
2547
|
-
|
2548
|
-
if (!isNaN(input)) {
|
2549
|
-
return parseInt(input, 10);
|
2550
|
-
}
|
2551
|
-
|
2552
|
-
input = locale.weekdaysParse(input);
|
2553
|
-
if (typeof input === 'number') {
|
2554
|
-
return input;
|
2555
|
-
}
|
2556
|
-
|
2557
|
-
return null;
|
2558
|
-
}
|
2559
|
-
|
2560
|
-
// LOCALES
|
2561
|
-
|
2562
|
-
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
2563
|
-
function localeWeekdays (m, format) {
|
2564
|
-
return isArray(this._weekdays) ? this._weekdays[m.day()] :
|
2565
|
-
this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
|
2566
|
-
}
|
2567
|
-
|
2568
|
-
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
2569
|
-
function localeWeekdaysShort (m) {
|
2570
|
-
return this._weekdaysShort[m.day()];
|
2571
|
-
}
|
2572
|
-
|
2573
|
-
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
2574
|
-
function localeWeekdaysMin (m) {
|
2575
|
-
return this._weekdaysMin[m.day()];
|
2576
|
-
}
|
2577
|
-
|
2578
|
-
function localeWeekdaysParse (weekdayName, format, strict) {
|
2579
|
-
var i, mom, regex;
|
2580
|
-
|
2581
|
-
if (!this._weekdaysParse) {
|
2582
|
-
this._weekdaysParse = [];
|
2583
|
-
this._minWeekdaysParse = [];
|
2584
|
-
this._shortWeekdaysParse = [];
|
2585
|
-
this._fullWeekdaysParse = [];
|
2586
|
-
}
|
2587
|
-
|
2588
|
-
for (i = 0; i < 7; i++) {
|
2589
|
-
// make the regex if we don't have it already
|
2590
|
-
|
2591
|
-
mom = local__createLocal([2000, 1]).day(i);
|
2592
|
-
if (strict && !this._fullWeekdaysParse[i]) {
|
2593
|
-
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
|
2594
|
-
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
|
2595
|
-
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
|
2596
|
-
}
|
2597
|
-
if (!this._weekdaysParse[i]) {
|
2598
|
-
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
2599
|
-
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
2600
|
-
}
|
2601
|
-
// test the regex
|
2602
|
-
if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
2603
|
-
return i;
|
2604
|
-
} else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
2605
|
-
return i;
|
2606
|
-
} else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
2607
|
-
return i;
|
2608
|
-
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
2609
|
-
return i;
|
2610
|
-
}
|
2611
|
-
}
|
2612
|
-
}
|
2613
|
-
|
2614
|
-
// MOMENTS
|
2615
|
-
|
2616
|
-
function getSetDayOfWeek (input) {
|
2617
|
-
if (!this.isValid()) {
|
2618
|
-
return input != null ? this : NaN;
|
2619
|
-
}
|
2620
|
-
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
2621
|
-
if (input != null) {
|
2622
|
-
input = parseWeekday(input, this.localeData());
|
2623
|
-
return this.add(input - day, 'd');
|
2624
|
-
} else {
|
2625
|
-
return day;
|
2626
|
-
}
|
2627
|
-
}
|
2628
|
-
|
2629
|
-
function getSetLocaleDayOfWeek (input) {
|
2630
|
-
if (!this.isValid()) {
|
2631
|
-
return input != null ? this : NaN;
|
2632
|
-
}
|
2633
|
-
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
2634
|
-
return input == null ? weekday : this.add(input - weekday, 'd');
|
2635
|
-
}
|
2636
|
-
|
2637
|
-
function getSetISODayOfWeek (input) {
|
2638
|
-
if (!this.isValid()) {
|
2639
|
-
return input != null ? this : NaN;
|
2640
|
-
}
|
2641
|
-
// behaves the same as moment#day except
|
2642
|
-
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
|
2643
|
-
// as a setter, sunday should belong to the previous week.
|
2644
|
-
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
|
2645
|
-
}
|
2646
|
-
|
2647
|
-
// FORMATTING
|
2648
|
-
|
2649
|
-
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
2650
|
-
|
2651
|
-
// ALIASES
|
2652
|
-
|
2653
|
-
addUnitAlias('dayOfYear', 'DDD');
|
2654
|
-
|
2655
|
-
// PARSING
|
2656
|
-
|
2657
|
-
addRegexToken('DDD', match1to3);
|
2658
|
-
addRegexToken('DDDD', match3);
|
2659
|
-
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
2660
|
-
config._dayOfYear = toInt(input);
|
2661
|
-
});
|
2662
|
-
|
2663
|
-
// HELPERS
|
2664
|
-
|
2665
|
-
// MOMENTS
|
2666
|
-
|
2667
|
-
function getSetDayOfYear (input) {
|
2668
|
-
var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
2669
|
-
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
|
3393
|
+
function getSetQuarter (input) {
|
3394
|
+
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
2670
3395
|
}
|
2671
3396
|
|
2672
3397
|
// FORMATTING
|
2673
3398
|
|
2674
|
-
|
2675
|
-
return this.hours() % 12 || 12;
|
2676
|
-
}
|
3399
|
+
addFormatToken('D', ['DD', 2], 'Do', 'date');
|
2677
3400
|
|
2678
|
-
|
2679
|
-
addFormatToken('h', ['hh', 2], 0, hFormat);
|
3401
|
+
// ALIASES
|
2680
3402
|
|
2681
|
-
|
2682
|
-
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
2683
|
-
});
|
3403
|
+
addUnitAlias('date', 'D');
|
2684
3404
|
|
2685
|
-
|
2686
|
-
|
2687
|
-
zeroFill(this.seconds(), 2);
|
2688
|
-
});
|
3405
|
+
// PRIOROITY
|
3406
|
+
addUnitPriority('date', 9);
|
2689
3407
|
|
2690
|
-
|
2691
|
-
|
3408
|
+
// PARSING
|
3409
|
+
|
3410
|
+
addRegexToken('D', match1to2);
|
3411
|
+
addRegexToken('DD', match1to2, match2);
|
3412
|
+
addRegexToken('Do', function (isStrict, locale) {
|
3413
|
+
return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
|
2692
3414
|
});
|
2693
3415
|
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
3416
|
+
addParseToken(['D', 'DD'], DATE);
|
3417
|
+
addParseToken('Do', function (input, array) {
|
3418
|
+
array[DATE] = toInt(input.match(match1to2)[0], 10);
|
2697
3419
|
});
|
2698
3420
|
|
2699
|
-
|
2700
|
-
addFormatToken(token, 0, 0, function () {
|
2701
|
-
return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
2702
|
-
});
|
2703
|
-
}
|
3421
|
+
// MOMENTS
|
2704
3422
|
|
2705
|
-
|
2706
|
-
meridiem('A', false);
|
3423
|
+
var getSetDayOfMonth = makeGetSet('Date', true);
|
2707
3424
|
|
2708
|
-
//
|
3425
|
+
// FORMATTING
|
2709
3426
|
|
2710
|
-
|
3427
|
+
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
2711
3428
|
|
2712
|
-
//
|
3429
|
+
// ALIASES
|
2713
3430
|
|
2714
|
-
|
2715
|
-
return locale._meridiemParse;
|
2716
|
-
}
|
3431
|
+
addUnitAlias('dayOfYear', 'DDD');
|
2717
3432
|
|
2718
|
-
|
2719
|
-
|
2720
|
-
addRegexToken('H', match1to2);
|
2721
|
-
addRegexToken('h', match1to2);
|
2722
|
-
addRegexToken('HH', match1to2, match2);
|
2723
|
-
addRegexToken('hh', match1to2, match2);
|
3433
|
+
// PRIORITY
|
3434
|
+
addUnitPriority('dayOfYear', 4);
|
2724
3435
|
|
2725
|
-
|
2726
|
-
addRegexToken('hmmss', match5to6);
|
2727
|
-
addRegexToken('Hmm', match3to4);
|
2728
|
-
addRegexToken('Hmmss', match5to6);
|
3436
|
+
// PARSING
|
2729
3437
|
|
2730
|
-
|
2731
|
-
|
2732
|
-
|
2733
|
-
config.
|
2734
|
-
});
|
2735
|
-
addParseToken(['h', 'hh'], function (input, array, config) {
|
2736
|
-
array[HOUR] = toInt(input);
|
2737
|
-
getParsingFlags(config).bigHour = true;
|
2738
|
-
});
|
2739
|
-
addParseToken('hmm', function (input, array, config) {
|
2740
|
-
var pos = input.length - 2;
|
2741
|
-
array[HOUR] = toInt(input.substr(0, pos));
|
2742
|
-
array[MINUTE] = toInt(input.substr(pos));
|
2743
|
-
getParsingFlags(config).bigHour = true;
|
2744
|
-
});
|
2745
|
-
addParseToken('hmmss', function (input, array, config) {
|
2746
|
-
var pos1 = input.length - 4;
|
2747
|
-
var pos2 = input.length - 2;
|
2748
|
-
array[HOUR] = toInt(input.substr(0, pos1));
|
2749
|
-
array[MINUTE] = toInt(input.substr(pos1, 2));
|
2750
|
-
array[SECOND] = toInt(input.substr(pos2));
|
2751
|
-
getParsingFlags(config).bigHour = true;
|
2752
|
-
});
|
2753
|
-
addParseToken('Hmm', function (input, array, config) {
|
2754
|
-
var pos = input.length - 2;
|
2755
|
-
array[HOUR] = toInt(input.substr(0, pos));
|
2756
|
-
array[MINUTE] = toInt(input.substr(pos));
|
2757
|
-
});
|
2758
|
-
addParseToken('Hmmss', function (input, array, config) {
|
2759
|
-
var pos1 = input.length - 4;
|
2760
|
-
var pos2 = input.length - 2;
|
2761
|
-
array[HOUR] = toInt(input.substr(0, pos1));
|
2762
|
-
array[MINUTE] = toInt(input.substr(pos1, 2));
|
2763
|
-
array[SECOND] = toInt(input.substr(pos2));
|
3438
|
+
addRegexToken('DDD', match1to3);
|
3439
|
+
addRegexToken('DDDD', match3);
|
3440
|
+
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
3441
|
+
config._dayOfYear = toInt(input);
|
2764
3442
|
});
|
2765
3443
|
|
2766
|
-
//
|
2767
|
-
|
2768
|
-
function localeIsPM (input) {
|
2769
|
-
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
|
2770
|
-
// Using charAt should be more compatible.
|
2771
|
-
return ((input + '').toLowerCase().charAt(0) === 'p');
|
2772
|
-
}
|
2773
|
-
|
2774
|
-
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
2775
|
-
function localeMeridiem (hours, minutes, isLower) {
|
2776
|
-
if (hours > 11) {
|
2777
|
-
return isLower ? 'pm' : 'PM';
|
2778
|
-
} else {
|
2779
|
-
return isLower ? 'am' : 'AM';
|
2780
|
-
}
|
2781
|
-
}
|
2782
|
-
|
3444
|
+
// HELPERS
|
2783
3445
|
|
2784
3446
|
// MOMENTS
|
2785
3447
|
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
var getSetHour = makeGetSet('Hours', true);
|
3448
|
+
function getSetDayOfYear (input) {
|
3449
|
+
var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
3450
|
+
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
|
3451
|
+
}
|
2791
3452
|
|
2792
3453
|
// FORMATTING
|
2793
3454
|
|
@@ -2797,6 +3458,10 @@
|
|
2797
3458
|
|
2798
3459
|
addUnitAlias('minute', 'm');
|
2799
3460
|
|
3461
|
+
// PRIORITY
|
3462
|
+
|
3463
|
+
addUnitPriority('minute', 14);
|
3464
|
+
|
2800
3465
|
// PARSING
|
2801
3466
|
|
2802
3467
|
addRegexToken('m', match1to2);
|
@@ -2815,6 +3480,10 @@
|
|
2815
3480
|
|
2816
3481
|
addUnitAlias('second', 's');
|
2817
3482
|
|
3483
|
+
// PRIORITY
|
3484
|
+
|
3485
|
+
addUnitPriority('second', 15);
|
3486
|
+
|
2818
3487
|
// PARSING
|
2819
3488
|
|
2820
3489
|
addRegexToken('s', match1to2);
|
@@ -2860,6 +3529,10 @@
|
|
2860
3529
|
|
2861
3530
|
addUnitAlias('millisecond', 'ms');
|
2862
3531
|
|
3532
|
+
// PRIORITY
|
3533
|
+
|
3534
|
+
addUnitPriority('millisecond', 16);
|
3535
|
+
|
2863
3536
|
// PARSING
|
2864
3537
|
|
2865
3538
|
addRegexToken('S', match1to3, match1);
|
@@ -2909,7 +3582,7 @@
|
|
2909
3582
|
momentPrototype__proto.fromNow = fromNow;
|
2910
3583
|
momentPrototype__proto.to = to;
|
2911
3584
|
momentPrototype__proto.toNow = toNow;
|
2912
|
-
momentPrototype__proto.get =
|
3585
|
+
momentPrototype__proto.get = stringGet;
|
2913
3586
|
momentPrototype__proto.invalidAt = invalidAt;
|
2914
3587
|
momentPrototype__proto.isAfter = isAfter;
|
2915
3588
|
momentPrototype__proto.isBefore = isBefore;
|
@@ -2924,7 +3597,7 @@
|
|
2924
3597
|
momentPrototype__proto.max = prototypeMax;
|
2925
3598
|
momentPrototype__proto.min = prototypeMin;
|
2926
3599
|
momentPrototype__proto.parsingFlags = parsingFlags;
|
2927
|
-
momentPrototype__proto.set =
|
3600
|
+
momentPrototype__proto.set = stringSet;
|
2928
3601
|
momentPrototype__proto.startOf = startOf;
|
2929
3602
|
momentPrototype__proto.subtract = add_subtract__subtract;
|
2930
3603
|
momentPrototype__proto.toArray = toArray;
|
@@ -2984,7 +3657,6 @@
|
|
2984
3657
|
momentPrototype__proto.parseZone = setOffsetToParsedOffset;
|
2985
3658
|
momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
2986
3659
|
momentPrototype__proto.isDST = isDaylightSavingTime;
|
2987
|
-
momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
|
2988
3660
|
momentPrototype__proto.isLocal = isLocal;
|
2989
3661
|
momentPrototype__proto.isUtcOffset = isUtcOffset;
|
2990
3662
|
momentPrototype__proto.isUtc = isUtc;
|
@@ -2998,7 +3670,8 @@
|
|
2998
3670
|
momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
2999
3671
|
momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
3000
3672
|
momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
3001
|
-
momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead.
|
3673
|
+
momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
3674
|
+
momentPrototype__proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
3002
3675
|
|
3003
3676
|
var momentPrototype = momentPrototype__proto;
|
3004
3677
|
|
@@ -3010,151 +3683,46 @@
|
|
3010
3683
|
return local__createLocal.apply(null, arguments).parseZone();
|
3011
3684
|
}
|
3012
3685
|
|
3013
|
-
var defaultCalendar = {
|
3014
|
-
sameDay : '[Today at] LT',
|
3015
|
-
nextDay : '[Tomorrow at] LT',
|
3016
|
-
nextWeek : 'dddd [at] LT',
|
3017
|
-
lastDay : '[Yesterday at] LT',
|
3018
|
-
lastWeek : '[Last] dddd [at] LT',
|
3019
|
-
sameElse : 'L'
|
3020
|
-
};
|
3021
|
-
|
3022
|
-
function locale_calendar__calendar (key, mom, now) {
|
3023
|
-
var output = this._calendar[key];
|
3024
|
-
return isFunction(output) ? output.call(mom, now) : output;
|
3025
|
-
}
|
3026
|
-
|
3027
|
-
var defaultLongDateFormat = {
|
3028
|
-
LTS : 'h:mm:ss A',
|
3029
|
-
LT : 'h:mm A',
|
3030
|
-
L : 'MM/DD/YYYY',
|
3031
|
-
LL : 'MMMM D, YYYY',
|
3032
|
-
LLL : 'MMMM D, YYYY h:mm A',
|
3033
|
-
LLLL : 'dddd, MMMM D, YYYY h:mm A'
|
3034
|
-
};
|
3035
|
-
|
3036
|
-
function longDateFormat (key) {
|
3037
|
-
var format = this._longDateFormat[key],
|
3038
|
-
formatUpper = this._longDateFormat[key.toUpperCase()];
|
3039
|
-
|
3040
|
-
if (format || !formatUpper) {
|
3041
|
-
return format;
|
3042
|
-
}
|
3043
|
-
|
3044
|
-
this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
3045
|
-
return val.slice(1);
|
3046
|
-
});
|
3047
|
-
|
3048
|
-
return this._longDateFormat[key];
|
3049
|
-
}
|
3050
|
-
|
3051
|
-
var defaultInvalidDate = 'Invalid date';
|
3052
|
-
|
3053
|
-
function invalidDate () {
|
3054
|
-
return this._invalidDate;
|
3055
|
-
}
|
3056
|
-
|
3057
|
-
var defaultOrdinal = '%d';
|
3058
|
-
var defaultOrdinalParse = /\d{1,2}/;
|
3059
|
-
|
3060
|
-
function ordinal (number) {
|
3061
|
-
return this._ordinal.replace('%d', number);
|
3062
|
-
}
|
3063
|
-
|
3064
3686
|
function preParsePostFormat (string) {
|
3065
3687
|
return string;
|
3066
3688
|
}
|
3067
3689
|
|
3068
|
-
var defaultRelativeTime = {
|
3069
|
-
future : 'in %s',
|
3070
|
-
past : '%s ago',
|
3071
|
-
s : 'a few seconds',
|
3072
|
-
m : 'a minute',
|
3073
|
-
mm : '%d minutes',
|
3074
|
-
h : 'an hour',
|
3075
|
-
hh : '%d hours',
|
3076
|
-
d : 'a day',
|
3077
|
-
dd : '%d days',
|
3078
|
-
M : 'a month',
|
3079
|
-
MM : '%d months',
|
3080
|
-
y : 'a year',
|
3081
|
-
yy : '%d years'
|
3082
|
-
};
|
3083
|
-
|
3084
|
-
function relative__relativeTime (number, withoutSuffix, string, isFuture) {
|
3085
|
-
var output = this._relativeTime[string];
|
3086
|
-
return (isFunction(output)) ?
|
3087
|
-
output(number, withoutSuffix, string, isFuture) :
|
3088
|
-
output.replace(/%d/i, number);
|
3089
|
-
}
|
3090
|
-
|
3091
|
-
function pastFuture (diff, output) {
|
3092
|
-
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
3093
|
-
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
3094
|
-
}
|
3095
|
-
|
3096
|
-
function locale_set__set (config) {
|
3097
|
-
var prop, i;
|
3098
|
-
for (i in config) {
|
3099
|
-
prop = config[i];
|
3100
|
-
if (isFunction(prop)) {
|
3101
|
-
this[i] = prop;
|
3102
|
-
} else {
|
3103
|
-
this['_' + i] = prop;
|
3104
|
-
}
|
3105
|
-
}
|
3106
|
-
// Lenient ordinal parsing accepts just a number in addition to
|
3107
|
-
// number + (possibly) stuff coming from _ordinalParseLenient.
|
3108
|
-
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
|
3109
|
-
}
|
3110
|
-
|
3111
3690
|
var prototype__proto = Locale.prototype;
|
3112
3691
|
|
3113
|
-
prototype__proto._calendar = defaultCalendar;
|
3114
3692
|
prototype__proto.calendar = locale_calendar__calendar;
|
3115
|
-
prototype__proto._longDateFormat = defaultLongDateFormat;
|
3116
3693
|
prototype__proto.longDateFormat = longDateFormat;
|
3117
|
-
prototype__proto._invalidDate = defaultInvalidDate;
|
3118
3694
|
prototype__proto.invalidDate = invalidDate;
|
3119
|
-
prototype__proto._ordinal = defaultOrdinal;
|
3120
3695
|
prototype__proto.ordinal = ordinal;
|
3121
|
-
prototype__proto._ordinalParse = defaultOrdinalParse;
|
3122
3696
|
prototype__proto.preparse = preParsePostFormat;
|
3123
3697
|
prototype__proto.postformat = preParsePostFormat;
|
3124
|
-
prototype__proto._relativeTime = defaultRelativeTime;
|
3125
3698
|
prototype__proto.relativeTime = relative__relativeTime;
|
3126
3699
|
prototype__proto.pastFuture = pastFuture;
|
3127
3700
|
prototype__proto.set = locale_set__set;
|
3128
3701
|
|
3129
3702
|
// Month
|
3130
3703
|
prototype__proto.months = localeMonths;
|
3131
|
-
prototype__proto._months = defaultLocaleMonths;
|
3132
3704
|
prototype__proto.monthsShort = localeMonthsShort;
|
3133
|
-
prototype__proto._monthsShort = defaultLocaleMonthsShort;
|
3134
3705
|
prototype__proto.monthsParse = localeMonthsParse;
|
3135
|
-
prototype__proto._monthsRegex = defaultMonthsRegex;
|
3136
3706
|
prototype__proto.monthsRegex = monthsRegex;
|
3137
|
-
prototype__proto._monthsShortRegex = defaultMonthsShortRegex;
|
3138
3707
|
prototype__proto.monthsShortRegex = monthsShortRegex;
|
3139
3708
|
|
3140
3709
|
// Week
|
3141
3710
|
prototype__proto.week = localeWeek;
|
3142
|
-
prototype__proto._week = defaultLocaleWeek;
|
3143
3711
|
prototype__proto.firstDayOfYear = localeFirstDayOfYear;
|
3144
3712
|
prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
|
3145
3713
|
|
3146
3714
|
// Day of Week
|
3147
3715
|
prototype__proto.weekdays = localeWeekdays;
|
3148
|
-
prototype__proto._weekdays = defaultLocaleWeekdays;
|
3149
3716
|
prototype__proto.weekdaysMin = localeWeekdaysMin;
|
3150
|
-
prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
|
3151
3717
|
prototype__proto.weekdaysShort = localeWeekdaysShort;
|
3152
|
-
prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
|
3153
3718
|
prototype__proto.weekdaysParse = localeWeekdaysParse;
|
3154
3719
|
|
3720
|
+
prototype__proto.weekdaysRegex = weekdaysRegex;
|
3721
|
+
prototype__proto.weekdaysShortRegex = weekdaysShortRegex;
|
3722
|
+
prototype__proto.weekdaysMinRegex = weekdaysMinRegex;
|
3723
|
+
|
3155
3724
|
// Hours
|
3156
3725
|
prototype__proto.isPM = localeIsPM;
|
3157
|
-
prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
|
3158
3726
|
prototype__proto.meridiem = localeMeridiem;
|
3159
3727
|
|
3160
3728
|
function lists__get (format, index, field, setter) {
|
@@ -3163,7 +3731,7 @@
|
|
3163
3731
|
return locale[field](utc, format);
|
3164
3732
|
}
|
3165
3733
|
|
3166
|
-
function
|
3734
|
+
function listMonthsImpl (format, index, field) {
|
3167
3735
|
if (typeof format === 'number') {
|
3168
3736
|
index = format;
|
3169
3737
|
format = undefined;
|
@@ -3172,35 +3740,79 @@
|
|
3172
3740
|
format = format || '';
|
3173
3741
|
|
3174
3742
|
if (index != null) {
|
3175
|
-
return lists__get(format, index, field,
|
3743
|
+
return lists__get(format, index, field, 'month');
|
3744
|
+
}
|
3745
|
+
|
3746
|
+
var i;
|
3747
|
+
var out = [];
|
3748
|
+
for (i = 0; i < 12; i++) {
|
3749
|
+
out[i] = lists__get(format, i, field, 'month');
|
3750
|
+
}
|
3751
|
+
return out;
|
3752
|
+
}
|
3753
|
+
|
3754
|
+
// ()
|
3755
|
+
// (5)
|
3756
|
+
// (fmt, 5)
|
3757
|
+
// (fmt)
|
3758
|
+
// (true)
|
3759
|
+
// (true, 5)
|
3760
|
+
// (true, fmt, 5)
|
3761
|
+
// (true, fmt)
|
3762
|
+
function listWeekdaysImpl (localeSorted, format, index, field) {
|
3763
|
+
if (typeof localeSorted === 'boolean') {
|
3764
|
+
if (typeof format === 'number') {
|
3765
|
+
index = format;
|
3766
|
+
format = undefined;
|
3767
|
+
}
|
3768
|
+
|
3769
|
+
format = format || '';
|
3770
|
+
} else {
|
3771
|
+
format = localeSorted;
|
3772
|
+
index = format;
|
3773
|
+
localeSorted = false;
|
3774
|
+
|
3775
|
+
if (typeof format === 'number') {
|
3776
|
+
index = format;
|
3777
|
+
format = undefined;
|
3778
|
+
}
|
3779
|
+
|
3780
|
+
format = format || '';
|
3781
|
+
}
|
3782
|
+
|
3783
|
+
var locale = locale_locales__getLocale(),
|
3784
|
+
shift = localeSorted ? locale._week.dow : 0;
|
3785
|
+
|
3786
|
+
if (index != null) {
|
3787
|
+
return lists__get(format, (index + shift) % 7, field, 'day');
|
3176
3788
|
}
|
3177
3789
|
|
3178
3790
|
var i;
|
3179
3791
|
var out = [];
|
3180
|
-
for (i = 0; i <
|
3181
|
-
out[i] = lists__get(format, i, field,
|
3792
|
+
for (i = 0; i < 7; i++) {
|
3793
|
+
out[i] = lists__get(format, (i + shift) % 7, field, 'day');
|
3182
3794
|
}
|
3183
3795
|
return out;
|
3184
3796
|
}
|
3185
3797
|
|
3186
3798
|
function lists__listMonths (format, index) {
|
3187
|
-
return
|
3799
|
+
return listMonthsImpl(format, index, 'months');
|
3188
3800
|
}
|
3189
3801
|
|
3190
3802
|
function lists__listMonthsShort (format, index) {
|
3191
|
-
return
|
3803
|
+
return listMonthsImpl(format, index, 'monthsShort');
|
3192
3804
|
}
|
3193
3805
|
|
3194
|
-
function lists__listWeekdays (format, index) {
|
3195
|
-
return
|
3806
|
+
function lists__listWeekdays (localeSorted, format, index) {
|
3807
|
+
return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
3196
3808
|
}
|
3197
3809
|
|
3198
|
-
function lists__listWeekdaysShort (format, index) {
|
3199
|
-
return
|
3810
|
+
function lists__listWeekdaysShort (localeSorted, format, index) {
|
3811
|
+
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
3200
3812
|
}
|
3201
3813
|
|
3202
|
-
function lists__listWeekdaysMin (format, index) {
|
3203
|
-
return
|
3814
|
+
function lists__listWeekdaysMin (localeSorted, format, index) {
|
3815
|
+
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
3204
3816
|
}
|
3205
3817
|
|
3206
3818
|
locale_locales__getSetGlobalLocale('en', {
|
@@ -3439,6 +4051,18 @@
|
|
3439
4051
|
return substituteTimeAgo.apply(null, a);
|
3440
4052
|
}
|
3441
4053
|
|
4054
|
+
// This function allows you to set the rounding function for relative time strings
|
4055
|
+
function duration_humanize__getSetRelativeTimeRounding (roundingFunction) {
|
4056
|
+
if (roundingFunction === undefined) {
|
4057
|
+
return round;
|
4058
|
+
}
|
4059
|
+
if (typeof(roundingFunction) === 'function') {
|
4060
|
+
round = roundingFunction;
|
4061
|
+
return true;
|
4062
|
+
}
|
4063
|
+
return false;
|
4064
|
+
}
|
4065
|
+
|
3442
4066
|
// This function allows you to set a threshold for relative time strings
|
3443
4067
|
function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
|
3444
4068
|
if (thresholds[threshold] === undefined) {
|
@@ -3571,7 +4195,7 @@
|
|
3571
4195
|
// Side effect imports
|
3572
4196
|
|
3573
4197
|
|
3574
|
-
utils_hooks__hooks.version = '2.
|
4198
|
+
utils_hooks__hooks.version = '2.15.1';
|
3575
4199
|
|
3576
4200
|
setHookCallback(local__createLocal);
|
3577
4201
|
|
@@ -3594,9 +4218,13 @@
|
|
3594
4218
|
utils_hooks__hooks.monthsShort = lists__listMonthsShort;
|
3595
4219
|
utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
|
3596
4220
|
utils_hooks__hooks.defineLocale = defineLocale;
|
4221
|
+
utils_hooks__hooks.updateLocale = updateLocale;
|
4222
|
+
utils_hooks__hooks.locales = locale_locales__listLocales;
|
3597
4223
|
utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
|
3598
4224
|
utils_hooks__hooks.normalizeUnits = normalizeUnits;
|
4225
|
+
utils_hooks__hooks.relativeTimeRounding = duration_humanize__getSetRelativeTimeRounding;
|
3599
4226
|
utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
|
4227
|
+
utils_hooks__hooks.calendarFormat = getCalendarFormat;
|
3600
4228
|
utils_hooks__hooks.prototype = momentPrototype;
|
3601
4229
|
|
3602
4230
|
var _moment = utils_hooks__hooks;
|