@nocobase/plugin-backup-restore 2.2.20 → 2.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/externalVersion.js +5 -5
  2. package/dist/node_modules/@hapi/topo/package.json +1 -1
  3. package/dist/node_modules/@xhmikosr/decompress/package.json +1 -1
  4. package/dist/node_modules/archiver/package.json +1 -1
  5. package/dist/node_modules/fs-extra/package.json +1 -1
  6. package/dist/node_modules/moment/LICENSE +1 -1
  7. package/dist/node_modules/moment/dist/locale/am-et.js +62 -0
  8. package/dist/node_modules/moment/dist/locale/ar-dz.js +8 -8
  9. package/dist/node_modules/moment/dist/locale/ar-ly.js +8 -8
  10. package/dist/node_modules/moment/dist/locale/ar-ps.js +112 -0
  11. package/dist/node_modules/moment/dist/locale/ar.js +8 -8
  12. package/dist/node_modules/moment/dist/locale/be.js +2 -2
  13. package/dist/node_modules/moment/dist/locale/bs.js +14 -4
  14. package/dist/node_modules/moment/dist/locale/ca.js +7 -7
  15. package/dist/node_modules/moment/dist/locale/cs.js +5 -4
  16. package/dist/node_modules/moment/dist/locale/cv.js +2 -2
  17. package/dist/node_modules/moment/dist/locale/de-at.js +29 -1
  18. package/dist/node_modules/moment/dist/locale/de-ch.js +29 -1
  19. package/dist/node_modules/moment/dist/locale/de.js +29 -1
  20. package/dist/node_modules/moment/dist/locale/en-au.js +6 -6
  21. package/dist/node_modules/moment/dist/locale/en-ca.js +6 -6
  22. package/dist/node_modules/moment/dist/locale/en-gb.js +6 -6
  23. package/dist/node_modules/moment/dist/locale/en-ie.js +6 -6
  24. package/dist/node_modules/moment/dist/locale/en-il.js +6 -6
  25. package/dist/node_modules/moment/dist/locale/en-in.js +6 -6
  26. package/dist/node_modules/moment/dist/locale/en-nz.js +6 -6
  27. package/dist/node_modules/moment/dist/locale/en-sg.js +6 -6
  28. package/dist/node_modules/moment/dist/locale/hu.js +3 -3
  29. package/dist/node_modules/moment/dist/locale/id.js +12 -1
  30. package/dist/node_modules/moment/dist/locale/it.js +4 -4
  31. package/dist/node_modules/moment/dist/locale/ka.js +1 -1
  32. package/dist/node_modules/moment/dist/locale/ku-kmr.js +121 -0
  33. package/dist/node_modules/moment/dist/locale/lt.js +2 -2
  34. package/dist/node_modules/moment/dist/locale/me.js +2 -2
  35. package/dist/node_modules/moment/dist/locale/nb.js +4 -4
  36. package/dist/node_modules/moment/dist/locale/nl-be.js +2 -2
  37. package/dist/node_modules/moment/dist/locale/nl.js +1 -1
  38. package/dist/node_modules/moment/dist/locale/oc-lnc.js +6 -6
  39. package/dist/node_modules/moment/dist/locale/pl.js +1 -1
  40. package/dist/node_modules/moment/dist/locale/ps.js +177 -0
  41. package/dist/node_modules/moment/dist/locale/pt-br.js +14 -6
  42. package/dist/node_modules/moment/dist/locale/ru.js +2 -2
  43. package/dist/node_modules/moment/dist/locale/sv.js +7 -7
  44. package/dist/node_modules/moment/dist/locale/sw.js +56 -14
  45. package/dist/node_modules/moment/dist/locale/tet.js +6 -6
  46. package/dist/node_modules/moment/dist/locale/tlh.js +8 -8
  47. package/dist/node_modules/moment/dist/locale/tzl.js +2 -2
  48. package/dist/node_modules/moment/dist/locale/uk.js +9 -8
  49. package/dist/node_modules/moment/dist/locale/uz-latn.js +1 -1
  50. package/dist/node_modules/moment/dist/locale/uz.js +1 -1
  51. package/dist/node_modules/moment/dist/locale/x-pseudo.js +6 -6
  52. package/dist/node_modules/moment/dist/moment.js +1274 -1042
  53. package/dist/node_modules/moment/dojo.profile.js +11 -0
  54. package/dist/node_modules/moment/ender.js +1 -1
  55. package/dist/node_modules/moment/locale/am-et.js +73 -0
  56. package/dist/node_modules/moment/locale/ar-dz.js +8 -8
  57. package/dist/node_modules/moment/locale/ar-ly.js +8 -8
  58. package/dist/node_modules/moment/locale/ar-ps.js +123 -0
  59. package/dist/node_modules/moment/locale/ar.js +8 -8
  60. package/dist/node_modules/moment/locale/be.js +2 -2
  61. package/dist/node_modules/moment/locale/bm.js +2 -0
  62. package/dist/node_modules/moment/locale/bs.js +14 -4
  63. package/dist/node_modules/moment/locale/ca.js +7 -7
  64. package/dist/node_modules/moment/locale/cs.js +5 -4
  65. package/dist/node_modules/moment/locale/cv.js +2 -2
  66. package/dist/node_modules/moment/locale/de-at.js +29 -1
  67. package/dist/node_modules/moment/locale/de-ch.js +29 -1
  68. package/dist/node_modules/moment/locale/de.js +29 -1
  69. package/dist/node_modules/moment/locale/en-au.js +6 -6
  70. package/dist/node_modules/moment/locale/en-ca.js +6 -6
  71. package/dist/node_modules/moment/locale/en-gb.js +6 -6
  72. package/dist/node_modules/moment/locale/en-ie.js +6 -6
  73. package/dist/node_modules/moment/locale/en-il.js +6 -6
  74. package/dist/node_modules/moment/locale/en-in.js +6 -6
  75. package/dist/node_modules/moment/locale/en-nz.js +6 -6
  76. package/dist/node_modules/moment/locale/en-sg.js +6 -6
  77. package/dist/node_modules/moment/locale/hu.js +3 -3
  78. package/dist/node_modules/moment/locale/id.js +12 -1
  79. package/dist/node_modules/moment/locale/it.js +4 -4
  80. package/dist/node_modules/moment/locale/ka.js +1 -1
  81. package/dist/node_modules/moment/locale/ku-kmr.js +125 -0
  82. package/dist/node_modules/moment/locale/lt.js +2 -2
  83. package/dist/node_modules/moment/locale/me.js +2 -2
  84. package/dist/node_modules/moment/locale/mk.js +0 -1
  85. package/dist/node_modules/moment/locale/nb.js +4 -4
  86. package/dist/node_modules/moment/locale/nl-be.js +2 -2
  87. package/dist/node_modules/moment/locale/nl.js +1 -1
  88. package/dist/node_modules/moment/locale/oc-lnc.js +6 -6
  89. package/dist/node_modules/moment/locale/pl.js +1 -1
  90. package/dist/node_modules/moment/locale/ps.js +188 -0
  91. package/dist/node_modules/moment/locale/pt-br.js +14 -6
  92. package/dist/node_modules/moment/locale/ru.js +2 -2
  93. package/dist/node_modules/moment/locale/sv.js +7 -7
  94. package/dist/node_modules/moment/locale/sw.js +56 -14
  95. package/dist/node_modules/moment/locale/tet.js +6 -6
  96. package/dist/node_modules/moment/locale/tlh.js +8 -8
  97. package/dist/node_modules/moment/locale/tzl.js +2 -2
  98. package/dist/node_modules/moment/locale/uk.js +9 -8
  99. package/dist/node_modules/moment/locale/uz-latn.js +1 -1
  100. package/dist/node_modules/moment/locale/uz.js +1 -1
  101. package/dist/node_modules/moment/locale/x-pseudo.js +6 -6
  102. package/dist/node_modules/moment/min/locales.js +1380 -771
  103. package/dist/node_modules/moment/min/locales.min.js +211 -1
  104. package/dist/node_modules/moment/min/moment-with-locales.js +2705 -1858
  105. package/dist/node_modules/moment/min/moment-with-locales.min.js +216 -1
  106. package/dist/node_modules/moment/min/moment.min.js +8 -1
  107. package/dist/node_modules/moment/moment.d.ts +2 -0
  108. package/dist/node_modules/moment/moment.js +3 -3
  109. package/dist/node_modules/moment/package.json +1 -1
  110. package/dist/node_modules/moment/src/lib/create/check-overflow.js +15 -15
  111. package/dist/node_modules/moment/src/lib/create/from-array.js +77 -10
  112. package/dist/node_modules/moment/src/lib/create/from-string-and-array.js +2 -0
  113. package/dist/node_modules/moment/src/lib/create/parsing-flags.js +1 -0
  114. package/dist/node_modules/moment/src/lib/create/valid.js +25 -24
  115. package/dist/node_modules/moment/src/lib/duration/as.js +3 -15
  116. package/dist/node_modules/moment/src/lib/duration/bubble.js +4 -6
  117. package/dist/node_modules/moment/src/lib/duration/humanize.js +14 -3
  118. package/dist/node_modules/moment/src/lib/format/format.js +7 -4
  119. package/dist/node_modules/moment/src/lib/locale/en.js +6 -6
  120. package/dist/node_modules/moment/src/lib/locale/formats.js +19 -3
  121. package/dist/node_modules/moment/src/lib/locale/locales.js +33 -13
  122. package/dist/node_modules/moment/src/lib/locale/relative.js +25 -2
  123. package/dist/node_modules/moment/src/lib/locale/set.js +4 -0
  124. package/dist/node_modules/moment/src/lib/moment/calendar.js +10 -10
  125. package/dist/node_modules/moment/src/lib/moment/get-set.js +66 -22
  126. package/dist/node_modules/moment/src/lib/moment/min-max.js +15 -3
  127. package/dist/node_modules/moment/src/lib/parse/regex.js +4 -0
  128. package/dist/node_modules/moment/src/lib/units/aliases.js +50 -6
  129. package/dist/node_modules/moment/src/lib/units/day-of-month.js +7 -11
  130. package/dist/node_modules/moment/src/lib/units/day-of-week.js +52 -21
  131. package/dist/node_modules/moment/src/lib/units/day-of-year.js +0 -9
  132. package/dist/node_modules/moment/src/lib/units/era.js +13 -7
  133. package/dist/node_modules/moment/src/lib/units/hour.js +5 -12
  134. package/dist/node_modules/moment/src/lib/units/millisecond.js +0 -10
  135. package/dist/node_modules/moment/src/lib/units/minute.js +7 -12
  136. package/dist/node_modules/moment/src/lib/units/month.js +38 -28
  137. package/dist/node_modules/moment/src/lib/units/offset.js +13 -1
  138. package/dist/node_modules/moment/src/lib/units/priorities.js +18 -5
  139. package/dist/node_modules/moment/src/lib/units/quarter.js +0 -10
  140. package/dist/node_modules/moment/src/lib/units/second.js +7 -12
  141. package/dist/node_modules/moment/src/lib/units/week-calendar-utils.js +22 -8
  142. package/dist/node_modules/moment/src/lib/units/week-year.js +1 -11
  143. package/dist/node_modules/moment/src/lib/units/week.js +8 -15
  144. package/dist/node_modules/moment/src/lib/units/year.js +0 -10
  145. package/dist/node_modules/moment/src/lib/utils/deprecate.js +1 -1
  146. package/dist/node_modules/moment/src/locale/am-et.js +62 -0
  147. package/dist/node_modules/moment/src/locale/ar-dz.js +8 -8
  148. package/dist/node_modules/moment/src/locale/ar-ly.js +8 -8
  149. package/dist/node_modules/moment/src/locale/ar-ps.js +112 -0
  150. package/dist/node_modules/moment/src/locale/ar.js +8 -8
  151. package/dist/node_modules/moment/src/locale/be.js +2 -2
  152. package/dist/node_modules/moment/src/locale/bs.js +14 -4
  153. package/dist/node_modules/moment/src/locale/ca.js +7 -7
  154. package/dist/node_modules/moment/src/locale/cs.js +5 -4
  155. package/dist/node_modules/moment/src/locale/cv.js +2 -2
  156. package/dist/node_modules/moment/src/locale/de-at.js +29 -1
  157. package/dist/node_modules/moment/src/locale/de-ch.js +29 -1
  158. package/dist/node_modules/moment/src/locale/de.js +29 -1
  159. package/dist/node_modules/moment/src/locale/en-au.js +6 -6
  160. package/dist/node_modules/moment/src/locale/en-ca.js +6 -6
  161. package/dist/node_modules/moment/src/locale/en-gb.js +6 -6
  162. package/dist/node_modules/moment/src/locale/en-ie.js +6 -6
  163. package/dist/node_modules/moment/src/locale/en-il.js +6 -6
  164. package/dist/node_modules/moment/src/locale/en-in.js +6 -6
  165. package/dist/node_modules/moment/src/locale/en-nz.js +6 -6
  166. package/dist/node_modules/moment/src/locale/en-sg.js +6 -6
  167. package/dist/node_modules/moment/src/locale/hu.js +3 -3
  168. package/dist/node_modules/moment/src/locale/id.js +12 -1
  169. package/dist/node_modules/moment/src/locale/it.js +4 -4
  170. package/dist/node_modules/moment/src/locale/ka.js +1 -1
  171. package/dist/node_modules/moment/src/locale/ku-kmr.js +121 -0
  172. package/dist/node_modules/moment/src/locale/lt.js +2 -2
  173. package/dist/node_modules/moment/src/locale/me.js +2 -2
  174. package/dist/node_modules/moment/src/locale/nb.js +4 -4
  175. package/dist/node_modules/moment/src/locale/nl-be.js +2 -2
  176. package/dist/node_modules/moment/src/locale/nl.js +1 -1
  177. package/dist/node_modules/moment/src/locale/oc-lnc.js +6 -6
  178. package/dist/node_modules/moment/src/locale/pl.js +1 -1
  179. package/dist/node_modules/moment/src/locale/ps.js +177 -0
  180. package/dist/node_modules/moment/src/locale/pt-br.js +14 -6
  181. package/dist/node_modules/moment/src/locale/ru.js +2 -2
  182. package/dist/node_modules/moment/src/locale/sv.js +7 -7
  183. package/dist/node_modules/moment/src/locale/sw.js +56 -14
  184. package/dist/node_modules/moment/src/locale/tet.js +6 -6
  185. package/dist/node_modules/moment/src/locale/tlh.js +8 -8
  186. package/dist/node_modules/moment/src/locale/tzl.js +2 -2
  187. package/dist/node_modules/moment/src/locale/uk.js +9 -8
  188. package/dist/node_modules/moment/src/locale/uz-latn.js +1 -1
  189. package/dist/node_modules/moment/src/locale/uz.js +1 -1
  190. package/dist/node_modules/moment/src/locale/x-pseudo.js +6 -6
  191. package/dist/node_modules/moment/src/moment.js +2 -2
  192. package/dist/node_modules/moment/ts3.1-typings/moment.d.ts +258 -78
  193. package/dist/node_modules/semver/package.json +1 -1
  194. package/package.json +2 -2
  195. package/dist/node_modules/moment/package.js +0 -11
@@ -1,5 +1,5 @@
1
1
  //! moment.js
2
- //! version : 2.29.4
2
+ //! version : 2.31.0
3
3
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
4
4
  //! license : MIT
5
5
  //! momentjs.com
@@ -111,6 +111,7 @@ function defaultParsingFlags() {
111
111
  nullInput: false,
112
112
  invalidEra: null,
113
113
  invalidMonth: null,
114
+ invalidOffset: null,
114
115
  invalidFormat: false,
115
116
  userInvalidated: false,
116
117
  iso: false,
@@ -148,25 +149,27 @@ if (Array.prototype.some) {
148
149
  };
149
150
  }
150
151
 
151
- function isValid(m) {
152
- if (m._isValid == null) {
153
- var flags = getParsingFlags(m),
154
- parsedParts = some.call(flags.parsedDateParts, function (i) {
155
- return i != null;
156
- }),
157
- isNowValid =
158
- !isNaN(m._d.getTime()) &&
159
- flags.overflow < 0 &&
160
- !flags.empty &&
161
- !flags.invalidEra &&
162
- !flags.invalidMonth &&
163
- !flags.invalidWeekday &&
164
- !flags.weekdayMismatch &&
165
- !flags.nullInput &&
166
- !flags.invalidFormat &&
167
- !flags.userInvalidated &&
168
- (!flags.meridiem || (flags.meridiem && parsedParts));
169
-
152
+ function isValid$2(m) {
153
+ var flags = null,
154
+ parsedParts = false,
155
+ isNowValid = m._d && !isNaN(m._d.getTime());
156
+ if (isNowValid) {
157
+ flags = getParsingFlags(m);
158
+ parsedParts = some.call(flags.parsedDateParts, function (i) {
159
+ return i != null;
160
+ });
161
+ isNowValid =
162
+ flags.overflow < 0 &&
163
+ !flags.empty &&
164
+ !flags.invalidEra &&
165
+ !flags.invalidMonth &&
166
+ !flags.invalidOffset &&
167
+ !flags.invalidWeekday &&
168
+ !flags.weekdayMismatch &&
169
+ !flags.nullInput &&
170
+ !flags.invalidFormat &&
171
+ !flags.userInvalidated &&
172
+ (!flags.meridiem || (flags.meridiem && parsedParts));
170
173
  if (m._strict) {
171
174
  isNowValid =
172
175
  isNowValid &&
@@ -174,17 +177,16 @@ function isValid(m) {
174
177
  flags.unusedTokens.length === 0 &&
175
178
  flags.bigHour === undefined;
176
179
  }
177
-
178
- if (Object.isFrozen == null || !Object.isFrozen(m)) {
179
- m._isValid = isNowValid;
180
- } else {
181
- return isNowValid;
182
- }
180
+ }
181
+ if (Object.isFrozen == null || !Object.isFrozen(m)) {
182
+ m._isValid = isNowValid;
183
+ } else {
184
+ return isNowValid;
183
185
  }
184
186
  return m._isValid;
185
187
  }
186
188
 
187
- function createInvalid(flags) {
189
+ function createInvalid$1(flags) {
188
190
  var m = createUTC(NaN);
189
191
  if (flags != null) {
190
192
  extend(getParsingFlags(m), flags);
@@ -330,7 +332,7 @@ function deprecateSimple(name, msg) {
330
332
  hooks.deprecationHandler(name, msg);
331
333
  }
332
334
  if (!deprecations[name]) {
333
- warn(msg);
335
+ warn(msg + '\n' + new Error().stack);
334
336
  deprecations[name] = true;
335
337
  }
336
338
  }
@@ -345,93 +347,111 @@ function isFunction(input) {
345
347
  );
346
348
  }
347
349
 
348
- function set(config) {
349
- var prop, i;
350
- for (i in config) {
351
- if (hasOwnProp(config, i)) {
352
- prop = config[i];
353
- if (isFunction(prop)) {
354
- this[i] = prop;
355
- } else {
356
- this['_' + i] = prop;
357
- }
358
- }
359
- }
360
- this._config = config;
361
- // Lenient ordinal parsing accepts just a number in addition to
362
- // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
363
- // TODO: Remove "ordinalParse" fallback in next major release.
364
- this._dayOfMonthOrdinalParseLenient = new RegExp(
365
- (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
366
- '|' +
367
- /\d{1,2}/.source
368
- );
350
+ var aliases = {
351
+ D: 'date',
352
+ dates: 'date',
353
+ date: 'date',
354
+ d: 'day',
355
+ days: 'day',
356
+ day: 'day',
357
+ e: 'weekday',
358
+ weekdays: 'weekday',
359
+ weekday: 'weekday',
360
+ E: 'isoWeekday',
361
+ isoweekdays: 'isoWeekday',
362
+ isoweekday: 'isoWeekday',
363
+ DDD: 'dayOfYear',
364
+ dayofyears: 'dayOfYear',
365
+ dayofyear: 'dayOfYear',
366
+ h: 'hour',
367
+ hours: 'hour',
368
+ hour: 'hour',
369
+ ms: 'millisecond',
370
+ milliseconds: 'millisecond',
371
+ millisecond: 'millisecond',
372
+ m: 'minute',
373
+ minutes: 'minute',
374
+ minute: 'minute',
375
+ M: 'month',
376
+ months: 'month',
377
+ month: 'month',
378
+ Q: 'quarter',
379
+ quarters: 'quarter',
380
+ quarter: 'quarter',
381
+ s: 'second',
382
+ seconds: 'second',
383
+ second: 'second',
384
+ gg: 'weekYear',
385
+ weekyears: 'weekYear',
386
+ weekyear: 'weekYear',
387
+ GG: 'isoWeekYear',
388
+ isoweekyears: 'isoWeekYear',
389
+ isoweekyear: 'isoWeekYear',
390
+ w: 'week',
391
+ weeks: 'week',
392
+ week: 'week',
393
+ W: 'isoWeek',
394
+ isoweeks: 'isoWeek',
395
+ isoweek: 'isoWeek',
396
+ y: 'year',
397
+ years: 'year',
398
+ year: 'year',
399
+ };
400
+
401
+ function normalizeUnits(units) {
402
+ return typeof units === 'string'
403
+ ? aliases[units] || aliases[units.toLowerCase()]
404
+ : undefined;
369
405
  }
370
406
 
371
- function mergeConfigs(parentConfig, childConfig) {
372
- var res = extend({}, parentConfig),
407
+ function normalizeObjectUnits(inputObject) {
408
+ var normalizedInput = {},
409
+ normalizedProp,
373
410
  prop;
374
- for (prop in childConfig) {
375
- if (hasOwnProp(childConfig, prop)) {
376
- if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
377
- res[prop] = {};
378
- extend(res[prop], parentConfig[prop]);
379
- extend(res[prop], childConfig[prop]);
380
- } else if (childConfig[prop] != null) {
381
- res[prop] = childConfig[prop];
382
- } else {
383
- delete res[prop];
411
+
412
+ for (prop in inputObject) {
413
+ if (hasOwnProp(inputObject, prop)) {
414
+ normalizedProp = normalizeUnits(prop);
415
+ if (normalizedProp) {
416
+ normalizedInput[normalizedProp] = inputObject[prop];
384
417
  }
385
418
  }
386
419
  }
387
- for (prop in parentConfig) {
388
- if (
389
- hasOwnProp(parentConfig, prop) &&
390
- !hasOwnProp(childConfig, prop) &&
391
- isObject(parentConfig[prop])
392
- ) {
393
- // make sure changes to properties don't modify parent config
394
- res[prop] = extend({}, res[prop]);
395
- }
396
- }
397
- return res;
398
- }
399
-
400
- function Locale(config) {
401
- if (config != null) {
402
- this.set(config);
403
- }
404
- }
405
-
406
- var keys;
407
420
 
408
- if (Object.keys) {
409
- keys = Object.keys;
410
- } else {
411
- keys = function (obj) {
412
- var i,
413
- res = [];
414
- for (i in obj) {
415
- if (hasOwnProp(obj, i)) {
416
- res.push(i);
417
- }
418
- }
419
- return res;
420
- };
421
+ return normalizedInput;
421
422
  }
422
423
 
423
- var defaultCalendar = {
424
- sameDay: '[Today at] LT',
425
- nextDay: '[Tomorrow at] LT',
426
- nextWeek: 'dddd [at] LT',
427
- lastDay: '[Yesterday at] LT',
428
- lastWeek: '[Last] dddd [at] LT',
429
- sameElse: 'L',
424
+ var priorities = {
425
+ date: 9,
426
+ day: 11,
427
+ weekday: 11,
428
+ isoWeekday: 11,
429
+ dayOfYear: 4,
430
+ hour: 13,
431
+ millisecond: 16,
432
+ minute: 14,
433
+ month: 8,
434
+ quarter: 7,
435
+ second: 15,
436
+ weekYear: 1,
437
+ isoWeekYear: 1,
438
+ week: 5,
439
+ isoWeek: 5,
440
+ year: 1,
430
441
  };
431
442
 
432
- function calendar(key, mom, now) {
433
- var output = this._calendar[key] || this._calendar['sameElse'];
434
- return isFunction(output) ? output.call(mom, now) : output;
443
+ function getPrioritizedUnits(unitsObj) {
444
+ var units = [],
445
+ u;
446
+ for (u in unitsObj) {
447
+ if (hasOwnProp(unitsObj, u)) {
448
+ units.push({ unit: u, priority: priorities[u] });
449
+ }
450
+ }
451
+ units.sort(function (a, b) {
452
+ return a.priority - b.priority;
453
+ });
454
+ return units;
435
455
  }
436
456
 
437
457
  function zeroFill(number, targetLength, forceSign) {
@@ -446,7 +466,7 @@ function zeroFill(number, targetLength, forceSign) {
446
466
  }
447
467
 
448
468
  var formattingTokens =
449
- /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
469
+ /(\[[^\[]*\])|(\\e)|(\\)?(eHHmm|[Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
450
470
  localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
451
471
  formatFunctions = {},
452
472
  formatTokenFunctions = {};
@@ -519,10 +539,12 @@ function formatMoment(m, format) {
519
539
  }
520
540
 
521
541
  format = expandFormat(format, m.localeData());
522
- formatFunctions[format] =
523
- formatFunctions[format] || makeFormatFunction(format);
542
+ var cacheKey = '$' + format;
543
+ if (!hasOwnProp(formatFunctions, cacheKey)) {
544
+ formatFunctions[cacheKey] = makeFormatFunction(format);
545
+ }
524
546
 
525
- return formatFunctions[format](m);
547
+ return formatFunctions[cacheKey](m);
526
548
  }
527
549
 
528
550
  function expandFormat(format, locale) {
@@ -545,157 +567,186 @@ function expandFormat(format, locale) {
545
567
  return format;
546
568
  }
547
569
 
548
- var defaultLongDateFormat = {
549
- LTS: 'h:mm:ss A',
550
- LT: 'h:mm A',
551
- L: 'MM/DD/YYYY',
552
- LL: 'MMMM D, YYYY',
553
- LLL: 'MMMM D, YYYY h:mm A',
554
- LLLL: 'dddd, MMMM D, YYYY h:mm A',
555
- };
556
-
557
- function longDateFormat(key) {
558
- var format = this._longDateFormat[key],
559
- formatUpper = this._longDateFormat[key.toUpperCase()];
560
-
561
- if (format || !formatUpper) {
562
- return format;
563
- }
564
-
565
- this._longDateFormat[key] = formatUpper
566
- .match(formattingTokens)
567
- .map(function (tok) {
568
- if (
569
- tok === 'MMMM' ||
570
- tok === 'MM' ||
571
- tok === 'DD' ||
572
- tok === 'dddd'
573
- ) {
574
- return tok.slice(1);
575
- }
576
- return tok;
577
- })
578
- .join('');
579
-
580
- return this._longDateFormat[key];
581
- }
582
-
583
- var defaultInvalidDate = 'Invalid date';
584
-
585
- function invalidDate() {
586
- return this._invalidDate;
587
- }
570
+ var match1 = /\d/, // 0 - 9
571
+ match2 = /\d\d/, // 00 - 99
572
+ match3 = /\d{3}/, // 000 - 999
573
+ match4 = /\d{4}/, // 0000 - 9999
574
+ match6 = /[+-]?\d{6}/, // -999999 - 999999
575
+ match1to2 = /\d\d?/, // 0 - 99
576
+ match3to4 = /\d\d\d\d?/, // 999 - 9999
577
+ match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
578
+ match1to3 = /\d{1,3}/, // 0 - 999
579
+ match1to4 = /\d{1,4}/, // 0 - 9999
580
+ match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
581
+ matchUnsigned = /\d+/, // 0 - inf
582
+ matchSigned = /[+-]?\d+/, // -inf - inf
583
+ matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
584
+ matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
585
+ matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
586
+ // any word (or two) characters or numbers including two/three word month in arabic.
587
+ // includes scottish gaelic two word and hyphenated months
588
+ matchWord =
589
+ /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
590
+ match1to2NoLeadingZero = /^[1-9]\d?/, // 1-99
591
+ match1to2HasZero = /^([1-9]\d|\d)/, // 0-99
592
+ regexes;
588
593
 
589
- var defaultOrdinal = '%d',
590
- defaultDayOfMonthOrdinalParse = /\d{1,2}/;
594
+ regexes = {};
591
595
 
592
- function ordinal(number) {
593
- return this._ordinal.replace('%d', number);
596
+ function addRegexToken(token, regex, strictRegex) {
597
+ regexes[token] = isFunction(regex)
598
+ ? regex
599
+ : function (isStrict, localeData) {
600
+ return isStrict && strictRegex ? strictRegex : regex;
601
+ };
594
602
  }
595
603
 
596
- var defaultRelativeTime = {
597
- future: 'in %s',
598
- past: '%s ago',
599
- s: 'a few seconds',
600
- ss: '%d seconds',
601
- m: 'a minute',
602
- mm: '%d minutes',
603
- h: 'an hour',
604
- hh: '%d hours',
605
- d: 'a day',
606
- dd: '%d days',
607
- w: 'a week',
608
- ww: '%d weeks',
609
- M: 'a month',
610
- MM: '%d months',
611
- y: 'a year',
612
- yy: '%d years',
613
- };
604
+ function getParseRegexForToken(token, config) {
605
+ if (!hasOwnProp(regexes, token)) {
606
+ return new RegExp(unescapeFormat(token));
607
+ }
614
608
 
615
- function relativeTime(number, withoutSuffix, string, isFuture) {
616
- var output = this._relativeTime[string];
617
- return isFunction(output)
618
- ? output(number, withoutSuffix, string, isFuture)
619
- : output.replace(/%d/i, number);
609
+ return regexes[token](config._strict, config._locale);
620
610
  }
621
611
 
622
- function pastFuture(diff, output) {
623
- var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
624
- return isFunction(format) ? format(output) : format.replace(/%s/i, output);
612
+ // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
613
+ function unescapeFormat(s) {
614
+ return regexEscape(
615
+ s
616
+ .replace('\\', '')
617
+ .replace(
618
+ /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
619
+ function (matched, p1, p2, p3, p4) {
620
+ return p1 || p2 || p3 || p4;
621
+ }
622
+ )
623
+ );
625
624
  }
626
625
 
627
- var aliases = {};
628
-
629
- function addUnitAlias(unit, shorthand) {
630
- var lowerCase = unit.toLowerCase();
631
- aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
626
+ function regexEscape(s) {
627
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
632
628
  }
633
629
 
634
- function normalizeUnits(units) {
635
- return typeof units === 'string'
636
- ? aliases[units] || aliases[units.toLowerCase()]
637
- : undefined;
630
+ function absFloor(number) {
631
+ if (number < 0) {
632
+ // -0 -> 0
633
+ return Math.ceil(number) || 0;
634
+ } else {
635
+ return Math.floor(number);
636
+ }
638
637
  }
639
638
 
640
- function normalizeObjectUnits(inputObject) {
641
- var normalizedInput = {},
642
- normalizedProp,
643
- prop;
639
+ function toInt(argumentForCoercion) {
640
+ var coercedNumber = +argumentForCoercion,
641
+ value = 0;
644
642
 
645
- for (prop in inputObject) {
646
- if (hasOwnProp(inputObject, prop)) {
647
- normalizedProp = normalizeUnits(prop);
648
- if (normalizedProp) {
649
- normalizedInput[normalizedProp] = inputObject[prop];
650
- }
651
- }
643
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
644
+ value = absFloor(coercedNumber);
652
645
  }
653
646
 
654
- return normalizedInput;
647
+ return value;
655
648
  }
656
649
 
657
- var priorities = {};
650
+ var tokens = {};
658
651
 
659
- function addUnitPriority(unit, priority) {
660
- priorities[unit] = priority;
652
+ function addParseToken(token, callback) {
653
+ var i,
654
+ func = callback,
655
+ tokenLen;
656
+ if (typeof token === 'string') {
657
+ token = [token];
658
+ }
659
+ if (isNumber(callback)) {
660
+ func = function (input, array) {
661
+ array[callback] = toInt(input);
662
+ };
663
+ }
664
+ tokenLen = token.length;
665
+ for (i = 0; i < tokenLen; i++) {
666
+ tokens[token[i]] = func;
667
+ }
661
668
  }
662
669
 
663
- function getPrioritizedUnits(unitsObj) {
664
- var units = [],
665
- u;
666
- for (u in unitsObj) {
667
- if (hasOwnProp(unitsObj, u)) {
668
- units.push({ unit: u, priority: priorities[u] });
669
- }
670
- }
671
- units.sort(function (a, b) {
672
- return a.priority - b.priority;
670
+ function addWeekParseToken(token, callback) {
671
+ addParseToken(token, function (input, array, config, token) {
672
+ config._w = config._w || {};
673
+ callback(input, config._w, config, token);
673
674
  });
674
- return units;
675
+ }
676
+
677
+ function addTimeToArrayFromToken(token, input, config) {
678
+ if (input != null && hasOwnProp(tokens, token)) {
679
+ tokens[token](input, config._a, config, token);
680
+ }
675
681
  }
676
682
 
677
683
  function isLeapYear(year) {
678
684
  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
679
685
  }
680
686
 
681
- function absFloor(number) {
682
- if (number < 0) {
683
- // -0 -> 0
684
- return Math.ceil(number) || 0;
685
- } else {
686
- return Math.floor(number);
687
- }
687
+ var YEAR = 0,
688
+ MONTH = 1,
689
+ DATE = 2,
690
+ HOUR = 3,
691
+ MINUTE = 4,
692
+ SECOND = 5,
693
+ MILLISECOND = 6,
694
+ WEEK = 7,
695
+ WEEKDAY = 8;
696
+
697
+ // FORMATTING
698
+
699
+ addFormatToken('Y', 0, 0, function () {
700
+ var y = this.year();
701
+ return y <= 9999 ? zeroFill(y, 4) : '+' + y;
702
+ });
703
+
704
+ addFormatToken(0, ['YY', 2], 0, function () {
705
+ return this.year() % 100;
706
+ });
707
+
708
+ addFormatToken(0, ['YYYY', 4], 0, 'year');
709
+ addFormatToken(0, ['YYYYY', 5], 0, 'year');
710
+ addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
711
+
712
+ // PARSING
713
+
714
+ addRegexToken('Y', matchSigned);
715
+ addRegexToken('YY', match1to2, match2);
716
+ addRegexToken('YYYY', match1to4, match4);
717
+ addRegexToken('YYYYY', match1to6, match6);
718
+ addRegexToken('YYYYYY', match1to6, match6);
719
+
720
+ addParseToken(['YYYYY', 'YYYYYY'], YEAR);
721
+ addParseToken('YYYY', function (input, array) {
722
+ array[YEAR] =
723
+ input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
724
+ });
725
+ addParseToken('YY', function (input, array) {
726
+ array[YEAR] = hooks.parseTwoDigitYear(input);
727
+ });
728
+ addParseToken('Y', function (input, array) {
729
+ array[YEAR] = parseInt(input, 10);
730
+ });
731
+
732
+ // HELPERS
733
+
734
+ function daysInYear(year) {
735
+ return isLeapYear(year) ? 366 : 365;
688
736
  }
689
737
 
690
- function toInt(argumentForCoercion) {
691
- var coercedNumber = +argumentForCoercion,
692
- value = 0;
738
+ // HOOKS
693
739
 
694
- if (coercedNumber !== 0 && isFinite(coercedNumber)) {
695
- value = absFloor(coercedNumber);
696
- }
740
+ hooks.parseTwoDigitYear = function (input) {
741
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
742
+ };
697
743
 
698
- return value;
744
+ // MOMENTS
745
+
746
+ var getSetYear = makeGetSet('FullYear', true);
747
+
748
+ function getIsLeapYear() {
749
+ return isLeapYear(this.year());
699
750
  }
700
751
 
701
752
  function makeGetSet(unit, keepTime) {
@@ -705,35 +756,81 @@ function makeGetSet(unit, keepTime) {
705
756
  hooks.updateOffset(this, keepTime);
706
757
  return this;
707
758
  } else {
708
- return get(this, unit);
759
+ return get$2(this, unit);
709
760
  }
710
761
  };
711
762
  }
712
763
 
713
- function get(mom, unit) {
714
- return mom.isValid()
715
- ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
716
- : NaN;
764
+ function get$2(mom, unit) {
765
+ if (!mom.isValid()) {
766
+ return NaN;
767
+ }
768
+
769
+ var d = mom._d,
770
+ isUTC = mom._isUTC;
771
+
772
+ switch (unit) {
773
+ case 'Milliseconds':
774
+ return isUTC ? d.getUTCMilliseconds() : d.getMilliseconds();
775
+ case 'Seconds':
776
+ return isUTC ? d.getUTCSeconds() : d.getSeconds();
777
+ case 'Minutes':
778
+ return isUTC ? d.getUTCMinutes() : d.getMinutes();
779
+ case 'Hours':
780
+ return isUTC ? d.getUTCHours() : d.getHours();
781
+ case 'Date':
782
+ return isUTC ? d.getUTCDate() : d.getDate();
783
+ case 'Day':
784
+ return isUTC ? d.getUTCDay() : d.getDay();
785
+ case 'Month':
786
+ return isUTC ? d.getUTCMonth() : d.getMonth();
787
+ case 'FullYear':
788
+ return isUTC ? d.getUTCFullYear() : d.getFullYear();
789
+ default:
790
+ return NaN; // Just in case
791
+ }
717
792
  }
718
793
 
719
794
  function set$1(mom, unit, value) {
720
- if (mom.isValid() && !isNaN(value)) {
721
- if (
722
- unit === 'FullYear' &&
723
- isLeapYear(mom.year()) &&
724
- mom.month() === 1 &&
725
- mom.date() === 29
726
- ) {
727
- value = toInt(value);
728
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
729
- value,
730
- mom.month(),
731
- daysInMonth(value, mom.month())
732
- );
733
- } else {
734
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
735
- }
795
+ var d, isUTC, year, month, date;
796
+
797
+ if (!mom.isValid() || isNaN(value)) {
798
+ return;
736
799
  }
800
+
801
+ d = mom._d;
802
+ isUTC = mom._isUTC;
803
+
804
+ switch (unit) {
805
+ case 'Milliseconds':
806
+ return void (isUTC
807
+ ? d.setUTCMilliseconds(value)
808
+ : d.setMilliseconds(value));
809
+ case 'Seconds':
810
+ return void (isUTC ? d.setUTCSeconds(value) : d.setSeconds(value));
811
+ case 'Minutes':
812
+ return void (isUTC ? d.setUTCMinutes(value) : d.setMinutes(value));
813
+ case 'Hours':
814
+ return void (isUTC ? d.setUTCHours(value) : d.setHours(value));
815
+ case 'Date':
816
+ return void (isUTC ? d.setUTCDate(value) : d.setDate(value));
817
+ // case 'Day': // Not real
818
+ // return void (isUTC ? d.setUTCDay(value) : d.setDay(value));
819
+ // case 'Month': // Not used because we need to pass two variables
820
+ // return void (isUTC ? d.setUTCMonth(value) : d.setMonth(value));
821
+ case 'FullYear':
822
+ break; // See below ...
823
+ default:
824
+ return; // Just in case
825
+ }
826
+
827
+ year = value;
828
+ month = mom.month();
829
+ date = mom.date();
830
+ date = date === 29 && month === 1 && !isLeapYear(year) ? 28 : date;
831
+ void (isUTC
832
+ ? d.setUTCFullYear(year, month, date)
833
+ : d.setFullYear(year, month, date));
737
834
  }
738
835
 
739
836
  // MOMENTS
@@ -764,108 +861,7 @@ function stringSet(units, value) {
764
861
  return this;
765
862
  }
766
863
 
767
- var match1 = /\d/, // 0 - 9
768
- match2 = /\d\d/, // 00 - 99
769
- match3 = /\d{3}/, // 000 - 999
770
- match4 = /\d{4}/, // 0000 - 9999
771
- match6 = /[+-]?\d{6}/, // -999999 - 999999
772
- match1to2 = /\d\d?/, // 0 - 99
773
- match3to4 = /\d\d\d\d?/, // 999 - 9999
774
- match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
775
- match1to3 = /\d{1,3}/, // 0 - 999
776
- match1to4 = /\d{1,4}/, // 0 - 9999
777
- match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
778
- matchUnsigned = /\d+/, // 0 - inf
779
- matchSigned = /[+-]?\d+/, // -inf - inf
780
- matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
781
- matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
782
- matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
783
- // any word (or two) characters or numbers including two/three word month in arabic.
784
- // includes scottish gaelic two word and hyphenated months
785
- matchWord =
786
- /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
787
- regexes;
788
-
789
- regexes = {};
790
-
791
- function addRegexToken(token, regex, strictRegex) {
792
- regexes[token] = isFunction(regex)
793
- ? regex
794
- : function (isStrict, localeData) {
795
- return isStrict && strictRegex ? strictRegex : regex;
796
- };
797
- }
798
-
799
- function getParseRegexForToken(token, config) {
800
- if (!hasOwnProp(regexes, token)) {
801
- return new RegExp(unescapeFormat(token));
802
- }
803
-
804
- return regexes[token](config._strict, config._locale);
805
- }
806
-
807
- // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
808
- function unescapeFormat(s) {
809
- return regexEscape(
810
- s
811
- .replace('\\', '')
812
- .replace(
813
- /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
814
- function (matched, p1, p2, p3, p4) {
815
- return p1 || p2 || p3 || p4;
816
- }
817
- )
818
- );
819
- }
820
-
821
- function regexEscape(s) {
822
- return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
823
- }
824
-
825
- var tokens = {};
826
-
827
- function addParseToken(token, callback) {
828
- var i,
829
- func = callback,
830
- tokenLen;
831
- if (typeof token === 'string') {
832
- token = [token];
833
- }
834
- if (isNumber(callback)) {
835
- func = function (input, array) {
836
- array[callback] = toInt(input);
837
- };
838
- }
839
- tokenLen = token.length;
840
- for (i = 0; i < tokenLen; i++) {
841
- tokens[token[i]] = func;
842
- }
843
- }
844
-
845
- function addWeekParseToken(token, callback) {
846
- addParseToken(token, function (input, array, config, token) {
847
- config._w = config._w || {};
848
- callback(input, config._w, config, token);
849
- });
850
- }
851
-
852
- function addTimeToArrayFromToken(token, input, config) {
853
- if (input != null && hasOwnProp(tokens, token)) {
854
- tokens[token](input, config._a, config, token);
855
- }
856
- }
857
-
858
- var YEAR = 0,
859
- MONTH = 1,
860
- DATE = 2,
861
- HOUR = 3,
862
- MINUTE = 4,
863
- SECOND = 5,
864
- MILLISECOND = 6,
865
- WEEK = 7,
866
- WEEKDAY = 8;
867
-
868
- function mod(n, x) {
864
+ function mod$1(n, x) {
869
865
  return ((n % x) + x) % x;
870
866
  }
871
867
 
@@ -890,7 +886,7 @@ function daysInMonth(year, month) {
890
886
  if (isNaN(year) || isNaN(month)) {
891
887
  return NaN;
892
888
  }
893
- var modMonth = mod(month, 12);
889
+ var modMonth = mod$1(month, 12);
894
890
  year += (month - modMonth) / 12;
895
891
  return modMonth === 1
896
892
  ? isLeapYear(year)
@@ -913,17 +909,9 @@ addFormatToken('MMMM', 0, 0, function (format) {
913
909
  return this.localeData().months(this, format);
914
910
  });
915
911
 
916
- // ALIASES
917
-
918
- addUnitAlias('month', 'M');
919
-
920
- // PRIORITY
921
-
922
- addUnitPriority('month', 8);
923
-
924
912
  // PARSING
925
913
 
926
- addRegexToken('M', match1to2);
914
+ addRegexToken('M', match1to2, match1to2NoLeadingZero);
927
915
  addRegexToken('MM', match1to2, match2);
928
916
  addRegexToken('MMM', function (isStrict, locale) {
929
917
  return locale.monthsShortRegex(isStrict);
@@ -956,7 +944,26 @@ var defaultLocaleMonths =
956
944
  'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
957
945
  MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
958
946
  defaultMonthsShortRegex = matchWord,
959
- defaultMonthsRegex = matchWord;
947
+ defaultMonthsRegex = matchWord,
948
+ monthsParseProperties = [
949
+ 'monthsParse',
950
+ 'longMonthsParse',
951
+ 'shortMonthsParse',
952
+ 'monthsRegex',
953
+ 'monthsShortRegex',
954
+ 'monthsStrictRegex',
955
+ 'monthsShortStrictRegex',
956
+ ];
957
+
958
+ function clearMonthsParseCache(locale, config) {
959
+ var i, prop;
960
+ for (i = 0; i < monthsParseProperties.length; i++) {
961
+ prop = monthsParseProperties[i];
962
+ if (!hasOwnProp(config, prop)) {
963
+ delete locale['_' + prop];
964
+ }
965
+ }
966
+ }
960
967
 
961
968
  function localeMonths(m, format) {
962
969
  if (!m) {
@@ -986,7 +993,7 @@ function localeMonthsShort(m, format) {
986
993
  ][m.month()];
987
994
  }
988
995
 
989
- function handleStrictParse(monthName, format, strict) {
996
+ function handleStrictParse$1(monthName, format, strict) {
990
997
  var i,
991
998
  ii,
992
999
  mom,
@@ -1037,7 +1044,7 @@ function localeMonthsParse(monthName, format, strict) {
1037
1044
  var i, mom, regex;
1038
1045
 
1039
1046
  if (this._monthsParseExact) {
1040
- return handleStrictParse.call(this, monthName, format, strict);
1047
+ return handleStrictParse$1.call(this, monthName, format, strict);
1041
1048
  }
1042
1049
 
1043
1050
  if (!this._monthsParse) {
@@ -1089,8 +1096,6 @@ function localeMonthsParse(monthName, format, strict) {
1089
1096
  // MOMENTS
1090
1097
 
1091
1098
  function setMonth(mom, value) {
1092
- var dayOfMonth;
1093
-
1094
1099
  if (!mom.isValid()) {
1095
1100
  // No op
1096
1101
  return mom;
@@ -1108,8 +1113,13 @@ function setMonth(mom, value) {
1108
1113
  }
1109
1114
  }
1110
1115
 
1111
- dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
1112
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
1116
+ var month = value,
1117
+ date = mom.date();
1118
+
1119
+ date = date < 29 ? date : Math.min(date, daysInMonth(mom.year(), month));
1120
+ void (mom._isUTC
1121
+ ? mom._d.setUTCMonth(month, date)
1122
+ : mom._d.setMonth(month, date));
1113
1123
  return mom;
1114
1124
  }
1115
1125
 
@@ -1119,7 +1129,7 @@ function getSetMonth(value) {
1119
1129
  hooks.updateOffset(this, true);
1120
1130
  return this;
1121
1131
  } else {
1122
- return get(this, 'Month');
1132
+ return get$2(this, 'Month');
1123
1133
  }
1124
1134
  }
1125
1135
 
@@ -1176,27 +1186,24 @@ function computeMonthsParse() {
1176
1186
  longPieces = [],
1177
1187
  mixedPieces = [],
1178
1188
  i,
1179
- mom;
1189
+ mom,
1190
+ shortP,
1191
+ longP;
1180
1192
  for (i = 0; i < 12; i++) {
1181
1193
  // make the regex if we don't have it already
1182
1194
  mom = createUTC([2000, i]);
1183
- shortPieces.push(this.monthsShort(mom, ''));
1184
- longPieces.push(this.months(mom, ''));
1185
- mixedPieces.push(this.months(mom, ''));
1186
- mixedPieces.push(this.monthsShort(mom, ''));
1195
+ shortP = regexEscape(this.monthsShort(mom, ''));
1196
+ longP = regexEscape(this.months(mom, ''));
1197
+ shortPieces.push(shortP);
1198
+ longPieces.push(longP);
1199
+ mixedPieces.push(longP);
1200
+ mixedPieces.push(shortP);
1187
1201
  }
1188
1202
  // Sorting makes sure if one month (or abbr) is a prefix of another it
1189
1203
  // will match the longer piece.
1190
1204
  shortPieces.sort(cmpLenRev);
1191
1205
  longPieces.sort(cmpLenRev);
1192
1206
  mixedPieces.sort(cmpLenRev);
1193
- for (i = 0; i < 12; i++) {
1194
- shortPieces[i] = regexEscape(shortPieces[i]);
1195
- longPieces[i] = regexEscape(longPieces[i]);
1196
- }
1197
- for (i = 0; i < 24; i++) {
1198
- mixedPieces[i] = regexEscape(mixedPieces[i]);
1199
- }
1200
1207
 
1201
1208
  this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
1202
1209
  this._monthsShortRegex = this._monthsRegex;
@@ -1212,239 +1219,14 @@ function computeMonthsParse() {
1212
1219
 
1213
1220
  // FORMATTING
1214
1221
 
1215
- addFormatToken('Y', 0, 0, function () {
1216
- var y = this.year();
1217
- return y <= 9999 ? zeroFill(y, 4) : '+' + y;
1222
+ addFormatToken('d', 0, 'do', 'day');
1223
+
1224
+ addFormatToken('dd', 0, 0, function (format) {
1225
+ return this.localeData().weekdaysMin(this, format);
1218
1226
  });
1219
1227
 
1220
- addFormatToken(0, ['YY', 2], 0, function () {
1221
- return this.year() % 100;
1222
- });
1223
-
1224
- addFormatToken(0, ['YYYY', 4], 0, 'year');
1225
- addFormatToken(0, ['YYYYY', 5], 0, 'year');
1226
- addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
1227
-
1228
- // ALIASES
1229
-
1230
- addUnitAlias('year', 'y');
1231
-
1232
- // PRIORITIES
1233
-
1234
- addUnitPriority('year', 1);
1235
-
1236
- // PARSING
1237
-
1238
- addRegexToken('Y', matchSigned);
1239
- addRegexToken('YY', match1to2, match2);
1240
- addRegexToken('YYYY', match1to4, match4);
1241
- addRegexToken('YYYYY', match1to6, match6);
1242
- addRegexToken('YYYYYY', match1to6, match6);
1243
-
1244
- addParseToken(['YYYYY', 'YYYYYY'], YEAR);
1245
- addParseToken('YYYY', function (input, array) {
1246
- array[YEAR] =
1247
- input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
1248
- });
1249
- addParseToken('YY', function (input, array) {
1250
- array[YEAR] = hooks.parseTwoDigitYear(input);
1251
- });
1252
- addParseToken('Y', function (input, array) {
1253
- array[YEAR] = parseInt(input, 10);
1254
- });
1255
-
1256
- // HELPERS
1257
-
1258
- function daysInYear(year) {
1259
- return isLeapYear(year) ? 366 : 365;
1260
- }
1261
-
1262
- // HOOKS
1263
-
1264
- hooks.parseTwoDigitYear = function (input) {
1265
- return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
1266
- };
1267
-
1268
- // MOMENTS
1269
-
1270
- var getSetYear = makeGetSet('FullYear', true);
1271
-
1272
- function getIsLeapYear() {
1273
- return isLeapYear(this.year());
1274
- }
1275
-
1276
- function createDate(y, m, d, h, M, s, ms) {
1277
- // can't just apply() to create a date:
1278
- // https://stackoverflow.com/q/181348
1279
- var date;
1280
- // the date constructor remaps years 0-99 to 1900-1999
1281
- if (y < 100 && y >= 0) {
1282
- // preserve leap years using a full 400 year cycle, then reset
1283
- date = new Date(y + 400, m, d, h, M, s, ms);
1284
- if (isFinite(date.getFullYear())) {
1285
- date.setFullYear(y);
1286
- }
1287
- } else {
1288
- date = new Date(y, m, d, h, M, s, ms);
1289
- }
1290
-
1291
- return date;
1292
- }
1293
-
1294
- function createUTCDate(y) {
1295
- var date, args;
1296
- // the Date.UTC function remaps years 0-99 to 1900-1999
1297
- if (y < 100 && y >= 0) {
1298
- args = Array.prototype.slice.call(arguments);
1299
- // preserve leap years using a full 400 year cycle, then reset
1300
- args[0] = y + 400;
1301
- date = new Date(Date.UTC.apply(null, args));
1302
- if (isFinite(date.getUTCFullYear())) {
1303
- date.setUTCFullYear(y);
1304
- }
1305
- } else {
1306
- date = new Date(Date.UTC.apply(null, arguments));
1307
- }
1308
-
1309
- return date;
1310
- }
1311
-
1312
- // start-of-first-week - start-of-year
1313
- function firstWeekOffset(year, dow, doy) {
1314
- var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
1315
- fwd = 7 + dow - doy,
1316
- // first-week day local weekday -- which local weekday is fwd
1317
- fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
1318
-
1319
- return -fwdlw + fwd - 1;
1320
- }
1321
-
1322
- // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1323
- function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
1324
- var localWeekday = (7 + weekday - dow) % 7,
1325
- weekOffset = firstWeekOffset(year, dow, doy),
1326
- dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
1327
- resYear,
1328
- resDayOfYear;
1329
-
1330
- if (dayOfYear <= 0) {
1331
- resYear = year - 1;
1332
- resDayOfYear = daysInYear(resYear) + dayOfYear;
1333
- } else if (dayOfYear > daysInYear(year)) {
1334
- resYear = year + 1;
1335
- resDayOfYear = dayOfYear - daysInYear(year);
1336
- } else {
1337
- resYear = year;
1338
- resDayOfYear = dayOfYear;
1339
- }
1340
-
1341
- return {
1342
- year: resYear,
1343
- dayOfYear: resDayOfYear,
1344
- };
1345
- }
1346
-
1347
- function weekOfYear(mom, dow, doy) {
1348
- var weekOffset = firstWeekOffset(mom.year(), dow, doy),
1349
- week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
1350
- resWeek,
1351
- resYear;
1352
-
1353
- if (week < 1) {
1354
- resYear = mom.year() - 1;
1355
- resWeek = week + weeksInYear(resYear, dow, doy);
1356
- } else if (week > weeksInYear(mom.year(), dow, doy)) {
1357
- resWeek = week - weeksInYear(mom.year(), dow, doy);
1358
- resYear = mom.year() + 1;
1359
- } else {
1360
- resYear = mom.year();
1361
- resWeek = week;
1362
- }
1363
-
1364
- return {
1365
- week: resWeek,
1366
- year: resYear,
1367
- };
1368
- }
1369
-
1370
- function weeksInYear(year, dow, doy) {
1371
- var weekOffset = firstWeekOffset(year, dow, doy),
1372
- weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
1373
- return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
1374
- }
1375
-
1376
- // FORMATTING
1377
-
1378
- addFormatToken('w', ['ww', 2], 'wo', 'week');
1379
- addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
1380
-
1381
- // ALIASES
1382
-
1383
- addUnitAlias('week', 'w');
1384
- addUnitAlias('isoWeek', 'W');
1385
-
1386
- // PRIORITIES
1387
-
1388
- addUnitPriority('week', 5);
1389
- addUnitPriority('isoWeek', 5);
1390
-
1391
- // PARSING
1392
-
1393
- addRegexToken('w', match1to2);
1394
- addRegexToken('ww', match1to2, match2);
1395
- addRegexToken('W', match1to2);
1396
- addRegexToken('WW', match1to2, match2);
1397
-
1398
- addWeekParseToken(
1399
- ['w', 'ww', 'W', 'WW'],
1400
- function (input, week, config, token) {
1401
- week[token.substr(0, 1)] = toInt(input);
1402
- }
1403
- );
1404
-
1405
- // HELPERS
1406
-
1407
- // LOCALES
1408
-
1409
- function localeWeek(mom) {
1410
- return weekOfYear(mom, this._week.dow, this._week.doy).week;
1411
- }
1412
-
1413
- var defaultLocaleWeek = {
1414
- dow: 0, // Sunday is the first day of the week.
1415
- doy: 6, // The week that contains Jan 6th is the first week of the year.
1416
- };
1417
-
1418
- function localeFirstDayOfWeek() {
1419
- return this._week.dow;
1420
- }
1421
-
1422
- function localeFirstDayOfYear() {
1423
- return this._week.doy;
1424
- }
1425
-
1426
- // MOMENTS
1427
-
1428
- function getSetWeek(input) {
1429
- var week = this.localeData().week(this);
1430
- return input == null ? week : this.add((input - week) * 7, 'd');
1431
- }
1432
-
1433
- function getSetISOWeek(input) {
1434
- var week = weekOfYear(this, 1, 4).week;
1435
- return input == null ? week : this.add((input - week) * 7, 'd');
1436
- }
1437
-
1438
- // FORMATTING
1439
-
1440
- addFormatToken('d', 0, 'do', 'day');
1441
-
1442
- addFormatToken('dd', 0, 0, function (format) {
1443
- return this.localeData().weekdaysMin(this, format);
1444
- });
1445
-
1446
- addFormatToken('ddd', 0, 0, function (format) {
1447
- return this.localeData().weekdaysShort(this, format);
1228
+ addFormatToken('ddd', 0, 0, function (format) {
1229
+ return this.localeData().weekdaysShort(this, format);
1448
1230
  });
1449
1231
 
1450
1232
  addFormatToken('dddd', 0, 0, function (format) {
@@ -1453,23 +1235,21 @@ addFormatToken('dddd', 0, 0, function (format) {
1453
1235
 
1454
1236
  addFormatToken('e', 0, 0, 'weekday');
1455
1237
  addFormatToken('E', 0, 0, 'isoWeekday');
1456
-
1457
- // ALIASES
1458
-
1459
- addUnitAlias('day', 'd');
1460
- addUnitAlias('weekday', 'e');
1461
- addUnitAlias('isoWeekday', 'E');
1462
-
1463
- // PRIORITY
1464
- addUnitPriority('day', 11);
1465
- addUnitPriority('weekday', 11);
1466
- addUnitPriority('isoWeekday', 11);
1238
+ addFormatToken('eHHmm', 0, 0, function () {
1239
+ return (
1240
+ '' +
1241
+ this.weekday() +
1242
+ zeroFill(this.hours(), 2) +
1243
+ zeroFill(this.minutes(), 2)
1244
+ );
1245
+ });
1467
1246
 
1468
1247
  // PARSING
1469
1248
 
1470
1249
  addRegexToken('d', match1to2);
1471
1250
  addRegexToken('e', match1to2);
1472
1251
  addRegexToken('E', match1to2);
1252
+ addRegexToken('eHHmm', match5to6);
1473
1253
  addRegexToken('dd', function (isStrict, locale) {
1474
1254
  return locale.weekdaysMinRegex(isStrict);
1475
1255
  });
@@ -1494,6 +1274,14 @@ addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
1494
1274
  week[token] = toInt(input);
1495
1275
  });
1496
1276
 
1277
+ addWeekParseToken('eHHmm', function (input, week, config) {
1278
+ var weekdayEnd = input.length - 4;
1279
+
1280
+ week.e = toInt(input.substr(0, weekdayEnd));
1281
+ config._a[HOUR] = toInt(input.substr(weekdayEnd, 2));
1282
+ config._a[MINUTE] = toInt(input.substr(weekdayEnd + 2));
1283
+ });
1284
+
1497
1285
  // HELPERS
1498
1286
 
1499
1287
  function parseWeekday(input, locale) {
@@ -1531,7 +1319,29 @@ var defaultLocaleWeekdays =
1531
1319
  defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
1532
1320
  defaultWeekdaysRegex = matchWord,
1533
1321
  defaultWeekdaysShortRegex = matchWord,
1534
- defaultWeekdaysMinRegex = matchWord;
1322
+ defaultWeekdaysMinRegex = matchWord,
1323
+ weekdaysParseProperties = [
1324
+ 'weekdaysParse',
1325
+ 'fullWeekdaysParse',
1326
+ 'shortWeekdaysParse',
1327
+ 'minWeekdaysParse',
1328
+ 'weekdaysRegex',
1329
+ 'weekdaysShortRegex',
1330
+ 'weekdaysMinRegex',
1331
+ 'weekdaysStrictRegex',
1332
+ 'weekdaysShortStrictRegex',
1333
+ 'weekdaysMinStrictRegex',
1334
+ ];
1335
+
1336
+ function clearWeekdaysParseCache(locale, config) {
1337
+ var i, prop;
1338
+ for (i = 0; i < weekdaysParseProperties.length; i++) {
1339
+ prop = weekdaysParseProperties[i];
1340
+ if (!hasOwnProp(config, prop)) {
1341
+ delete locale['_' + prop];
1342
+ }
1343
+ }
1344
+ }
1535
1345
 
1536
1346
  function localeWeekdays(m, format) {
1537
1347
  var weekdays = isArray(this._weekdays)
@@ -1544,27 +1354,27 @@ function localeWeekdays(m, format) {
1544
1354
  return m === true
1545
1355
  ? shiftWeekdays(weekdays, this._week.dow)
1546
1356
  : m
1547
- ? weekdays[m.day()]
1548
- : weekdays;
1357
+ ? weekdays[m.day()]
1358
+ : weekdays;
1549
1359
  }
1550
1360
 
1551
1361
  function localeWeekdaysShort(m) {
1552
1362
  return m === true
1553
1363
  ? shiftWeekdays(this._weekdaysShort, this._week.dow)
1554
1364
  : m
1555
- ? this._weekdaysShort[m.day()]
1556
- : this._weekdaysShort;
1365
+ ? this._weekdaysShort[m.day()]
1366
+ : this._weekdaysShort;
1557
1367
  }
1558
1368
 
1559
1369
  function localeWeekdaysMin(m) {
1560
1370
  return m === true
1561
1371
  ? shiftWeekdays(this._weekdaysMin, this._week.dow)
1562
1372
  : m
1563
- ? this._weekdaysMin[m.day()]
1564
- : this._weekdaysMin;
1373
+ ? this._weekdaysMin[m.day()]
1374
+ : this._weekdaysMin;
1565
1375
  }
1566
1376
 
1567
- function handleStrictParse$1(weekdayName, format, strict) {
1377
+ function handleStrictParse(weekdayName, format, strict) {
1568
1378
  var i,
1569
1379
  ii,
1570
1380
  mom,
@@ -1641,7 +1451,7 @@ function localeWeekdaysParse(weekdayName, format, strict) {
1641
1451
  var i, mom, regex;
1642
1452
 
1643
1453
  if (this._weekdaysParseExact) {
1644
- return handleStrictParse$1.call(this, weekdayName, format, strict);
1454
+ return handleStrictParse.call(this, weekdayName, format, strict);
1645
1455
  }
1646
1456
 
1647
1457
  if (!this._weekdaysParse) {
@@ -1710,7 +1520,8 @@ function getSetDayOfWeek(input) {
1710
1520
  if (!this.isValid()) {
1711
1521
  return input != null ? this : NaN;
1712
1522
  }
1713
- var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
1523
+
1524
+ var day = get$2(this, 'Day');
1714
1525
  if (input != null) {
1715
1526
  input = parseWeekday(input, this.localeData());
1716
1527
  return this.add(input - day, 'd');
@@ -1764,96 +1575,471 @@ function weekdaysRegex(isStrict) {
1764
1575
  }
1765
1576
  }
1766
1577
 
1767
- function weekdaysShortRegex(isStrict) {
1768
- if (this._weekdaysParseExact) {
1769
- if (!hasOwnProp(this, '_weekdaysRegex')) {
1770
- computeWeekdaysParse.call(this);
1771
- }
1772
- if (isStrict) {
1773
- return this._weekdaysShortStrictRegex;
1774
- } else {
1775
- return this._weekdaysShortRegex;
1776
- }
1777
- } else {
1778
- if (!hasOwnProp(this, '_weekdaysShortRegex')) {
1779
- this._weekdaysShortRegex = defaultWeekdaysShortRegex;
1780
- }
1781
- return this._weekdaysShortStrictRegex && isStrict
1782
- ? this._weekdaysShortStrictRegex
1783
- : this._weekdaysShortRegex;
1578
+ function weekdaysShortRegex(isStrict) {
1579
+ if (this._weekdaysParseExact) {
1580
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
1581
+ computeWeekdaysParse.call(this);
1582
+ }
1583
+ if (isStrict) {
1584
+ return this._weekdaysShortStrictRegex;
1585
+ } else {
1586
+ return this._weekdaysShortRegex;
1587
+ }
1588
+ } else {
1589
+ if (!hasOwnProp(this, '_weekdaysShortRegex')) {
1590
+ this._weekdaysShortRegex = defaultWeekdaysShortRegex;
1591
+ }
1592
+ return this._weekdaysShortStrictRegex && isStrict
1593
+ ? this._weekdaysShortStrictRegex
1594
+ : this._weekdaysShortRegex;
1595
+ }
1596
+ }
1597
+
1598
+ function weekdaysMinRegex(isStrict) {
1599
+ if (this._weekdaysParseExact) {
1600
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
1601
+ computeWeekdaysParse.call(this);
1602
+ }
1603
+ if (isStrict) {
1604
+ return this._weekdaysMinStrictRegex;
1605
+ } else {
1606
+ return this._weekdaysMinRegex;
1607
+ }
1608
+ } else {
1609
+ if (!hasOwnProp(this, '_weekdaysMinRegex')) {
1610
+ this._weekdaysMinRegex = defaultWeekdaysMinRegex;
1611
+ }
1612
+ return this._weekdaysMinStrictRegex && isStrict
1613
+ ? this._weekdaysMinStrictRegex
1614
+ : this._weekdaysMinRegex;
1615
+ }
1616
+ }
1617
+
1618
+ function computeWeekdaysParse() {
1619
+ function cmpLenRev(a, b) {
1620
+ return b.length - a.length;
1621
+ }
1622
+
1623
+ var minPieces = [],
1624
+ shortPieces = [],
1625
+ longPieces = [],
1626
+ mixedPieces = [],
1627
+ i,
1628
+ mom,
1629
+ minp,
1630
+ shortp,
1631
+ longp;
1632
+ for (i = 0; i < 7; i++) {
1633
+ // make the regex if we don't have it already
1634
+ mom = createUTC([2000, 1]).day(i);
1635
+ minp = regexEscape(this.weekdaysMin(mom, ''));
1636
+ shortp = regexEscape(this.weekdaysShort(mom, ''));
1637
+ longp = regexEscape(this.weekdays(mom, ''));
1638
+ minPieces.push(minp);
1639
+ shortPieces.push(shortp);
1640
+ longPieces.push(longp);
1641
+ mixedPieces.push(minp);
1642
+ mixedPieces.push(shortp);
1643
+ mixedPieces.push(longp);
1644
+ }
1645
+ // Sorting makes sure if one weekday (or abbr) is a prefix of another it
1646
+ // will match the longer piece.
1647
+ minPieces.sort(cmpLenRev);
1648
+ shortPieces.sort(cmpLenRev);
1649
+ longPieces.sort(cmpLenRev);
1650
+ mixedPieces.sort(cmpLenRev);
1651
+
1652
+ this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
1653
+ this._weekdaysShortRegex = this._weekdaysRegex;
1654
+ this._weekdaysMinRegex = this._weekdaysRegex;
1655
+
1656
+ this._weekdaysStrictRegex = new RegExp(
1657
+ '^(' + longPieces.join('|') + ')',
1658
+ 'i'
1659
+ );
1660
+ this._weekdaysShortStrictRegex = new RegExp(
1661
+ '^(' + shortPieces.join('|') + ')',
1662
+ 'i'
1663
+ );
1664
+ this._weekdaysMinStrictRegex = new RegExp(
1665
+ '^(' + minPieces.join('|') + ')',
1666
+ 'i'
1667
+ );
1668
+ }
1669
+
1670
+ function set(config) {
1671
+ var prop, i;
1672
+ clearMonthsParseCache(this, config);
1673
+ clearWeekdaysParseCache(this, config);
1674
+ for (i in config) {
1675
+ if (hasOwnProp(config, i)) {
1676
+ prop = config[i];
1677
+ if (isFunction(prop)) {
1678
+ this[i] = prop;
1679
+ } else {
1680
+ this['_' + i] = prop;
1681
+ }
1682
+ }
1683
+ }
1684
+ this._config = config;
1685
+ // Lenient ordinal parsing accepts just a number in addition to
1686
+ // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
1687
+ // TODO: Remove "ordinalParse" fallback in next major release.
1688
+ this._dayOfMonthOrdinalParseLenient = new RegExp(
1689
+ (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
1690
+ '|' +
1691
+ /\d{1,2}/.source
1692
+ );
1693
+ }
1694
+
1695
+ function mergeConfigs(parentConfig, childConfig) {
1696
+ var res = extend({}, parentConfig),
1697
+ prop;
1698
+ for (prop in childConfig) {
1699
+ if (hasOwnProp(childConfig, prop)) {
1700
+ if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
1701
+ res[prop] = {};
1702
+ extend(res[prop], parentConfig[prop]);
1703
+ extend(res[prop], childConfig[prop]);
1704
+ } else if (childConfig[prop] != null) {
1705
+ res[prop] = childConfig[prop];
1706
+ } else {
1707
+ delete res[prop];
1708
+ }
1709
+ }
1710
+ }
1711
+ for (prop in parentConfig) {
1712
+ if (
1713
+ hasOwnProp(parentConfig, prop) &&
1714
+ !hasOwnProp(childConfig, prop) &&
1715
+ isObject(parentConfig[prop])
1716
+ ) {
1717
+ // make sure changes to properties don't modify parent config
1718
+ res[prop] = extend({}, res[prop]);
1719
+ }
1720
+ }
1721
+ return res;
1722
+ }
1723
+
1724
+ function Locale(config) {
1725
+ if (config != null) {
1726
+ this.set(config);
1727
+ }
1728
+ }
1729
+
1730
+ var keys;
1731
+
1732
+ if (Object.keys) {
1733
+ keys = Object.keys;
1734
+ } else {
1735
+ keys = function (obj) {
1736
+ var i,
1737
+ res = [];
1738
+ for (i in obj) {
1739
+ if (hasOwnProp(obj, i)) {
1740
+ res.push(i);
1741
+ }
1742
+ }
1743
+ return res;
1744
+ };
1745
+ }
1746
+
1747
+ var defaultCalendar = {
1748
+ sameDay: '[Today at] LT',
1749
+ nextDay: '[Tomorrow at] LT',
1750
+ nextWeek: 'dddd [at] LT',
1751
+ lastDay: '[Yesterday at] LT',
1752
+ lastWeek: '[Last] dddd [at] LT',
1753
+ sameElse: 'L',
1754
+ };
1755
+
1756
+ function calendar$1(key, mom, now) {
1757
+ var output = this._calendar[key] || this._calendar['sameElse'];
1758
+ return isFunction(output) ? output.call(mom, now) : output;
1759
+ }
1760
+
1761
+ var defaultLongDateFormat = {
1762
+ LTS: 'h:mm:ss A',
1763
+ LT: 'h:mm A',
1764
+ L: 'MM/DD/YYYY',
1765
+ LL: 'MMMM D, YYYY',
1766
+ LLL: 'MMMM D, YYYY h:mm A',
1767
+ LLLL: 'dddd, MMMM D, YYYY h:mm A',
1768
+ };
1769
+
1770
+ function longDateFormat(key) {
1771
+ var format = this._longDateFormat[key],
1772
+ formatUpper = this._longDateFormat[key.toUpperCase()],
1773
+ formatCache = this._longDateFormatCache;
1774
+
1775
+ if (format || !formatUpper) {
1776
+ return format;
1777
+ }
1778
+
1779
+ if (
1780
+ formatCache &&
1781
+ formatCache[key] &&
1782
+ formatCache[key].formatUpper === formatUpper
1783
+ ) {
1784
+ return formatCache[key].format;
1785
+ }
1786
+
1787
+ format = formatUpper
1788
+ .match(formattingTokens)
1789
+ .map(function (tok) {
1790
+ if (
1791
+ tok === 'MMMM' ||
1792
+ tok === 'MM' ||
1793
+ tok === 'DD' ||
1794
+ tok === 'dddd'
1795
+ ) {
1796
+ return tok.slice(1);
1797
+ }
1798
+ return tok;
1799
+ })
1800
+ .join('');
1801
+
1802
+ if (!formatCache) {
1803
+ formatCache = this._longDateFormatCache = {};
1804
+ }
1805
+ formatCache[key] = {
1806
+ formatUpper: formatUpper,
1807
+ format: format,
1808
+ };
1809
+ return format;
1810
+ }
1811
+
1812
+ var defaultInvalidDate = 'Invalid date';
1813
+
1814
+ function invalidDate() {
1815
+ return this._invalidDate;
1816
+ }
1817
+
1818
+ var defaultOrdinal = '%d',
1819
+ defaultDayOfMonthOrdinalParse = /\d{1,2}/;
1820
+
1821
+ function ordinal(number) {
1822
+ return this._ordinal.replace('%d', number);
1823
+ }
1824
+
1825
+ var defaultRelativeTime = {
1826
+ future: 'in %s',
1827
+ past: '%s ago',
1828
+ s: 'a few seconds',
1829
+ ss: '%d seconds',
1830
+ m: 'a minute',
1831
+ mm: '%d minutes',
1832
+ h: 'an hour',
1833
+ hh: '%d hours',
1834
+ d: 'a day',
1835
+ dd: '%d days',
1836
+ w: 'a week',
1837
+ ww: '%d weeks',
1838
+ M: 'a month',
1839
+ MM: '%d months',
1840
+ y: 'a year',
1841
+ yy: '%d years',
1842
+ };
1843
+
1844
+ function relativeTimeWithoutPostformat(
1845
+ number,
1846
+ withoutSuffix,
1847
+ string,
1848
+ isFuture
1849
+ ) {
1850
+ var output = this._relativeTime[string];
1851
+ return isFunction(output)
1852
+ ? output(number, withoutSuffix, string, isFuture)
1853
+ : output.replace(/%d/i, number);
1854
+ }
1855
+
1856
+ function relativeTime$1(number, withoutSuffix, string, isFuture) {
1857
+ return this.postformat(
1858
+ relativeTimeWithoutPostformat.call(
1859
+ this,
1860
+ number,
1861
+ withoutSuffix,
1862
+ string,
1863
+ isFuture
1864
+ )
1865
+ );
1866
+ }
1867
+
1868
+ function pastFutureWithoutPostformat(diff, output) {
1869
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
1870
+ return isFunction(format) ? format(output) : format.replace(/%s/i, output);
1871
+ }
1872
+
1873
+ function pastFuture(diff, output) {
1874
+ return this.postformat(
1875
+ pastFutureWithoutPostformat.call(this, diff, output)
1876
+ );
1877
+ }
1878
+
1879
+ function createDate(y, m, d, h, M, s, ms) {
1880
+ // can't just apply() to create a date:
1881
+ // https://stackoverflow.com/q/181348
1882
+ var date;
1883
+ // the date constructor remaps years 0-99 to 1900-1999
1884
+ if (y < 100 && y >= 0) {
1885
+ // preserve leap years using a full 400 year cycle, then reset
1886
+ date = new Date(y + 400, m, d, h, M, s, ms);
1887
+ if (isFinite(date.getFullYear())) {
1888
+ date.setFullYear(y);
1889
+ }
1890
+ } else {
1891
+ date = new Date(y, m, d, h, M, s, ms);
1892
+ }
1893
+
1894
+ return date;
1895
+ }
1896
+
1897
+ function createUTCDate(y) {
1898
+ var date, args;
1899
+ // the Date.UTC function remaps years 0-99 to 1900-1999
1900
+ if (y < 100 && y >= 0) {
1901
+ args = Array.prototype.slice.call(arguments);
1902
+ // preserve leap years using a full 400 year cycle, then reset
1903
+ args[0] = y + 400;
1904
+ date = new Date(Date.UTC.apply(null, args));
1905
+ if (isFinite(date.getUTCFullYear())) {
1906
+ date.setUTCFullYear(y);
1907
+ }
1908
+ } else {
1909
+ date = new Date(Date.UTC.apply(null, arguments));
1910
+ }
1911
+
1912
+ return date;
1913
+ }
1914
+
1915
+ // start-of-first-week - start-of-year
1916
+ function firstWeekOffset(year, dow, doy) {
1917
+ var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
1918
+ fwd = 7 + dow - doy,
1919
+ // first-week day local weekday -- which local weekday is fwd
1920
+ fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
1921
+
1922
+ return -fwdlw + fwd - 1;
1923
+ }
1924
+
1925
+ // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1926
+ function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
1927
+ var localWeekday = (7 + weekday - dow) % 7,
1928
+ weekOffset = firstWeekOffset(year, dow, doy),
1929
+ dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
1930
+ resYear,
1931
+ resDayOfYear;
1932
+
1933
+ if (dayOfYear <= 0) {
1934
+ resYear = year - 1;
1935
+ resDayOfYear = daysInYear(resYear) + dayOfYear;
1936
+ } else if (dayOfYear > daysInYear(year)) {
1937
+ resYear = year + 1;
1938
+ resDayOfYear = dayOfYear - daysInYear(year);
1939
+ } else {
1940
+ resYear = year;
1941
+ resDayOfYear = dayOfYear;
1942
+ }
1943
+
1944
+ return {
1945
+ year: resYear,
1946
+ dayOfYear: resDayOfYear,
1947
+ };
1948
+ }
1949
+
1950
+ function weekOfYearFromDayOfYear(year, dayOfYear, dow, doy) {
1951
+ var weekOffset = firstWeekOffset(year, dow, doy),
1952
+ week = Math.floor((dayOfYear - weekOffset - 1) / 7) + 1,
1953
+ resWeek,
1954
+ resYear;
1955
+
1956
+ if (week < 1) {
1957
+ resYear = year - 1;
1958
+ resWeek = week + weeksInYear(resYear, dow, doy);
1959
+ } else if (week > weeksInYear(year, dow, doy)) {
1960
+ resWeek = week - weeksInYear(year, dow, doy);
1961
+ resYear = year + 1;
1962
+ } else {
1963
+ resYear = year;
1964
+ resWeek = week;
1965
+ }
1966
+
1967
+ return {
1968
+ week: resWeek,
1969
+ year: resYear,
1970
+ };
1971
+ }
1972
+
1973
+ function weekOfYear(mom, dow, doy) {
1974
+ return weekOfYearFromDayOfYear(mom.year(), mom.dayOfYear(), dow, doy);
1975
+ }
1976
+
1977
+ function weekOfYearFromDate(year, month, date, dow, doy) {
1978
+ var dayOfYear =
1979
+ Math.round(
1980
+ (createUTCDate(year, month, date) - createUTCDate(year, 0, 1)) /
1981
+ 864e5
1982
+ ) + 1;
1983
+
1984
+ return weekOfYearFromDayOfYear(year, dayOfYear, dow, doy);
1985
+ }
1986
+
1987
+ function weeksInYear(year, dow, doy) {
1988
+ var weekOffset = firstWeekOffset(year, dow, doy),
1989
+ weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
1990
+ return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
1991
+ }
1992
+
1993
+ // FORMATTING
1994
+
1995
+ addFormatToken('w', ['ww', 2], 'wo', 'week');
1996
+ addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
1997
+
1998
+ // PARSING
1999
+
2000
+ addRegexToken('w', match1to2, match1to2NoLeadingZero);
2001
+ addRegexToken('ww', match1to2, match2);
2002
+ addRegexToken('W', match1to2, match1to2NoLeadingZero);
2003
+ addRegexToken('WW', match1to2, match2);
2004
+
2005
+ addWeekParseToken(
2006
+ ['w', 'ww', 'W', 'WW'],
2007
+ function (input, week, config, token) {
2008
+ week[token.substr(0, 1)] = toInt(input);
1784
2009
  }
2010
+ );
2011
+
2012
+ // HELPERS
2013
+
2014
+ // LOCALES
2015
+
2016
+ function localeWeek(mom) {
2017
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
1785
2018
  }
1786
2019
 
1787
- function weekdaysMinRegex(isStrict) {
1788
- if (this._weekdaysParseExact) {
1789
- if (!hasOwnProp(this, '_weekdaysRegex')) {
1790
- computeWeekdaysParse.call(this);
1791
- }
1792
- if (isStrict) {
1793
- return this._weekdaysMinStrictRegex;
1794
- } else {
1795
- return this._weekdaysMinRegex;
1796
- }
1797
- } else {
1798
- if (!hasOwnProp(this, '_weekdaysMinRegex')) {
1799
- this._weekdaysMinRegex = defaultWeekdaysMinRegex;
1800
- }
1801
- return this._weekdaysMinStrictRegex && isStrict
1802
- ? this._weekdaysMinStrictRegex
1803
- : this._weekdaysMinRegex;
1804
- }
2020
+ var defaultLocaleWeek = {
2021
+ dow: 0, // Sunday is the first day of the week.
2022
+ doy: 6, // The week that contains Jan 6th is the first week of the year.
2023
+ };
2024
+
2025
+ function localeFirstDayOfWeek() {
2026
+ return this._week.dow;
1805
2027
  }
1806
2028
 
1807
- function computeWeekdaysParse() {
1808
- function cmpLenRev(a, b) {
1809
- return b.length - a.length;
1810
- }
2029
+ function localeFirstDayOfYear() {
2030
+ return this._week.doy;
2031
+ }
1811
2032
 
1812
- var minPieces = [],
1813
- shortPieces = [],
1814
- longPieces = [],
1815
- mixedPieces = [],
1816
- i,
1817
- mom,
1818
- minp,
1819
- shortp,
1820
- longp;
1821
- for (i = 0; i < 7; i++) {
1822
- // make the regex if we don't have it already
1823
- mom = createUTC([2000, 1]).day(i);
1824
- minp = regexEscape(this.weekdaysMin(mom, ''));
1825
- shortp = regexEscape(this.weekdaysShort(mom, ''));
1826
- longp = regexEscape(this.weekdays(mom, ''));
1827
- minPieces.push(minp);
1828
- shortPieces.push(shortp);
1829
- longPieces.push(longp);
1830
- mixedPieces.push(minp);
1831
- mixedPieces.push(shortp);
1832
- mixedPieces.push(longp);
1833
- }
1834
- // Sorting makes sure if one weekday (or abbr) is a prefix of another it
1835
- // will match the longer piece.
1836
- minPieces.sort(cmpLenRev);
1837
- shortPieces.sort(cmpLenRev);
1838
- longPieces.sort(cmpLenRev);
1839
- mixedPieces.sort(cmpLenRev);
2033
+ // MOMENTS
1840
2034
 
1841
- this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
1842
- this._weekdaysShortRegex = this._weekdaysRegex;
1843
- this._weekdaysMinRegex = this._weekdaysRegex;
2035
+ function getSetWeek(input) {
2036
+ var week = this.localeData().week(this);
2037
+ return input == null ? week : this.add((input - week) * 7, 'd');
2038
+ }
1844
2039
 
1845
- this._weekdaysStrictRegex = new RegExp(
1846
- '^(' + longPieces.join('|') + ')',
1847
- 'i'
1848
- );
1849
- this._weekdaysShortStrictRegex = new RegExp(
1850
- '^(' + shortPieces.join('|') + ')',
1851
- 'i'
1852
- );
1853
- this._weekdaysMinStrictRegex = new RegExp(
1854
- '^(' + minPieces.join('|') + ')',
1855
- 'i'
1856
- );
2040
+ function getSetISOWeek(input) {
2041
+ var week = weekOfYear(this, 1, 4).week;
2042
+ return input == null ? week : this.add((input - week) * 7, 'd');
1857
2043
  }
1858
2044
 
1859
2045
  // FORMATTING
@@ -1909,13 +2095,6 @@ function meridiem(token, lowercase) {
1909
2095
  meridiem('a', true);
1910
2096
  meridiem('A', false);
1911
2097
 
1912
- // ALIASES
1913
-
1914
- addUnitAlias('hour', 'h');
1915
-
1916
- // PRIORITY
1917
- addUnitPriority('hour', 13);
1918
-
1919
2098
  // PARSING
1920
2099
 
1921
2100
  function matchMeridiem(isStrict, locale) {
@@ -1924,9 +2103,9 @@ function matchMeridiem(isStrict, locale) {
1924
2103
 
1925
2104
  addRegexToken('a', matchMeridiem);
1926
2105
  addRegexToken('A', matchMeridiem);
1927
- addRegexToken('H', match1to2);
1928
- addRegexToken('h', match1to2);
1929
- addRegexToken('k', match1to2);
2106
+ addRegexToken('H', match1to2, match1to2HasZero);
2107
+ addRegexToken('h', match1to2, match1to2NoLeadingZero);
2108
+ addRegexToken('k', match1to2, match1to2NoLeadingZero);
1930
2109
  addRegexToken('HH', match1to2, match2);
1931
2110
  addRegexToken('hh', match1to2, match2);
1932
2111
  addRegexToken('kk', match1to2, match2);
@@ -2075,33 +2254,49 @@ function chooseLocale(names) {
2075
2254
  }
2076
2255
 
2077
2256
  function isLocaleNameSane(name) {
2078
- // Prevent names that look like filesystem paths, i.e contain '/' or '\'
2079
- return name.match('^[^/\\\\]*$') != null;
2257
+ // Only canonical locale module names are safe to append to the require path.
2258
+ return typeof name === 'string' && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name);
2080
2259
  }
2081
2260
 
2082
2261
  function loadLocale(name) {
2083
2262
  var oldLocale = null,
2084
- aliasedRequire;
2263
+ aliasedRequire,
2264
+ normalizedName;
2265
+
2266
+ // Preserve exact custom locale names before trying the canonical built-in name.
2267
+ // Use hasOwnProp rather than a plain lookup so that names like "__proto__",
2268
+ // "constructor", or "prototype" can't resolve to an inherited Object.prototype
2269
+ // property instead of a real (or missing) locale entry.
2270
+ if (hasOwnProp(locales, name)) {
2271
+ return locales[name];
2272
+ }
2273
+
2274
+ normalizedName = normalizeLocale(name);
2275
+ if (hasOwnProp(locales, normalizedName)) {
2276
+ return locales[normalizedName];
2277
+ }
2278
+
2085
2279
  // TODO: Find a better way to register and load all the locales in Node
2086
2280
  if (
2087
- locales[name] === undefined &&
2088
2281
  typeof module !== 'undefined' &&
2089
2282
  module &&
2090
2283
  module.exports &&
2091
- isLocaleNameSane(name)
2284
+ isLocaleNameSane(normalizedName)
2092
2285
  ) {
2093
2286
  try {
2094
2287
  oldLocale = globalLocale._abbr;
2095
2288
  aliasedRequire = require;
2096
- aliasedRequire('./locale/' + name);
2289
+ aliasedRequire('./locale/' + normalizedName);
2097
2290
  getSetGlobalLocale(oldLocale);
2098
2291
  } catch (e) {
2099
2292
  // mark as not found to avoid repeating expensive file require call causing high CPU
2100
2293
  // when trying to find en-US, en_US, en-us for every format call
2101
- locales[name] = null; // null means not found
2294
+ locales[normalizedName] = null; // null means not found
2102
2295
  }
2103
2296
  }
2104
- return locales[name];
2297
+ if (hasOwnProp(locales, normalizedName)) {
2298
+ return locales[normalizedName];
2299
+ }
2105
2300
  }
2106
2301
 
2107
2302
  // This function will load locale and then set the global locale. If
@@ -2187,17 +2382,20 @@ function defineLocale(name, config) {
2187
2382
  }
2188
2383
 
2189
2384
  function updateLocale(name, config) {
2190
- if (config != null) {
2191
- var locale,
2192
- tmpLocale,
2193
- parentConfig = baseConfig;
2385
+ var locale,
2386
+ tmpLocale = loadLocale(name),
2387
+ parentConfig = baseConfig;
2194
2388
 
2389
+ if (tmpLocale != null) {
2390
+ name = tmpLocale._abbr;
2391
+ }
2392
+
2393
+ if (config != null) {
2195
2394
  if (locales[name] != null && locales[name].parentLocale != null) {
2196
2395
  // Update existing child locale in-place to avoid memory-leaks
2197
2396
  locales[name].set(mergeConfigs(locales[name]._config, config));
2198
2397
  } else {
2199
2398
  // MERGE
2200
- tmpLocale = loadLocale(name);
2201
2399
  if (tmpLocale != null) {
2202
2400
  parentConfig = tmpLocale._config;
2203
2401
  }
@@ -2268,21 +2466,21 @@ function checkOverflow(m) {
2268
2466
  a[MONTH] < 0 || a[MONTH] > 11
2269
2467
  ? MONTH
2270
2468
  : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
2271
- ? DATE
2272
- : a[HOUR] < 0 ||
2273
- a[HOUR] > 24 ||
2274
- (a[HOUR] === 24 &&
2275
- (a[MINUTE] !== 0 ||
2276
- a[SECOND] !== 0 ||
2277
- a[MILLISECOND] !== 0))
2278
- ? HOUR
2279
- : a[MINUTE] < 0 || a[MINUTE] > 59
2280
- ? MINUTE
2281
- : a[SECOND] < 0 || a[SECOND] > 59
2282
- ? SECOND
2283
- : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
2284
- ? MILLISECOND
2285
- : -1;
2469
+ ? DATE
2470
+ : a[HOUR] < 0 ||
2471
+ a[HOUR] > 24 ||
2472
+ (a[HOUR] === 24 &&
2473
+ (a[MINUTE] !== 0 ||
2474
+ a[SECOND] !== 0 ||
2475
+ a[MILLISECOND] !== 0))
2476
+ ? HOUR
2477
+ : a[MINUTE] < 0 || a[MINUTE] > 59
2478
+ ? MINUTE
2479
+ : a[SECOND] < 0 || a[SECOND] > 59
2480
+ ? SECOND
2481
+ : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
2482
+ ? MILLISECOND
2483
+ : -1;
2286
2484
 
2287
2485
  if (
2288
2486
  getParsingFlags(m)._overflowDayOfYear &&
@@ -2565,9 +2763,46 @@ function defaults(a, b, c) {
2565
2763
  return c;
2566
2764
  }
2567
2765
 
2568
- function currentDateArray(config) {
2766
+ function currentDateArray(config, now, forWeek) {
2767
+ var hadWeekContext = Object.prototype.hasOwnProperty.call(
2768
+ config,
2769
+ '_isDefaultDatePartsForWeek'
2770
+ ),
2771
+ weekContext = config._isDefaultDatePartsForWeek;
2772
+
2569
2773
  // hooks is actually the exported moment object
2570
- var nowValue = new Date(hooks.now());
2774
+ config._isDefaultDatePartsForWeek = !!forWeek;
2775
+ try {
2776
+ return hooks._getDefaultDateParts(config, now, forWeek);
2777
+ } finally {
2778
+ if (hadWeekContext) {
2779
+ config._isDefaultDatePartsForWeek = weekContext;
2780
+ } else {
2781
+ delete config._isDefaultDatePartsForWeek;
2782
+ }
2783
+ }
2784
+ }
2785
+
2786
+ function currentDateNow(config) {
2787
+ var now = config._defaultDatePartsNow;
2788
+
2789
+ if (!now) {
2790
+ return hooks.now();
2791
+ }
2792
+ if (!now.hasValue) {
2793
+ now.value = hooks.now();
2794
+ now.hasValue = true;
2795
+ }
2796
+ return now.value;
2797
+ }
2798
+
2799
+ // Internal hook for extensions that supply omitted calendar fields.
2800
+ function getDefaultDateParts(config, now, forWeek) {
2801
+ var useWeekDefaults = forWeek || config._isDefaultDatePartsForWeek,
2802
+ nowValue = useWeekDefaults ? createLocal(now) : new Date(now);
2803
+ if (useWeekDefaults) {
2804
+ return [nowValue.year(), nowValue.month(), nowValue.date()];
2805
+ }
2571
2806
  if (config._useUTC) {
2572
2807
  return [
2573
2808
  nowValue.getUTCFullYear(),
@@ -2578,6 +2813,8 @@ function currentDateArray(config) {
2578
2813
  return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
2579
2814
  }
2580
2815
 
2816
+ hooks._getDefaultDateParts = getDefaultDateParts;
2817
+
2581
2818
  // convert an array to a date.
2582
2819
  // the array should mirror the parameters below
2583
2820
  // note: all values past the year are optional and will default to the lowest possible value.
@@ -2586,24 +2823,34 @@ function configFromArray(config) {
2586
2823
  var i,
2587
2824
  date,
2588
2825
  input = [],
2826
+ now,
2589
2827
  currentDate,
2590
2828
  expectedWeekday,
2591
- yearToUse;
2829
+ yearToUse,
2830
+ dateIsDefaulted;
2592
2831
 
2593
2832
  if (config._d) {
2594
2833
  return;
2595
2834
  }
2596
2835
 
2597
- currentDate = currentDateArray(config);
2836
+ if (
2837
+ config._a[YEAR] == null ||
2838
+ config._a[MONTH] == null ||
2839
+ config._a[DATE] == null
2840
+ ) {
2841
+ now = currentDateNow(config);
2842
+ currentDate = currentDateArray(config, now);
2843
+ }
2598
2844
 
2599
2845
  //compute day of the year from weeks and weekdays
2600
2846
  if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
2601
- dayOfYearFromWeekInfo(config);
2847
+ dayOfYearFromWeekInfo(config, currentDateArray(config, now, true));
2602
2848
  }
2603
2849
 
2604
2850
  //if the day of the year is set, figure out what it is
2605
2851
  if (config._dayOfYear != null) {
2606
- yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
2852
+ yearToUse =
2853
+ config._a[YEAR] != null ? config._a[YEAR] : currentDate[YEAR];
2607
2854
 
2608
2855
  if (
2609
2856
  config._dayOfYear > daysInYear(yearToUse) ||
@@ -2617,6 +2864,11 @@ function configFromArray(config) {
2617
2864
  config._a[DATE] = date.getUTCDate();
2618
2865
  }
2619
2866
 
2867
+ dateIsDefaulted =
2868
+ config._a[YEAR] == null ||
2869
+ config._a[MONTH] == null ||
2870
+ config._a[DATE] == null;
2871
+
2620
2872
  // Default to current date.
2621
2873
  // * if no year, month, day of month are given, default to today
2622
2874
  // * if day of month is given, default month and year
@@ -2665,13 +2917,14 @@ function configFromArray(config) {
2665
2917
  if (
2666
2918
  config._w &&
2667
2919
  typeof config._w.d !== 'undefined' &&
2920
+ !dateIsDefaulted &&
2668
2921
  config._w.d !== expectedWeekday
2669
2922
  ) {
2670
2923
  getParsingFlags(config).weekdayMismatch = true;
2671
2924
  }
2672
2925
  }
2673
2926
 
2674
- function dayOfYearFromWeekInfo(config) {
2927
+ function dayOfYearFromWeekInfo(config, currentDate) {
2675
2928
  var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
2676
2929
 
2677
2930
  w = config._w;
@@ -2686,7 +2939,13 @@ function dayOfYearFromWeekInfo(config) {
2686
2939
  weekYear = defaults(
2687
2940
  w.GG,
2688
2941
  config._a[YEAR],
2689
- weekOfYear(createLocal(), 1, 4).year
2942
+ weekOfYearFromDate(
2943
+ currentDate[YEAR],
2944
+ currentDate[MONTH],
2945
+ currentDate[DATE],
2946
+ 1,
2947
+ 4
2948
+ ).year
2690
2949
  );
2691
2950
  week = defaults(w.W, 1);
2692
2951
  weekday = defaults(w.E, 1);
@@ -2697,7 +2956,13 @@ function dayOfYearFromWeekInfo(config) {
2697
2956
  dow = config._locale._week.dow;
2698
2957
  doy = config._locale._week.doy;
2699
2958
 
2700
- curWeek = weekOfYear(createLocal(), dow, doy);
2959
+ curWeek = weekOfYearFromDate(
2960
+ currentDate[YEAR],
2961
+ currentDate[MONTH],
2962
+ currentDate[DATE],
2963
+ dow,
2964
+ doy
2965
+ );
2701
2966
 
2702
2967
  weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
2703
2968
 
@@ -2863,6 +3128,7 @@ function configFromStringAndArray(config) {
2863
3128
  currentScore,
2864
3129
  validFormatFound,
2865
3130
  bestFormatIsValid = false,
3131
+ defaultDatePartsNow = {},
2866
3132
  configfLen = config._f.length;
2867
3133
 
2868
3134
  if (configfLen === 0) {
@@ -2878,10 +3144,11 @@ function configFromStringAndArray(config) {
2878
3144
  if (config._useUTC != null) {
2879
3145
  tempConfig._useUTC = config._useUTC;
2880
3146
  }
3147
+ tempConfig._defaultDatePartsNow = defaultDatePartsNow;
2881
3148
  tempConfig._f = config._f[i];
2882
3149
  configFromStringAndFormat(tempConfig);
2883
3150
 
2884
- if (isValid(tempConfig)) {
3151
+ if (isValid$2(tempConfig)) {
2885
3152
  validFormatFound = true;
2886
3153
  }
2887
3154
 
@@ -2951,7 +3218,7 @@ function prepareConfig(config) {
2951
3218
  config._locale = config._locale || getLocale(config._l);
2952
3219
 
2953
3220
  if (input === null || (format === undefined && input === '')) {
2954
- return createInvalid({ nullInput: true });
3221
+ return createInvalid$1({ nullInput: true });
2955
3222
  }
2956
3223
 
2957
3224
  if (typeof input === 'string') {
@@ -2970,7 +3237,7 @@ function prepareConfig(config) {
2970
3237
  configFromInput(config);
2971
3238
  }
2972
3239
 
2973
- if (!isValid(config)) {
3240
+ if (!isValid$2(config)) {
2974
3241
  config._d = null;
2975
3242
  }
2976
3243
 
@@ -3042,7 +3309,7 @@ var prototypeMin = deprecate(
3042
3309
  if (this.isValid() && other.isValid()) {
3043
3310
  return other < this ? this : other;
3044
3311
  } else {
3045
- return createInvalid();
3312
+ return createInvalid$1();
3046
3313
  }
3047
3314
  }
3048
3315
  ),
@@ -3053,7 +3320,7 @@ var prototypeMin = deprecate(
3053
3320
  if (this.isValid() && other.isValid()) {
3054
3321
  return other > this ? this : other;
3055
3322
  } else {
3056
- return createInvalid();
3323
+ return createInvalid$1();
3057
3324
  }
3058
3325
  }
3059
3326
  );
@@ -3071,9 +3338,20 @@ function pickBy(fn, moments) {
3071
3338
  if (!moments.length) {
3072
3339
  return createLocal();
3073
3340
  }
3074
- res = moments[0];
3075
- for (i = 1; i < moments.length; ++i) {
3076
- if (!moments[i].isValid() || moments[i][fn](res)) {
3341
+ for (i = 0; i < moments.length; ++i) {
3342
+ if (isMoment(moments[i])) {
3343
+ res = moments[i];
3344
+ break;
3345
+ }
3346
+ }
3347
+ if (!res) {
3348
+ return createInvalid$1();
3349
+ }
3350
+ for (++i; i < moments.length; ++i) {
3351
+ if (
3352
+ isMoment(moments[i]) &&
3353
+ (!moments[i].isValid() || moments[i][fn](res))
3354
+ ) {
3077
3355
  res = moments[i];
3078
3356
  }
3079
3357
  }
@@ -3144,7 +3422,7 @@ function isValid$1() {
3144
3422
  return this._isValid;
3145
3423
  }
3146
3424
 
3147
- function createInvalid$1() {
3425
+ function createInvalid() {
3148
3426
  return createDuration(NaN);
3149
3427
  }
3150
3428
 
@@ -3203,8 +3481,7 @@ function compareArrays(array1, array2, dontConvert) {
3203
3481
  i;
3204
3482
  for (i = 0; i < len; i++) {
3205
3483
  if (
3206
- (dontConvert && array1[i] !== array2[i]) ||
3207
- (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
3484
+ (toInt(array1[i]) !== toInt(array2[i]))
3208
3485
  ) {
3209
3486
  diffs++;
3210
3487
  }
@@ -3239,8 +3516,12 @@ offset('ZZ', '');
3239
3516
  addRegexToken('Z', matchShortOffset);
3240
3517
  addRegexToken('ZZ', matchShortOffset);
3241
3518
  addParseToken(['Z', 'ZZ'], function (input, array, config) {
3519
+ var offset = offsetFromString(matchShortOffset, input);
3242
3520
  config._useUTC = true;
3243
- config._tzm = offsetFromString(matchShortOffset, input);
3521
+ config._tzm = offset;
3522
+ if (offset === null) {
3523
+ getParsingFlags(config).invalidOffset = input;
3524
+ }
3244
3525
  });
3245
3526
 
3246
3527
  // HELPERS
@@ -3264,6 +3545,13 @@ function offsetFromString(matcher, string) {
3264
3545
  parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
3265
3546
  minutes = +(parts[1] * 60) + toInt(parts[2]);
3266
3547
 
3548
+ if (
3549
+ toInt(parts[2]) > 59 ||
3550
+ (parts[0] === '+' ? minutes > 14 * 60 : minutes > 12 * 60)
3551
+ ) {
3552
+ return null;
3553
+ }
3554
+
3267
3555
  return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
3268
3556
  }
3269
3557
 
@@ -3334,7 +3622,7 @@ function getSetOffset(input, keepLocalTime, keepMinutes) {
3334
3622
  }
3335
3623
  if (offset !== input) {
3336
3624
  if (!keepLocalTime || this._changeInProgress) {
3337
- addSubtract(
3625
+ addSubtract$1(
3338
3626
  this,
3339
3627
  createDuration(input - offset, 'm'),
3340
3628
  1,
@@ -3527,7 +3815,7 @@ function createDuration(input, key) {
3527
3815
  }
3528
3816
 
3529
3817
  createDuration.fn = Duration.prototype;
3530
- createDuration.invalid = createInvalid$1;
3818
+ createDuration.invalid = createInvalid;
3531
3819
 
3532
3820
  function parseIso(inp, sign) {
3533
3821
  // We'd normally use ~~inp for this, but unfortunately it also
@@ -3591,12 +3879,12 @@ function createAdder(direction, name) {
3591
3879
  }
3592
3880
 
3593
3881
  dur = createDuration(val, period);
3594
- addSubtract(this, dur, direction);
3882
+ addSubtract$1(this, dur, direction);
3595
3883
  return this;
3596
3884
  };
3597
3885
  }
3598
3886
 
3599
- function addSubtract(mom, duration, isAdding, updateOffset) {
3887
+ function addSubtract$1(mom, duration, isAdding, updateOffset) {
3600
3888
  var milliseconds = duration._milliseconds,
3601
3889
  days = absRound(duration._days),
3602
3890
  months = absRound(duration._months);
@@ -3609,10 +3897,10 @@ function addSubtract(mom, duration, isAdding, updateOffset) {
3609
3897
  updateOffset = updateOffset == null ? true : updateOffset;
3610
3898
 
3611
3899
  if (months) {
3612
- setMonth(mom, get(mom, 'Month') + months * isAdding);
3900
+ setMonth(mom, get$2(mom, 'Month') + months * isAdding);
3613
3901
  }
3614
3902
  if (days) {
3615
- set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
3903
+ set$1(mom, 'Date', get$2(mom, 'Date') + days * isAdding);
3616
3904
  }
3617
3905
  if (milliseconds) {
3618
3906
  mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
@@ -3622,8 +3910,8 @@ function addSubtract(mom, duration, isAdding, updateOffset) {
3622
3910
  }
3623
3911
  }
3624
3912
 
3625
- var add = createAdder(1, 'add'),
3626
- subtract = createAdder(-1, 'subtract');
3913
+ var add$1 = createAdder(1, 'add'),
3914
+ subtract$1 = createAdder(-1, 'subtract');
3627
3915
 
3628
3916
  function isString(input) {
3629
3917
  return typeof input === 'string' || input instanceof String;
@@ -3723,19 +4011,19 @@ function getCalendarFormat(myMoment, now) {
3723
4011
  return diff < -6
3724
4012
  ? 'sameElse'
3725
4013
  : diff < -1
3726
- ? 'lastWeek'
3727
- : diff < 0
3728
- ? 'lastDay'
3729
- : diff < 1
3730
- ? 'sameDay'
3731
- : diff < 2
3732
- ? 'nextDay'
3733
- : diff < 7
3734
- ? 'nextWeek'
3735
- : 'sameElse';
3736
- }
3737
-
3738
- function calendar$1(time, formats) {
4014
+ ? 'lastWeek'
4015
+ : diff < 0
4016
+ ? 'lastDay'
4017
+ : diff < 1
4018
+ ? 'sameDay'
4019
+ : diff < 2
4020
+ ? 'nextDay'
4021
+ : diff < 7
4022
+ ? 'nextWeek'
4023
+ : 'sameElse';
4024
+ }
4025
+
4026
+ function calendar(time, formats) {
3739
4027
  // Support for single parameter, formats only overload to the calendar function
3740
4028
  if (arguments.length === 1) {
3741
4029
  if (!arguments[0]) {
@@ -3765,7 +4053,7 @@ function calendar$1(time, formats) {
3765
4053
  );
3766
4054
  }
3767
4055
 
3768
- function clone() {
4056
+ function clone$1() {
3769
4057
  return new Moment(this);
3770
4058
  }
3771
4059
 
@@ -3921,7 +4209,7 @@ function toString() {
3921
4209
  return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
3922
4210
  }
3923
4211
 
3924
- function toISOString(keepOffset) {
4212
+ function toISOString$1(keepOffset) {
3925
4213
  if (!this.isValid()) {
3926
4214
  return null;
3927
4215
  }
@@ -4061,7 +4349,7 @@ var MS_PER_SECOND = 1000,
4061
4349
  MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
4062
4350
 
4063
4351
  // actual modulo - handles negative numbers (for dates before 1970):
4064
- function mod$1(dividend, divisor) {
4352
+ function mod(dividend, divisor) {
4065
4353
  return ((dividend % divisor) + divisor) % divisor;
4066
4354
  }
4067
4355
 
@@ -4128,18 +4416,18 @@ function startOf(units) {
4128
4416
  break;
4129
4417
  case 'hour':
4130
4418
  time = this._d.valueOf();
4131
- time -= mod$1(
4419
+ time -= mod(
4132
4420
  time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
4133
4421
  MS_PER_HOUR
4134
4422
  );
4135
4423
  break;
4136
4424
  case 'minute':
4137
4425
  time = this._d.valueOf();
4138
- time -= mod$1(time, MS_PER_MINUTE);
4426
+ time -= mod(time, MS_PER_MINUTE);
4139
4427
  break;
4140
4428
  case 'second':
4141
4429
  time = this._d.valueOf();
4142
- time -= mod$1(time, MS_PER_SECOND);
4430
+ time -= mod(time, MS_PER_SECOND);
4143
4431
  break;
4144
4432
  }
4145
4433
 
@@ -4196,7 +4484,7 @@ function endOf(units) {
4196
4484
  time = this._d.valueOf();
4197
4485
  time +=
4198
4486
  MS_PER_HOUR -
4199
- mod$1(
4487
+ mod(
4200
4488
  time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
4201
4489
  MS_PER_HOUR
4202
4490
  ) -
@@ -4204,11 +4492,11 @@ function endOf(units) {
4204
4492
  break;
4205
4493
  case 'minute':
4206
4494
  time = this._d.valueOf();
4207
- time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
4495
+ time += MS_PER_MINUTE - mod(time, MS_PER_MINUTE) - 1;
4208
4496
  break;
4209
4497
  case 'second':
4210
4498
  time = this._d.valueOf();
4211
- time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
4499
+ time += MS_PER_SECOND - mod(time, MS_PER_SECOND) - 1;
4212
4500
  break;
4213
4501
  }
4214
4502
 
@@ -4217,7 +4505,7 @@ function endOf(units) {
4217
4505
  return this;
4218
4506
  }
4219
4507
 
4220
- function valueOf() {
4508
+ function valueOf$1() {
4221
4509
  return this._d.valueOf() - (this._offset || 0) * 60000;
4222
4510
  }
4223
4511
 
@@ -4260,8 +4548,8 @@ function toJSON() {
4260
4548
  return this.isValid() ? this.toISOString() : null;
4261
4549
  }
4262
4550
 
4263
- function isValid$2() {
4264
- return isValid(this);
4551
+ function isValid() {
4552
+ return isValid$2(this);
4265
4553
  }
4266
4554
 
4267
4555
  function parsingFlags() {
@@ -4402,7 +4690,7 @@ function localeErasParse(eraName, format, strict) {
4402
4690
  }
4403
4691
 
4404
4692
  function localeErasConvertYear(era, year) {
4405
- var dir = era.since <= era.until ? +1 : -1;
4693
+ var dir = era.since <= era.until ? 1 : -1;
4406
4694
  if (year === undefined) {
4407
4695
  return hooks(era.since).year();
4408
4696
  } else {
@@ -4477,7 +4765,7 @@ function getEraYear() {
4477
4765
  val,
4478
4766
  eras = this.localeData().eras();
4479
4767
  for (i = 0, l = eras.length; i < l; ++i) {
4480
- dir = eras[i].since <= eras[i].until ? +1 : -1;
4768
+ dir = eras[i].since <= eras[i].until ? 1 : -1;
4481
4769
 
4482
4770
  // truncate time
4483
4771
  val = this.clone().startOf('day').valueOf();
@@ -4540,16 +4828,22 @@ function computeErasParse() {
4540
4828
  mixedPieces = [],
4541
4829
  i,
4542
4830
  l,
4831
+ erasName,
4832
+ erasAbbr,
4833
+ erasNarrow,
4543
4834
  eras = this.eras();
4544
4835
 
4545
4836
  for (i = 0, l = eras.length; i < l; ++i) {
4546
- namePieces.push(regexEscape(eras[i].name));
4547
- abbrPieces.push(regexEscape(eras[i].abbr));
4548
- narrowPieces.push(regexEscape(eras[i].narrow));
4837
+ erasName = regexEscape(eras[i].name);
4838
+ erasAbbr = regexEscape(eras[i].abbr);
4839
+ erasNarrow = regexEscape(eras[i].narrow);
4549
4840
 
4550
- mixedPieces.push(regexEscape(eras[i].name));
4551
- mixedPieces.push(regexEscape(eras[i].abbr));
4552
- mixedPieces.push(regexEscape(eras[i].narrow));
4841
+ namePieces.push(erasName);
4842
+ abbrPieces.push(erasAbbr);
4843
+ narrowPieces.push(erasNarrow);
4844
+ mixedPieces.push(erasName);
4845
+ mixedPieces.push(erasAbbr);
4846
+ mixedPieces.push(erasNarrow);
4553
4847
  }
4554
4848
 
4555
4849
  this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
@@ -4582,14 +4876,6 @@ addWeekYearFormatToken('GGGGG', 'isoWeekYear');
4582
4876
 
4583
4877
  // ALIASES
4584
4878
 
4585
- addUnitAlias('weekYear', 'gg');
4586
- addUnitAlias('isoWeekYear', 'GG');
4587
-
4588
- // PRIORITY
4589
-
4590
- addUnitPriority('weekYear', 1);
4591
- addUnitPriority('isoWeekYear', 1);
4592
-
4593
4879
  // PARSING
4594
4880
 
4595
4881
  addRegexToken('G', matchSigned);
@@ -4619,7 +4905,7 @@ function getSetWeekYear(input) {
4619
4905
  this,
4620
4906
  input,
4621
4907
  this.week(),
4622
- this.weekday(),
4908
+ this.weekday() + this.localeData()._week.dow,
4623
4909
  this.localeData()._week.dow,
4624
4910
  this.localeData()._week.doy
4625
4911
  );
@@ -4681,14 +4967,6 @@ function setWeekAll(weekYear, week, weekday, dow, doy) {
4681
4967
 
4682
4968
  addFormatToken('Q', 0, 'Qo', 'quarter');
4683
4969
 
4684
- // ALIASES
4685
-
4686
- addUnitAlias('quarter', 'Q');
4687
-
4688
- // PRIORITY
4689
-
4690
- addUnitPriority('quarter', 7);
4691
-
4692
4970
  // PARSING
4693
4971
 
4694
4972
  addRegexToken('Q', match1);
@@ -4708,16 +4986,9 @@ function getSetQuarter(input) {
4708
4986
 
4709
4987
  addFormatToken('D', ['DD', 2], 'Do', 'date');
4710
4988
 
4711
- // ALIASES
4712
-
4713
- addUnitAlias('date', 'D');
4714
-
4715
- // PRIORITY
4716
- addUnitPriority('date', 9);
4717
-
4718
4989
  // PARSING
4719
4990
 
4720
- addRegexToken('D', match1to2);
4991
+ addRegexToken('D', match1to2, match1to2NoLeadingZero);
4721
4992
  addRegexToken('DD', match1to2, match2);
4722
4993
  addRegexToken('Do', function (isStrict, locale) {
4723
4994
  // TODO: Remove "ordinalParse" fallback in next major release.
@@ -4739,13 +5010,6 @@ var getSetDayOfMonth = makeGetSet('Date', true);
4739
5010
 
4740
5011
  addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
4741
5012
 
4742
- // ALIASES
4743
-
4744
- addUnitAlias('dayOfYear', 'DDD');
4745
-
4746
- // PRIORITY
4747
- addUnitPriority('dayOfYear', 4);
4748
-
4749
5013
  // PARSING
4750
5014
 
4751
5015
  addRegexToken('DDD', match1to3);
@@ -4770,17 +5034,9 @@ function getSetDayOfYear(input) {
4770
5034
 
4771
5035
  addFormatToken('m', ['mm', 2], 0, 'minute');
4772
5036
 
4773
- // ALIASES
4774
-
4775
- addUnitAlias('minute', 'm');
4776
-
4777
- // PRIORITY
4778
-
4779
- addUnitPriority('minute', 14);
4780
-
4781
5037
  // PARSING
4782
5038
 
4783
- addRegexToken('m', match1to2);
5039
+ addRegexToken('m', match1to2, match1to2HasZero);
4784
5040
  addRegexToken('mm', match1to2, match2);
4785
5041
  addParseToken(['m', 'mm'], MINUTE);
4786
5042
 
@@ -4792,17 +5048,9 @@ var getSetMinute = makeGetSet('Minutes', false);
4792
5048
 
4793
5049
  addFormatToken('s', ['ss', 2], 0, 'second');
4794
5050
 
4795
- // ALIASES
4796
-
4797
- addUnitAlias('second', 's');
4798
-
4799
- // PRIORITY
4800
-
4801
- addUnitPriority('second', 15);
4802
-
4803
5051
  // PARSING
4804
5052
 
4805
- addRegexToken('s', match1to2);
5053
+ addRegexToken('s', match1to2, match1to2HasZero);
4806
5054
  addRegexToken('ss', match1to2, match2);
4807
5055
  addParseToken(['s', 'ss'], SECOND);
4808
5056
 
@@ -4840,14 +5088,6 @@ addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
4840
5088
  return this.millisecond() * 1000000;
4841
5089
  });
4842
5090
 
4843
- // ALIASES
4844
-
4845
- addUnitAlias('millisecond', 'ms');
4846
-
4847
- // PRIORITY
4848
-
4849
- addUnitPriority('millisecond', 16);
4850
-
4851
5091
  // PARSING
4852
5092
 
4853
5093
  addRegexToken('S', match1to3, match1);
@@ -4884,106 +5124,106 @@ function getZoneName() {
4884
5124
  return this._isUTC ? 'Coordinated Universal Time' : '';
4885
5125
  }
4886
5126
 
4887
- var proto = Moment.prototype;
5127
+ var proto$2 = Moment.prototype;
4888
5128
 
4889
- proto.add = add;
4890
- proto.calendar = calendar$1;
4891
- proto.clone = clone;
4892
- proto.diff = diff;
4893
- proto.endOf = endOf;
4894
- proto.format = format;
4895
- proto.from = from;
4896
- proto.fromNow = fromNow;
4897
- proto.to = to;
4898
- proto.toNow = toNow;
4899
- proto.get = stringGet;
4900
- proto.invalidAt = invalidAt;
4901
- proto.isAfter = isAfter;
4902
- proto.isBefore = isBefore;
4903
- proto.isBetween = isBetween;
4904
- proto.isSame = isSame;
4905
- proto.isSameOrAfter = isSameOrAfter;
4906
- proto.isSameOrBefore = isSameOrBefore;
4907
- proto.isValid = isValid$2;
4908
- proto.lang = lang;
4909
- proto.locale = locale;
4910
- proto.localeData = localeData;
4911
- proto.max = prototypeMax;
4912
- proto.min = prototypeMin;
4913
- proto.parsingFlags = parsingFlags;
4914
- proto.set = stringSet;
4915
- proto.startOf = startOf;
4916
- proto.subtract = subtract;
4917
- proto.toArray = toArray;
4918
- proto.toObject = toObject;
4919
- proto.toDate = toDate;
4920
- proto.toISOString = toISOString;
4921
- proto.inspect = inspect;
5129
+ proto$2.add = add$1;
5130
+ proto$2.calendar = calendar;
5131
+ proto$2.clone = clone$1;
5132
+ proto$2.diff = diff;
5133
+ proto$2.endOf = endOf;
5134
+ proto$2.format = format;
5135
+ proto$2.from = from;
5136
+ proto$2.fromNow = fromNow;
5137
+ proto$2.to = to;
5138
+ proto$2.toNow = toNow;
5139
+ proto$2.get = stringGet;
5140
+ proto$2.invalidAt = invalidAt;
5141
+ proto$2.isAfter = isAfter;
5142
+ proto$2.isBefore = isBefore;
5143
+ proto$2.isBetween = isBetween;
5144
+ proto$2.isSame = isSame;
5145
+ proto$2.isSameOrAfter = isSameOrAfter;
5146
+ proto$2.isSameOrBefore = isSameOrBefore;
5147
+ proto$2.isValid = isValid;
5148
+ proto$2.lang = lang;
5149
+ proto$2.locale = locale;
5150
+ proto$2.localeData = localeData;
5151
+ proto$2.max = prototypeMax;
5152
+ proto$2.min = prototypeMin;
5153
+ proto$2.parsingFlags = parsingFlags;
5154
+ proto$2.set = stringSet;
5155
+ proto$2.startOf = startOf;
5156
+ proto$2.subtract = subtract$1;
5157
+ proto$2.toArray = toArray;
5158
+ proto$2.toObject = toObject;
5159
+ proto$2.toDate = toDate;
5160
+ proto$2.toISOString = toISOString$1;
5161
+ proto$2.inspect = inspect;
4922
5162
  if (typeof Symbol !== 'undefined' && Symbol.for != null) {
4923
- proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
5163
+ proto$2[Symbol.for('nodejs.util.inspect.custom')] = function () {
4924
5164
  return 'Moment<' + this.format() + '>';
4925
5165
  };
4926
5166
  }
4927
- proto.toJSON = toJSON;
4928
- proto.toString = toString;
4929
- proto.unix = unix;
4930
- proto.valueOf = valueOf;
4931
- proto.creationData = creationData;
4932
- proto.eraName = getEraName;
4933
- proto.eraNarrow = getEraNarrow;
4934
- proto.eraAbbr = getEraAbbr;
4935
- proto.eraYear = getEraYear;
4936
- proto.year = getSetYear;
4937
- proto.isLeapYear = getIsLeapYear;
4938
- proto.weekYear = getSetWeekYear;
4939
- proto.isoWeekYear = getSetISOWeekYear;
4940
- proto.quarter = proto.quarters = getSetQuarter;
4941
- proto.month = getSetMonth;
4942
- proto.daysInMonth = getDaysInMonth;
4943
- proto.week = proto.weeks = getSetWeek;
4944
- proto.isoWeek = proto.isoWeeks = getSetISOWeek;
4945
- proto.weeksInYear = getWeeksInYear;
4946
- proto.weeksInWeekYear = getWeeksInWeekYear;
4947
- proto.isoWeeksInYear = getISOWeeksInYear;
4948
- proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
4949
- proto.date = getSetDayOfMonth;
4950
- proto.day = proto.days = getSetDayOfWeek;
4951
- proto.weekday = getSetLocaleDayOfWeek;
4952
- proto.isoWeekday = getSetISODayOfWeek;
4953
- proto.dayOfYear = getSetDayOfYear;
4954
- proto.hour = proto.hours = getSetHour;
4955
- proto.minute = proto.minutes = getSetMinute;
4956
- proto.second = proto.seconds = getSetSecond;
4957
- proto.millisecond = proto.milliseconds = getSetMillisecond;
4958
- proto.utcOffset = getSetOffset;
4959
- proto.utc = setOffsetToUTC;
4960
- proto.local = setOffsetToLocal;
4961
- proto.parseZone = setOffsetToParsedOffset;
4962
- proto.hasAlignedHourOffset = hasAlignedHourOffset;
4963
- proto.isDST = isDaylightSavingTime;
4964
- proto.isLocal = isLocal;
4965
- proto.isUtcOffset = isUtcOffset;
4966
- proto.isUtc = isUtc;
4967
- proto.isUTC = isUtc;
4968
- proto.zoneAbbr = getZoneAbbr;
4969
- proto.zoneName = getZoneName;
4970
- proto.dates = deprecate(
5167
+ proto$2.toJSON = toJSON;
5168
+ proto$2.toString = toString;
5169
+ proto$2.unix = unix;
5170
+ proto$2.valueOf = valueOf$1;
5171
+ proto$2.creationData = creationData;
5172
+ proto$2.eraName = getEraName;
5173
+ proto$2.eraNarrow = getEraNarrow;
5174
+ proto$2.eraAbbr = getEraAbbr;
5175
+ proto$2.eraYear = getEraYear;
5176
+ proto$2.year = getSetYear;
5177
+ proto$2.isLeapYear = getIsLeapYear;
5178
+ proto$2.weekYear = getSetWeekYear;
5179
+ proto$2.isoWeekYear = getSetISOWeekYear;
5180
+ proto$2.quarter = proto$2.quarters = getSetQuarter;
5181
+ proto$2.month = getSetMonth;
5182
+ proto$2.daysInMonth = getDaysInMonth;
5183
+ proto$2.week = proto$2.weeks = getSetWeek;
5184
+ proto$2.isoWeek = proto$2.isoWeeks = getSetISOWeek;
5185
+ proto$2.weeksInYear = getWeeksInYear;
5186
+ proto$2.weeksInWeekYear = getWeeksInWeekYear;
5187
+ proto$2.isoWeeksInYear = getISOWeeksInYear;
5188
+ proto$2.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
5189
+ proto$2.date = getSetDayOfMonth;
5190
+ proto$2.day = proto$2.days = getSetDayOfWeek;
5191
+ proto$2.weekday = getSetLocaleDayOfWeek;
5192
+ proto$2.isoWeekday = getSetISODayOfWeek;
5193
+ proto$2.dayOfYear = getSetDayOfYear;
5194
+ proto$2.hour = proto$2.hours = getSetHour;
5195
+ proto$2.minute = proto$2.minutes = getSetMinute;
5196
+ proto$2.second = proto$2.seconds = getSetSecond;
5197
+ proto$2.millisecond = proto$2.milliseconds = getSetMillisecond;
5198
+ proto$2.utcOffset = getSetOffset;
5199
+ proto$2.utc = setOffsetToUTC;
5200
+ proto$2.local = setOffsetToLocal;
5201
+ proto$2.parseZone = setOffsetToParsedOffset;
5202
+ proto$2.hasAlignedHourOffset = hasAlignedHourOffset;
5203
+ proto$2.isDST = isDaylightSavingTime;
5204
+ proto$2.isLocal = isLocal;
5205
+ proto$2.isUtcOffset = isUtcOffset;
5206
+ proto$2.isUtc = isUtc;
5207
+ proto$2.isUTC = isUtc;
5208
+ proto$2.zoneAbbr = getZoneAbbr;
5209
+ proto$2.zoneName = getZoneName;
5210
+ proto$2.dates = deprecate(
4971
5211
  'dates accessor is deprecated. Use date instead.',
4972
5212
  getSetDayOfMonth
4973
5213
  );
4974
- proto.months = deprecate(
5214
+ proto$2.months = deprecate(
4975
5215
  'months accessor is deprecated. Use month instead',
4976
5216
  getSetMonth
4977
5217
  );
4978
- proto.years = deprecate(
5218
+ proto$2.years = deprecate(
4979
5219
  'years accessor is deprecated. Use year instead',
4980
5220
  getSetYear
4981
5221
  );
4982
- proto.zone = deprecate(
5222
+ proto$2.zone = deprecate(
4983
5223
  'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
4984
5224
  getSetZone
4985
5225
  );
4986
- proto.isDSTShifted = deprecate(
5226
+ proto$2.isDSTShifted = deprecate(
4987
5227
  'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
4988
5228
  isDaylightSavingTimeShifted
4989
5229
  );
@@ -5002,13 +5242,13 @@ function preParsePostFormat(string) {
5002
5242
 
5003
5243
  var proto$1 = Locale.prototype;
5004
5244
 
5005
- proto$1.calendar = calendar;
5245
+ proto$1.calendar = calendar$1;
5006
5246
  proto$1.longDateFormat = longDateFormat;
5007
5247
  proto$1.invalidDate = invalidDate;
5008
5248
  proto$1.ordinal = ordinal;
5009
5249
  proto$1.preparse = preParsePostFormat;
5010
5250
  proto$1.postformat = preParsePostFormat;
5011
- proto$1.relativeTime = relativeTime;
5251
+ proto$1.relativeTime = relativeTime$1;
5012
5252
  proto$1.pastFuture = pastFuture;
5013
5253
  proto$1.set = set;
5014
5254
  proto$1.eras = localeEras;
@@ -5155,12 +5395,12 @@ getSetGlobalLocale('en', {
5155
5395
  toInt((number % 100) / 10) === 1
5156
5396
  ? 'th'
5157
5397
  : b === 1
5158
- ? 'st'
5159
- : b === 2
5160
- ? 'nd'
5161
- : b === 3
5162
- ? 'rd'
5163
- : 'th';
5398
+ ? 'st'
5399
+ : b === 2
5400
+ ? 'nd'
5401
+ : b === 3
5402
+ ? 'rd'
5403
+ : 'th';
5164
5404
  return number + output;
5165
5405
  },
5166
5406
  });
@@ -5178,7 +5418,7 @@ hooks.langData = deprecate(
5178
5418
 
5179
5419
  var mathAbs = Math.abs;
5180
5420
 
5181
- function abs() {
5421
+ function abs$1() {
5182
5422
  var data = this._data;
5183
5423
 
5184
5424
  this._milliseconds = mathAbs(this._milliseconds);
@@ -5195,7 +5435,7 @@ function abs() {
5195
5435
  return this;
5196
5436
  }
5197
5437
 
5198
- function addSubtract$1(duration, input, value, direction) {
5438
+ function addSubtract(duration, input, value, direction) {
5199
5439
  var other = createDuration(input, value);
5200
5440
 
5201
5441
  duration._milliseconds += direction * other._milliseconds;
@@ -5206,13 +5446,13 @@ function addSubtract$1(duration, input, value, direction) {
5206
5446
  }
5207
5447
 
5208
5448
  // supports only 2.0-style add(1, 's') or add(duration)
5209
- function add$1(input, value) {
5210
- return addSubtract$1(this, input, value, 1);
5449
+ function add(input, value) {
5450
+ return addSubtract(this, input, value, 1);
5211
5451
  }
5212
5452
 
5213
5453
  // supports only 2.0-style subtract(1, 's') or subtract(duration)
5214
- function subtract$1(input, value) {
5215
- return addSubtract$1(this, input, value, -1);
5454
+ function subtract(input, value) {
5455
+ return addSubtract(this, input, value, -1);
5216
5456
  }
5217
5457
 
5218
5458
  function absCeil(number) {
@@ -5236,12 +5476,10 @@ function bubble() {
5236
5476
 
5237
5477
  // if we have a mix of positive and negative values, bubble down first
5238
5478
  // check: https://github.com/moment/moment/issues/2166
5239
- if (
5240
- !(
5241
- (milliseconds >= 0 && days >= 0 && months >= 0) ||
5242
- (milliseconds <= 0 && days <= 0 && months <= 0)
5243
- )
5244
- ) {
5479
+ if (!(
5480
+ (milliseconds >= 0 && days >= 0 && months >= 0) ||
5481
+ (milliseconds <= 0 && days <= 0 && months <= 0)
5482
+ )) {
5245
5483
  milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
5246
5484
  days = 0;
5247
5485
  months = 0;
@@ -5333,19 +5571,6 @@ function as(units) {
5333
5571
  }
5334
5572
  }
5335
5573
 
5336
- // TODO: Use this.as('ms')?
5337
- function valueOf$1() {
5338
- if (!this.isValid()) {
5339
- return NaN;
5340
- }
5341
- return (
5342
- this._milliseconds +
5343
- this._days * 864e5 +
5344
- (this._months % 12) * 2592e6 +
5345
- toInt(this._months / 12) * 31536e6
5346
- );
5347
- }
5348
-
5349
5574
  function makeAs(alias) {
5350
5575
  return function () {
5351
5576
  return this.as(alias);
@@ -5360,13 +5585,14 @@ var asMilliseconds = makeAs('ms'),
5360
5585
  asWeeks = makeAs('w'),
5361
5586
  asMonths = makeAs('M'),
5362
5587
  asQuarters = makeAs('Q'),
5363
- asYears = makeAs('y');
5588
+ asYears = makeAs('y'),
5589
+ valueOf = asMilliseconds;
5364
5590
 
5365
- function clone$1() {
5591
+ function clone() {
5366
5592
  return createDuration(this);
5367
5593
  }
5368
5594
 
5369
- function get$2(units) {
5595
+ function get(units) {
5370
5596
  units = normalizeUnits(units);
5371
5597
  return this.isValid() ? this[units + 's']() : NaN;
5372
5598
  }
@@ -5402,10 +5628,16 @@ var round = Math.round,
5402
5628
 
5403
5629
  // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
5404
5630
  function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
5405
- return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
5631
+ return relativeTimeWithoutPostformat.call(
5632
+ locale,
5633
+ number || 1,
5634
+ !!withoutSuffix,
5635
+ string,
5636
+ isFuture
5637
+ );
5406
5638
  }
5407
5639
 
5408
- function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
5640
+ function relativeTime(posNegDuration, withoutSuffix, thresholds, locale) {
5409
5641
  var duration = createDuration(posNegDuration).abs(),
5410
5642
  seconds = round(duration.as('s')),
5411
5643
  minutes = round(duration.as('m')),
@@ -5486,29 +5718,29 @@ function humanize(argWithSuffix, argThresholds) {
5486
5718
  withSuffix = argWithSuffix;
5487
5719
  }
5488
5720
  if (typeof argThresholds === 'object') {
5489
- th = Object.assign({}, thresholds, argThresholds);
5721
+ th = extend(extend({}, thresholds), argThresholds || {});
5490
5722
  if (argThresholds.s != null && argThresholds.ss == null) {
5491
5723
  th.ss = argThresholds.s - 1;
5492
5724
  }
5493
5725
  }
5494
5726
 
5495
5727
  locale = this.localeData();
5496
- output = relativeTime$1(this, !withSuffix, th, locale);
5728
+ output = relativeTime(this, !withSuffix, th, locale);
5497
5729
 
5498
5730
  if (withSuffix) {
5499
- output = locale.pastFuture(+this, output);
5731
+ output = pastFutureWithoutPostformat.call(locale, +this, output);
5500
5732
  }
5501
5733
 
5502
5734
  return locale.postformat(output);
5503
5735
  }
5504
5736
 
5505
- var abs$1 = Math.abs;
5737
+ var abs = Math.abs;
5506
5738
 
5507
5739
  function sign(x) {
5508
5740
  return (x > 0) - (x < 0) || +x;
5509
5741
  }
5510
5742
 
5511
- function toISOString$1() {
5743
+ function toISOString() {
5512
5744
  // for ISO strings we do not use the normal bubbling rules:
5513
5745
  // * milliseconds bubble up until they become hours
5514
5746
  // * days do not bubble at all
@@ -5520,9 +5752,9 @@ function toISOString$1() {
5520
5752
  return this.localeData().invalidDate();
5521
5753
  }
5522
5754
 
5523
- var seconds = abs$1(this._milliseconds) / 1000,
5524
- days = abs$1(this._days),
5525
- months = abs$1(this._months),
5755
+ var seconds = abs(this._milliseconds) / 1000,
5756
+ days = abs(this._days),
5757
+ months = abs(this._months),
5526
5758
  minutes,
5527
5759
  hours,
5528
5760
  years,
@@ -5570,46 +5802,46 @@ function toISOString$1() {
5570
5802
  );
5571
5803
  }
5572
5804
 
5573
- var proto$2 = Duration.prototype;
5805
+ var proto = Duration.prototype;
5574
5806
 
5575
- proto$2.isValid = isValid$1;
5576
- proto$2.abs = abs;
5577
- proto$2.add = add$1;
5578
- proto$2.subtract = subtract$1;
5579
- proto$2.as = as;
5580
- proto$2.asMilliseconds = asMilliseconds;
5581
- proto$2.asSeconds = asSeconds;
5582
- proto$2.asMinutes = asMinutes;
5583
- proto$2.asHours = asHours;
5584
- proto$2.asDays = asDays;
5585
- proto$2.asWeeks = asWeeks;
5586
- proto$2.asMonths = asMonths;
5587
- proto$2.asQuarters = asQuarters;
5588
- proto$2.asYears = asYears;
5589
- proto$2.valueOf = valueOf$1;
5590
- proto$2._bubble = bubble;
5591
- proto$2.clone = clone$1;
5592
- proto$2.get = get$2;
5593
- proto$2.milliseconds = milliseconds;
5594
- proto$2.seconds = seconds;
5595
- proto$2.minutes = minutes;
5596
- proto$2.hours = hours;
5597
- proto$2.days = days;
5598
- proto$2.weeks = weeks;
5599
- proto$2.months = months;
5600
- proto$2.years = years;
5601
- proto$2.humanize = humanize;
5602
- proto$2.toISOString = toISOString$1;
5603
- proto$2.toString = toISOString$1;
5604
- proto$2.toJSON = toISOString$1;
5605
- proto$2.locale = locale;
5606
- proto$2.localeData = localeData;
5807
+ proto.isValid = isValid$1;
5808
+ proto.abs = abs$1;
5809
+ proto.add = add;
5810
+ proto.subtract = subtract;
5811
+ proto.as = as;
5812
+ proto.asMilliseconds = asMilliseconds;
5813
+ proto.asSeconds = asSeconds;
5814
+ proto.asMinutes = asMinutes;
5815
+ proto.asHours = asHours;
5816
+ proto.asDays = asDays;
5817
+ proto.asWeeks = asWeeks;
5818
+ proto.asMonths = asMonths;
5819
+ proto.asQuarters = asQuarters;
5820
+ proto.asYears = asYears;
5821
+ proto.valueOf = valueOf;
5822
+ proto._bubble = bubble;
5823
+ proto.clone = clone;
5824
+ proto.get = get;
5825
+ proto.milliseconds = milliseconds;
5826
+ proto.seconds = seconds;
5827
+ proto.minutes = minutes;
5828
+ proto.hours = hours;
5829
+ proto.days = days;
5830
+ proto.weeks = weeks;
5831
+ proto.months = months;
5832
+ proto.years = years;
5833
+ proto.humanize = humanize;
5834
+ proto.toISOString = toISOString;
5835
+ proto.toString = toISOString;
5836
+ proto.toJSON = toISOString;
5837
+ proto.locale = locale;
5838
+ proto.localeData = localeData;
5607
5839
 
5608
- proto$2.toIsoString = deprecate(
5840
+ proto.toIsoString = deprecate(
5609
5841
  'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
5610
- toISOString$1
5842
+ toISOString
5611
5843
  );
5612
- proto$2.lang = lang;
5844
+ proto.lang = lang;
5613
5845
 
5614
5846
  // FORMATTING
5615
5847
 
@@ -5629,11 +5861,11 @@ addParseToken('x', function (input, array, config) {
5629
5861
 
5630
5862
  //! moment.js
5631
5863
 
5632
- hooks.version = '2.29.4';
5864
+ hooks.version = '2.31.0';
5633
5865
 
5634
5866
  setHookCallback(createLocal);
5635
5867
 
5636
- hooks.fn = proto;
5868
+ hooks.fn = proto$2;
5637
5869
  hooks.min = min;
5638
5870
  hooks.max = max;
5639
5871
  hooks.now = now;
@@ -5642,7 +5874,7 @@ hooks.unix = createUnix;
5642
5874
  hooks.months = listMonths;
5643
5875
  hooks.isDate = isDate;
5644
5876
  hooks.locale = getSetGlobalLocale;
5645
- hooks.invalid = createInvalid;
5877
+ hooks.invalid = createInvalid$1;
5646
5878
  hooks.duration = createDuration;
5647
5879
  hooks.isMoment = isMoment;
5648
5880
  hooks.weekdays = listWeekdays;
@@ -5659,7 +5891,7 @@ hooks.normalizeUnits = normalizeUnits;
5659
5891
  hooks.relativeTimeRounding = getSetRelativeTimeRounding;
5660
5892
  hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
5661
5893
  hooks.calendarFormat = getCalendarFormat;
5662
- hooks.prototype = proto;
5894
+ hooks.prototype = proto$2;
5663
5895
 
5664
5896
  // currently HTML5 input type only supports 24-hour formats
5665
5897
  hooks.HTML5_FMT = {
@@ -5674,4 +5906,4 @@ hooks.HTML5_FMT = {
5674
5906
  MONTH: 'YYYY-MM', // <input type="month" />
5675
5907
  };
5676
5908
 
5677
- export default hooks;
5909
+ export { hooks as default };