You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4290 lines
132 KiB

2 years ago
  1. //! moment.js
  2. //! version : 2.17.1
  3. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  4. //! license : MIT
  5. //! momentjs.com
  6. ; (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. global.moment = factory()
  10. }(this, (function () {
  11. 'use strict';
  12. var hookCallback;
  13. function hooks() {
  14. return hookCallback.apply(null, arguments);
  15. }
  16. // This is done to register the method called with moment()
  17. // without creating circular dependencies.
  18. function setHookCallback(callback) {
  19. hookCallback = callback;
  20. }
  21. function isArray(input) {
  22. return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
  23. }
  24. function isObject(input) {
  25. // IE8 will treat undefined and null as object if it wasn't for
  26. // input != null
  27. return input != null && Object.prototype.toString.call(input) === '[object Object]';
  28. }
  29. function isObjectEmpty(obj) {
  30. var k;
  31. for (k in obj) {
  32. // even if its not own property I'd still call it non-empty
  33. return false;
  34. }
  35. return true;
  36. }
  37. function isNumber(input) {
  38. return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
  39. }
  40. function isDate(input) {
  41. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  42. }
  43. function map(arr, fn) {
  44. var res = [], i;
  45. for (i = 0; i < arr.length; ++i) {
  46. res.push(fn(arr[i], i));
  47. }
  48. return res;
  49. }
  50. function hasOwnProp(a, b) {
  51. return Object.prototype.hasOwnProperty.call(a, b);
  52. }
  53. function extend(a, b) {
  54. for (var i in b) {
  55. if (hasOwnProp(b, i)) {
  56. a[i] = b[i];
  57. }
  58. }
  59. if (hasOwnProp(b, 'toString')) {
  60. a.toString = b.toString;
  61. }
  62. if (hasOwnProp(b, 'valueOf')) {
  63. a.valueOf = b.valueOf;
  64. }
  65. return a;
  66. }
  67. function createUTC(input, format, locale, strict) {
  68. return createLocalOrUTC(input, format, locale, strict, true).utc();
  69. }
  70. function defaultParsingFlags() {
  71. // We need to deep clone this object.
  72. return {
  73. empty: false,
  74. unusedTokens: [],
  75. unusedInput: [],
  76. overflow: -2,
  77. charsLeftOver: 0,
  78. nullInput: false,
  79. invalidMonth: null,
  80. invalidFormat: false,
  81. userInvalidated: false,
  82. iso: false,
  83. parsedDateParts: [],
  84. meridiem: null
  85. };
  86. }
  87. function getParsingFlags(m) {
  88. if (m._pf == null) {
  89. m._pf = defaultParsingFlags();
  90. }
  91. return m._pf;
  92. }
  93. var some;
  94. if (Array.prototype.some) {
  95. some = Array.prototype.some;
  96. } else {
  97. some = function (fun) {
  98. var t = Object(this);
  99. var len = t.length >>> 0;
  100. for (var i = 0; i < len; i++) {
  101. if (i in t && fun.call(this, t[i], i, t)) {
  102. return true;
  103. }
  104. }
  105. return false;
  106. };
  107. }
  108. var some$1 = some;
  109. function isValid(m) {
  110. if (m._isValid == null) {
  111. var flags = getParsingFlags(m);
  112. var parsedParts = some$1.call(flags.parsedDateParts, function (i) {
  113. return i != null;
  114. });
  115. var isNowValid = !isNaN(m._d.getTime()) &&
  116. flags.overflow < 0 &&
  117. !flags.empty &&
  118. !flags.invalidMonth &&
  119. !flags.invalidWeekday &&
  120. !flags.nullInput &&
  121. !flags.invalidFormat &&
  122. !flags.userInvalidated &&
  123. (!flags.meridiem || (flags.meridiem && parsedParts));
  124. if (m._strict) {
  125. isNowValid = isNowValid &&
  126. flags.charsLeftOver === 0 &&
  127. flags.unusedTokens.length === 0 &&
  128. flags.bigHour === undefined;
  129. }
  130. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  131. m._isValid = isNowValid;
  132. }
  133. else {
  134. return isNowValid;
  135. }
  136. }
  137. return m._isValid;
  138. }
  139. function createInvalid(flags) {
  140. var m = createUTC(NaN);
  141. if (flags != null) {
  142. extend(getParsingFlags(m), flags);
  143. }
  144. else {
  145. getParsingFlags(m).userInvalidated = true;
  146. }
  147. return m;
  148. }
  149. function isUndefined(input) {
  150. return input === void 0;
  151. }
  152. // Plugins that add properties should also add the key here (null value),
  153. // so we can properly clone ourselves.
  154. var momentProperties = hooks.momentProperties = [];
  155. function copyConfig(to, from) {
  156. var i, prop, val;
  157. if (!isUndefined(from._isAMomentObject)) {
  158. to._isAMomentObject = from._isAMomentObject;
  159. }
  160. if (!isUndefined(from._i)) {
  161. to._i = from._i;
  162. }
  163. if (!isUndefined(from._f)) {
  164. to._f = from._f;
  165. }
  166. if (!isUndefined(from._l)) {
  167. to._l = from._l;
  168. }
  169. if (!isUndefined(from._strict)) {
  170. to._strict = from._strict;
  171. }
  172. if (!isUndefined(from._tzm)) {
  173. to._tzm = from._tzm;
  174. }
  175. if (!isUndefined(from._isUTC)) {
  176. to._isUTC = from._isUTC;
  177. }
  178. if (!isUndefined(from._offset)) {
  179. to._offset = from._offset;
  180. }
  181. if (!isUndefined(from._pf)) {
  182. to._pf = getParsingFlags(from);
  183. }
  184. if (!isUndefined(from._locale)) {
  185. to._locale = from._locale;
  186. }
  187. if (momentProperties.length > 0) {
  188. for (i in momentProperties) {
  189. prop = momentProperties[i];
  190. val = from[prop];
  191. if (!isUndefined(val)) {
  192. to[prop] = val;
  193. }
  194. }
  195. }
  196. return to;
  197. }
  198. var updateInProgress = false;
  199. // Moment prototype object
  200. function Moment(config) {
  201. copyConfig(this, config);
  202. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  203. if (!this.isValid()) {
  204. this._d = new Date(NaN);
  205. }
  206. // Prevent infinite loop in case updateOffset creates new moment
  207. // objects.
  208. if (updateInProgress === false) {
  209. updateInProgress = true;
  210. hooks.updateOffset(this);
  211. updateInProgress = false;
  212. }
  213. }
  214. function isMoment(obj) {
  215. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  216. }
  217. function absFloor(number) {
  218. if (number < 0) {
  219. // -0 -> 0
  220. return Math.ceil(number) || 0;
  221. } else {
  222. return Math.floor(number);
  223. }
  224. }
  225. function toInt(argumentForCoercion) {
  226. var coercedNumber = +argumentForCoercion,
  227. value = 0;
  228. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  229. value = absFloor(coercedNumber);
  230. }
  231. return value;
  232. }
  233. // compare two arrays, return the number of differences
  234. function compareArrays(array1, array2, dontConvert) {
  235. var len = Math.min(array1.length, array2.length),
  236. lengthDiff = Math.abs(array1.length - array2.length),
  237. diffs = 0,
  238. i;
  239. for (i = 0; i < len; i++) {
  240. if ((dontConvert && array1[i] !== array2[i]) ||
  241. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  242. diffs++;
  243. }
  244. }
  245. return diffs + lengthDiff;
  246. }
  247. function warn(msg) {
  248. if (hooks.suppressDeprecationWarnings === false &&
  249. (typeof console !== 'undefined') && console.warn) {
  250. console.warn('Deprecation warning: ' + msg);
  251. }
  252. }
  253. function deprecate(msg, fn) {
  254. var firstTime = true;
  255. return extend(function () {
  256. if (hooks.deprecationHandler != null) {
  257. hooks.deprecationHandler(null, msg);
  258. }
  259. if (firstTime) {
  260. var args = [];
  261. var arg;
  262. for (var i = 0; i < arguments.length; i++) {
  263. arg = '';
  264. if (typeof arguments[i] === 'object') {
  265. arg += '\n[' + i + '] ';
  266. for (var key in arguments[0]) {
  267. arg += key + ': ' + arguments[0][key] + ', ';
  268. }
  269. arg = arg.slice(0, -2); // Remove trailing comma and space
  270. } else {
  271. arg = arguments[i];
  272. }
  273. args.push(arg);
  274. }
  275. warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
  276. firstTime = false;
  277. }
  278. return fn.apply(this, arguments);
  279. }, fn);
  280. }
  281. var deprecations = {};
  282. function deprecateSimple(name, msg) {
  283. if (hooks.deprecationHandler != null) {
  284. hooks.deprecationHandler(name, msg);
  285. }
  286. if (!deprecations[name]) {
  287. warn(msg);
  288. deprecations[name] = true;
  289. }
  290. }
  291. hooks.suppressDeprecationWarnings = false;
  292. hooks.deprecationHandler = null;
  293. function isFunction(input) {
  294. return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  295. }
  296. function set(config) {
  297. var prop, i;
  298. for (i in config) {
  299. prop = config[i];
  300. if (isFunction(prop)) {
  301. this[i] = prop;
  302. } else {
  303. this['_' + i] = prop;
  304. }
  305. }
  306. this._config = config;
  307. // Lenient ordinal parsing accepts just a number in addition to
  308. // number + (possibly) stuff coming from _ordinalParseLenient.
  309. this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
  310. }
  311. function mergeConfigs(parentConfig, childConfig) {
  312. var res = extend({}, parentConfig), prop;
  313. for (prop in childConfig) {
  314. if (hasOwnProp(childConfig, prop)) {
  315. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  316. res[prop] = {};
  317. extend(res[prop], parentConfig[prop]);
  318. extend(res[prop], childConfig[prop]);
  319. } else if (childConfig[prop] != null) {
  320. res[prop] = childConfig[prop];
  321. } else {
  322. delete res[prop];
  323. }
  324. }
  325. }
  326. for (prop in parentConfig) {
  327. if (hasOwnProp(parentConfig, prop) &&
  328. !hasOwnProp(childConfig, prop) &&
  329. isObject(parentConfig[prop])) {
  330. // make sure changes to properties don't modify parent config
  331. res[prop] = extend({}, res[prop]);
  332. }
  333. }
  334. return res;
  335. }
  336. function Locale(config) {
  337. if (config != null) {
  338. this.set(config);
  339. }
  340. }
  341. var keys;
  342. if (Object.keys) {
  343. keys = Object.keys;
  344. } else {
  345. keys = function (obj) {
  346. var i, res = [];
  347. for (i in obj) {
  348. if (hasOwnProp(obj, i)) {
  349. res.push(i);
  350. }
  351. }
  352. return res;
  353. };
  354. }
  355. var keys$1 = keys;
  356. var defaultCalendar = {
  357. sameDay: '[Today at] LT',
  358. nextDay: '[Tomorrow at] LT',
  359. nextWeek: 'dddd [at] LT',
  360. lastDay: '[Yesterday at] LT',
  361. lastWeek: '[Last] dddd [at] LT',
  362. sameElse: 'L'
  363. };
  364. function calendar(key, mom, now) {
  365. var output = this._calendar[key] || this._calendar['sameElse'];
  366. return isFunction(output) ? output.call(mom, now) : output;
  367. }
  368. var defaultLongDateFormat = {
  369. LTS: 'h:mm:ss A',
  370. LT: 'h:mm A',
  371. L: 'MM/DD/YYYY',
  372. LL: 'MMMM D, YYYY',
  373. LLL: 'MMMM D, YYYY h:mm A',
  374. LLLL: 'dddd, MMMM D, YYYY h:mm A'
  375. };
  376. function longDateFormat(key) {
  377. var format = this._longDateFormat[key],
  378. formatUpper = this._longDateFormat[key.toUpperCase()];
  379. if (format || !formatUpper) {
  380. return format;
  381. }
  382. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  383. return val.slice(1);
  384. });
  385. return this._longDateFormat[key];
  386. }
  387. var defaultInvalidDate = 'Invalid date';
  388. function invalidDate() {
  389. return this._invalidDate;
  390. }
  391. var defaultOrdinal = '%d';
  392. var defaultOrdinalParse = /\d{1,2}/;
  393. function ordinal(number) {
  394. return this._ordinal.replace('%d', number);
  395. }
  396. var defaultRelativeTime = {
  397. future: 'in %s',
  398. past: '%s ago',
  399. s: 'a few seconds',
  400. m: 'a minute',
  401. mm: '%d minutes',
  402. h: 'an hour',
  403. hh: '%d hours',
  404. d: 'a day',
  405. dd: '%d days',
  406. M: 'a month',
  407. MM: '%d months',
  408. y: 'a year',
  409. yy: '%d years'
  410. };
  411. function relativeTime(number, withoutSuffix, string, isFuture) {
  412. var output = this._relativeTime[string];
  413. return (isFunction(output)) ?
  414. output(number, withoutSuffix, string, isFuture) :
  415. output.replace(/%d/i, number);
  416. }
  417. function pastFuture(diff, output) {
  418. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  419. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  420. }
  421. var aliases = {};
  422. function addUnitAlias(unit, shorthand) {
  423. var lowerCase = unit.toLowerCase();
  424. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  425. }
  426. function normalizeUnits(units) {
  427. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  428. }
  429. function normalizeObjectUnits(inputObject) {
  430. var normalizedInput = {},
  431. normalizedProp,
  432. prop;
  433. for (prop in inputObject) {
  434. if (hasOwnProp(inputObject, prop)) {
  435. normalizedProp = normalizeUnits(prop);
  436. if (normalizedProp) {
  437. normalizedInput[normalizedProp] = inputObject[prop];
  438. }
  439. }
  440. }
  441. return normalizedInput;
  442. }
  443. var priorities = {};
  444. function addUnitPriority(unit, priority) {
  445. priorities[unit] = priority;
  446. }
  447. function getPrioritizedUnits(unitsObj) {
  448. var units = [];
  449. for (var u in unitsObj) {
  450. units.push({ unit: u, priority: priorities[u] });
  451. }
  452. units.sort(function (a, b) {
  453. return a.priority - b.priority;
  454. });
  455. return units;
  456. }
  457. function makeGetSet(unit, keepTime) {
  458. return function (value) {
  459. if (value != null) {
  460. set$1(this, unit, value);
  461. hooks.updateOffset(this, keepTime);
  462. return this;
  463. } else {
  464. return get(this, unit);
  465. }
  466. };
  467. }
  468. function get(mom, unit) {
  469. return mom.isValid() ?
  470. mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  471. }
  472. function set$1(mom, unit, value) {
  473. if (mom.isValid()) {
  474. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  475. }
  476. }
  477. // MOMENTS
  478. function stringGet(units) {
  479. units = normalizeUnits(units);
  480. if (isFunction(this[units])) {
  481. return this[units]();
  482. }
  483. return this;
  484. }
  485. function stringSet(units, value) {
  486. if (typeof units === 'object') {
  487. units = normalizeObjectUnits(units);
  488. var prioritized = getPrioritizedUnits(units);
  489. for (var i = 0; i < prioritized.length; i++) {
  490. this[prioritized[i].unit](units[prioritized[i].unit]);
  491. }
  492. } else {
  493. units = normalizeUnits(units);
  494. if (isFunction(this[units])) {
  495. return this[units](value);
  496. }
  497. }
  498. return this;
  499. }
  500. function zeroFill(number, targetLength, forceSign) {
  501. var absNumber = '' + Math.abs(number),
  502. zerosToFill = targetLength - absNumber.length,
  503. sign = number >= 0;
  504. return (sign ? (forceSign ? '+' : '') : '-') +
  505. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  506. }
  507. var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
  508. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  509. var formatFunctions = {};
  510. var formatTokenFunctions = {};
  511. // token: 'M'
  512. // padded: ['MM', 2]
  513. // ordinal: 'Mo'
  514. // callback: function () { this.month() + 1 }
  515. function addFormatToken(token, padded, ordinal, callback) {
  516. var func = callback;
  517. if (typeof callback === 'string') {
  518. func = function () {
  519. return this[callback]();
  520. };
  521. }
  522. if (token) {
  523. formatTokenFunctions[token] = func;
  524. }
  525. if (padded) {
  526. formatTokenFunctions[padded[0]] = function () {
  527. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  528. };
  529. }
  530. if (ordinal) {
  531. formatTokenFunctions[ordinal] = function () {
  532. return this.localeData().ordinal(func.apply(this, arguments), token);
  533. };
  534. }
  535. }
  536. function removeFormattingTokens(input) {
  537. if (input.match(/\[[\s\S]/)) {
  538. return input.replace(/^\[|\]$/g, '');
  539. }
  540. return input.replace(/\\/g, '');
  541. }
  542. function makeFormatFunction(format) {
  543. var array = format.match(formattingTokens), i, length;
  544. for (i = 0, length = array.length; i < length; i++) {
  545. if (formatTokenFunctions[array[i]]) {
  546. array[i] = formatTokenFunctions[array[i]];
  547. } else {
  548. array[i] = removeFormattingTokens(array[i]);
  549. }
  550. }
  551. return function (mom) {
  552. var output = '', i;
  553. for (i = 0; i < length; i++) {
  554. output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
  555. }
  556. return output;
  557. };
  558. }
  559. // format date using native date object
  560. function formatMoment(m, format) {
  561. if (!m.isValid()) {
  562. return m.localeData().invalidDate();
  563. }
  564. format = expandFormat(format, m.localeData());
  565. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  566. return formatFunctions[format](m);
  567. }
  568. function expandFormat(format, locale) {
  569. var i = 5;
  570. function replaceLongDateFormatTokens(input) {
  571. return locale.longDateFormat(input) || input;
  572. }
  573. localFormattingTokens.lastIndex = 0;
  574. while (i >= 0 && localFormattingTokens.test(format)) {
  575. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  576. localFormattingTokens.lastIndex = 0;
  577. i -= 1;
  578. }
  579. return format;
  580. }
  581. var match1 = /\d/; // 0 - 9
  582. var match2 = /\d\d/; // 00 - 99
  583. var match3 = /\d{3}/; // 000 - 999
  584. var match4 = /\d{4}/; // 0000 - 9999
  585. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  586. var match1to2 = /\d\d?/; // 0 - 99
  587. var match3to4 = /\d\d\d\d?/; // 999 - 9999
  588. var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  589. var match1to3 = /\d{1,3}/; // 0 - 999
  590. var match1to4 = /\d{1,4}/; // 0 - 9999
  591. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  592. var matchUnsigned = /\d+/; // 0 - inf
  593. var matchSigned = /[+-]?\d+/; // -inf - inf
  594. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  595. var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  596. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  597. // any word (or two) characters or numbers including two/three word month in arabic.
  598. // includes scottish gaelic two word and hyphenated months
  599. var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  600. var regexes = {};
  601. function addRegexToken(token, regex, strictRegex) {
  602. regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  603. return (isStrict && strictRegex) ? strictRegex : regex;
  604. };
  605. }
  606. function getParseRegexForToken(token, config) {
  607. if (!hasOwnProp(regexes, token)) {
  608. return new RegExp(unescapeFormat(token));
  609. }
  610. return regexes[token](config._strict, config._locale);
  611. }
  612. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  613. function unescapeFormat(s) {
  614. return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  615. return p1 || p2 || p3 || p4;
  616. }));
  617. }
  618. function regexEscape(s) {
  619. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  620. }
  621. var tokens = {};
  622. function addParseToken(token, callback) {
  623. var i, func = callback;
  624. if (typeof token === 'string') {
  625. token = [token];
  626. }
  627. if (isNumber(callback)) {
  628. func = function (input, array) {
  629. array[callback] = toInt(input);
  630. };
  631. }
  632. for (i = 0; i < token.length; i++) {
  633. tokens[token[i]] = func;
  634. }
  635. }
  636. function addWeekParseToken(token, callback) {
  637. addParseToken(token, function (input, array, config, token) {
  638. config._w = config._w || {};
  639. callback(input, config._w, config, token);
  640. });
  641. }
  642. function addTimeToArrayFromToken(token, input, config) {
  643. if (input != null && hasOwnProp(tokens, token)) {
  644. tokens[token](input, config._a, config, token);
  645. }
  646. }
  647. var YEAR = 0;
  648. var MONTH = 1;
  649. var DATE = 2;
  650. var HOUR = 3;
  651. var MINUTE = 4;
  652. var SECOND = 5;
  653. var MILLISECOND = 6;
  654. var WEEK = 7;
  655. var WEEKDAY = 8;
  656. var indexOf;
  657. if (Array.prototype.indexOf) {
  658. indexOf = Array.prototype.indexOf;
  659. } else {
  660. indexOf = function (o) {
  661. // I know
  662. var i;
  663. for (i = 0; i < this.length; ++i) {
  664. if (this[i] === o) {
  665. return i;
  666. }
  667. }
  668. return -1;
  669. };
  670. }
  671. var indexOf$1 = indexOf;
  672. function daysInMonth(year, month) {
  673. return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
  674. }
  675. // FORMATTING
  676. addFormatToken('M', ['MM', 2], 'Mo', function () {
  677. return this.month() + 1;
  678. });
  679. addFormatToken('MMM', 0, 0, function (format) {
  680. return this.localeData().monthsShort(this, format);
  681. });
  682. addFormatToken('MMMM', 0, 0, function (format) {
  683. return this.localeData().months(this, format);
  684. });
  685. // ALIASES
  686. addUnitAlias('month', 'M');
  687. // PRIORITY
  688. addUnitPriority('month', 8);
  689. // PARSING
  690. addRegexToken('M', match1to2);
  691. addRegexToken('MM', match1to2, match2);
  692. addRegexToken('MMM', function (isStrict, locale) {
  693. return locale.monthsShortRegex(isStrict);
  694. });
  695. addRegexToken('MMMM', function (isStrict, locale) {
  696. return locale.monthsRegex(isStrict);
  697. });
  698. addParseToken(['M', 'MM'], function (input, array) {
  699. array[MONTH] = toInt(input) - 1;
  700. });
  701. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  702. var month = config._locale.monthsParse(input, token, config._strict);
  703. // if we didn't find a month name, mark the date as invalid.
  704. if (month != null) {
  705. array[MONTH] = month;
  706. } else {
  707. getParsingFlags(config).invalidMonth = input;
  708. }
  709. });
  710. // LOCALES
  711. var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
  712. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  713. function localeMonths(m, format) {
  714. if (!m) {
  715. return this._months;
  716. }
  717. return isArray(this._months) ? this._months[m.month()] :
  718. this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
  719. }
  720. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  721. function localeMonthsShort(m, format) {
  722. if (!m) {
  723. return this._monthsShort;
  724. }
  725. return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  726. this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  727. }
  728. function handleStrictParse(monthName, format, strict) {
  729. var i, ii, mom, llc = monthName.toLocaleLowerCase();
  730. if (!this._monthsParse) {
  731. // this is not used
  732. this._monthsParse = [];
  733. this._longMonthsParse = [];
  734. this._shortMonthsParse = [];
  735. for (i = 0; i < 12; ++i) {
  736. mom = createUTC([2000, i]);
  737. this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
  738. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  739. }
  740. }
  741. if (strict) {
  742. if (format === 'MMM') {
  743. ii = indexOf$1.call(this._shortMonthsParse, llc);
  744. return ii !== -1 ? ii : null;
  745. } else {
  746. ii = indexOf$1.call(this._longMonthsParse, llc);
  747. return ii !== -1 ? ii : null;
  748. }
  749. } else {
  750. if (format === 'MMM') {
  751. ii = indexOf$1.call(this._shortMonthsParse, llc);
  752. if (ii !== -1) {
  753. return ii;
  754. }
  755. ii = indexOf$1.call(this._longMonthsParse, llc);
  756. return ii !== -1 ? ii : null;
  757. } else {
  758. ii = indexOf$1.call(this._longMonthsParse, llc);
  759. if (ii !== -1) {
  760. return ii;
  761. }
  762. ii = indexOf$1.call(this._shortMonthsParse, llc);
  763. return ii !== -1 ? ii : null;
  764. }
  765. }
  766. }
  767. function localeMonthsParse(monthName, format, strict) {
  768. var i, mom, regex;
  769. if (this._monthsParseExact) {
  770. return handleStrictParse.call(this, monthName, format, strict);
  771. }
  772. if (!this._monthsParse) {
  773. this._monthsParse = [];
  774. this._longMonthsParse = [];
  775. this._shortMonthsParse = [];
  776. }
  777. // TODO: add sorting
  778. // Sorting makes sure if one month (or abbr) is a prefix of another
  779. // see sorting in computeMonthsParse
  780. for (i = 0; i < 12; i++) {
  781. // make the regex if we don't have it already
  782. mom = createUTC([2000, i]);
  783. if (strict && !this._longMonthsParse[i]) {
  784. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  785. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  786. }
  787. if (!strict && !this._monthsParse[i]) {
  788. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  789. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  790. }
  791. // test the regex
  792. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  793. return i;
  794. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  795. return i;
  796. } else if (!strict && this._monthsParse[i].test(monthName)) {
  797. return i;
  798. }
  799. }
  800. }
  801. // MOMENTS
  802. function setMonth(mom, value) {
  803. var dayOfMonth;
  804. if (!mom.isValid()) {
  805. // No op
  806. return mom;
  807. }
  808. if (typeof value === 'string') {
  809. if (/^\d+$/.test(value)) {
  810. value = toInt(value);
  811. } else {
  812. value = mom.localeData().monthsParse(value);
  813. // TODO: Another silent failure?
  814. if (!isNumber(value)) {
  815. return mom;
  816. }
  817. }
  818. }
  819. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  820. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  821. return mom;
  822. }
  823. function getSetMonth(value) {
  824. if (value != null) {
  825. setMonth(this, value);
  826. hooks.updateOffset(this, true);
  827. return this;
  828. } else {
  829. return get(this, 'Month');
  830. }
  831. }
  832. function getDaysInMonth() {
  833. return daysInMonth(this.year(), this.month());
  834. }
  835. var defaultMonthsShortRegex = matchWord;
  836. function monthsShortRegex(isStrict) {
  837. if (this._monthsParseExact) {
  838. if (!hasOwnProp(this, '_monthsRegex')) {
  839. computeMonthsParse.call(this);
  840. }
  841. if (isStrict) {
  842. return this._monthsShortStrictRegex;
  843. } else {
  844. return this._monthsShortRegex;
  845. }
  846. } else {
  847. if (!hasOwnProp(this, '_monthsShortRegex')) {
  848. this._monthsShortRegex = defaultMonthsShortRegex;
  849. }
  850. return this._monthsShortStrictRegex && isStrict ?
  851. this._monthsShortStrictRegex : this._monthsShortRegex;
  852. }
  853. }
  854. var defaultMonthsRegex = matchWord;
  855. function monthsRegex(isStrict) {
  856. if (this._monthsParseExact) {
  857. if (!hasOwnProp(this, '_monthsRegex')) {
  858. computeMonthsParse.call(this);
  859. }
  860. if (isStrict) {
  861. return this._monthsStrictRegex;
  862. } else {
  863. return this._monthsRegex;
  864. }
  865. } else {
  866. if (!hasOwnProp(this, '_monthsRegex')) {
  867. this._monthsRegex = defaultMonthsRegex;
  868. }
  869. return this._monthsStrictRegex && isStrict ?
  870. this._monthsStrictRegex : this._monthsRegex;
  871. }
  872. }
  873. function computeMonthsParse() {
  874. function cmpLenRev(a, b) {
  875. return b.length - a.length;
  876. }
  877. var shortPieces = [], longPieces = [], mixedPieces = [],
  878. i, mom;
  879. for (i = 0; i < 12; i++) {
  880. // make the regex if we don't have it already
  881. mom = createUTC([2000, i]);
  882. shortPieces.push(this.monthsShort(mom, ''));
  883. longPieces.push(this.months(mom, ''));
  884. mixedPieces.push(this.months(mom, ''));
  885. mixedPieces.push(this.monthsShort(mom, ''));
  886. }
  887. // Sorting makes sure if one month (or abbr) is a prefix of another it
  888. // will match the longer piece.
  889. shortPieces.sort(cmpLenRev);
  890. longPieces.sort(cmpLenRev);
  891. mixedPieces.sort(cmpLenRev);
  892. for (i = 0; i < 12; i++) {
  893. shortPieces[i] = regexEscape(shortPieces[i]);
  894. longPieces[i] = regexEscape(longPieces[i]);
  895. }
  896. for (i = 0; i < 24; i++) {
  897. mixedPieces[i] = regexEscape(mixedPieces[i]);
  898. }
  899. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  900. this._monthsShortRegex = this._monthsRegex;
  901. this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  902. this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  903. }
  904. // FORMATTING
  905. addFormatToken('Y', 0, 0, function () {
  906. var y = this.year();
  907. return y <= 9999 ? '' + y : '+' + y;
  908. });
  909. addFormatToken(0, ['YY', 2], 0, function () {
  910. return this.year() % 100;
  911. });
  912. addFormatToken(0, ['YYYY', 4], 0, 'year');
  913. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  914. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  915. // ALIASES
  916. addUnitAlias('year', 'y');
  917. // PRIORITIES
  918. addUnitPriority('year', 1);
  919. // PARSING
  920. addRegexToken('Y', matchSigned);
  921. addRegexToken('YY', match1to2, match2);
  922. addRegexToken('YYYY', match1to4, match4);
  923. addRegexToken('YYYYY', match1to6, match6);
  924. addRegexToken('YYYYYY', match1to6, match6);
  925. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  926. addParseToken('YYYY', function (input, array) {
  927. array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  928. });
  929. addParseToken('YY', function (input, array) {
  930. array[YEAR] = hooks.parseTwoDigitYear(input);
  931. });
  932. addParseToken('Y', function (input, array) {
  933. array[YEAR] = parseInt(input, 10);
  934. });
  935. // HELPERS
  936. function daysInYear(year) {
  937. return isLeapYear(year) ? 366 : 365;
  938. }
  939. function isLeapYear(year) {
  940. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  941. }
  942. // HOOKS
  943. hooks.parseTwoDigitYear = function (input) {
  944. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  945. };
  946. // MOMENTS
  947. var getSetYear = makeGetSet('FullYear', true);
  948. function getIsLeapYear() {
  949. return isLeapYear(this.year());
  950. }
  951. function createDate(y, m, d, h, M, s, ms) {
  952. //can't just apply() to create a date:
  953. //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
  954. var date = new Date(y, m, d, h, M, s, ms);
  955. //the date constructor remaps years 0-99 to 1900-1999
  956. if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
  957. date.setFullYear(y);
  958. }
  959. return date;
  960. }
  961. function createUTCDate(y) {
  962. var date = new Date(Date.UTC.apply(null, arguments));
  963. //the Date.UTC function remaps years 0-99 to 1900-1999
  964. if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
  965. date.setUTCFullYear(y);
  966. }
  967. return date;
  968. }
  969. // start-of-first-week - start-of-year
  970. function firstWeekOffset(year, dow, doy) {
  971. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  972. fwd = 7 + dow - doy,
  973. // first-week day local weekday -- which local weekday is fwd
  974. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  975. return -fwdlw + fwd - 1;
  976. }
  977. //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  978. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  979. var localWeekday = (7 + weekday - dow) % 7,
  980. weekOffset = firstWeekOffset(year, dow, doy),
  981. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  982. resYear, resDayOfYear;
  983. if (dayOfYear <= 0) {
  984. resYear = year - 1;
  985. resDayOfYear = daysInYear(resYear) + dayOfYear;
  986. } else if (dayOfYear > daysInYear(year)) {
  987. resYear = year + 1;
  988. resDayOfYear = dayOfYear - daysInYear(year);
  989. } else {
  990. resYear = year;
  991. resDayOfYear = dayOfYear;
  992. }
  993. return {
  994. year: resYear,
  995. dayOfYear: resDayOfYear
  996. };
  997. }
  998. function weekOfYear(mom, dow, doy) {
  999. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  1000. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  1001. resWeek, resYear;
  1002. if (week < 1) {
  1003. resYear = mom.year() - 1;
  1004. resWeek = week + weeksInYear(resYear, dow, doy);
  1005. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  1006. resWeek = week - weeksInYear(mom.year(), dow, doy);
  1007. resYear = mom.year() + 1;
  1008. } else {
  1009. resYear = mom.year();
  1010. resWeek = week;
  1011. }
  1012. return {
  1013. week: resWeek,
  1014. year: resYear
  1015. };
  1016. }
  1017. function weeksInYear(year, dow, doy) {
  1018. var weekOffset = firstWeekOffset(year, dow, doy),
  1019. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  1020. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  1021. }
  1022. // FORMATTING
  1023. addFormatToken('w', ['ww', 2], 'wo', 'week');
  1024. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  1025. // ALIASES
  1026. addUnitAlias('week', 'w');
  1027. addUnitAlias('isoWeek', 'W');
  1028. // PRIORITIES
  1029. addUnitPriority('week', 5);
  1030. addUnitPriority('isoWeek', 5);
  1031. // PARSING
  1032. addRegexToken('w', match1to2);
  1033. addRegexToken('ww', match1to2, match2);
  1034. addRegexToken('W', match1to2);
  1035. addRegexToken('WW', match1to2, match2);
  1036. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  1037. week[token.substr(0, 1)] = toInt(input);
  1038. });
  1039. // HELPERS
  1040. // LOCALES
  1041. function localeWeek(mom) {
  1042. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  1043. }
  1044. var defaultLocaleWeek = {
  1045. dow: 0, // Sunday is the first day of the week.
  1046. doy: 6 // The week that contains Jan 1st is the first week of the year.
  1047. };
  1048. function localeFirstDayOfWeek() {
  1049. return this._week.dow;
  1050. }
  1051. function localeFirstDayOfYear() {
  1052. return this._week.doy;
  1053. }
  1054. // MOMENTS
  1055. function getSetWeek(input) {
  1056. var week = this.localeData().week(this);
  1057. return input == null ? week : this.add((input - week) * 7, 'd');
  1058. }
  1059. function getSetISOWeek(input) {
  1060. var week = weekOfYear(this, 1, 4).week;
  1061. return input == null ? week : this.add((input - week) * 7, 'd');
  1062. }
  1063. // FORMATTING
  1064. addFormatToken('d', 0, 'do', 'day');
  1065. addFormatToken('dd', 0, 0, function (format) {
  1066. return this.localeData().weekdaysMin(this, format);
  1067. });
  1068. addFormatToken('ddd', 0, 0, function (format) {
  1069. return this.localeData().weekdaysShort(this, format);
  1070. });
  1071. addFormatToken('dddd', 0, 0, function (format) {
  1072. return this.localeData().weekdays(this, format);
  1073. });
  1074. addFormatToken('e', 0, 0, 'weekday');
  1075. addFormatToken('E', 0, 0, 'isoWeekday');
  1076. // ALIASES
  1077. addUnitAlias('day', 'd');
  1078. addUnitAlias('weekday', 'e');
  1079. addUnitAlias('isoWeekday', 'E');
  1080. // PRIORITY
  1081. addUnitPriority('day', 11);
  1082. addUnitPriority('weekday', 11);
  1083. addUnitPriority('isoWeekday', 11);
  1084. // PARSING
  1085. addRegexToken('d', match1to2);
  1086. addRegexToken('e', match1to2);
  1087. addRegexToken('E', match1to2);
  1088. addRegexToken('dd', function (isStrict, locale) {
  1089. return locale.weekdaysMinRegex(isStrict);
  1090. });
  1091. addRegexToken('ddd', function (isStrict, locale) {
  1092. return locale.weekdaysShortRegex(isStrict);
  1093. });
  1094. addRegexToken('dddd', function (isStrict, locale) {
  1095. return locale.weekdaysRegex(isStrict);
  1096. });
  1097. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  1098. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  1099. // if we didn't get a weekday name, mark the date as invalid
  1100. if (weekday != null) {
  1101. week.d = weekday;
  1102. } else {
  1103. getParsingFlags(config).invalidWeekday = input;
  1104. }
  1105. });
  1106. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  1107. week[token] = toInt(input);
  1108. });
  1109. // HELPERS
  1110. function parseWeekday(input, locale) {
  1111. if (typeof input !== 'string') {
  1112. return input;
  1113. }
  1114. if (!isNaN(input)) {
  1115. return parseInt(input, 10);
  1116. }
  1117. input = locale.weekdaysParse(input);
  1118. if (typeof input === 'number') {
  1119. return input;
  1120. }
  1121. return null;
  1122. }
  1123. function parseIsoWeekday(input, locale) {
  1124. if (typeof input === 'string') {
  1125. return locale.weekdaysParse(input) % 7 || 7;
  1126. }
  1127. return isNaN(input) ? null : input;
  1128. }
  1129. // LOCALES
  1130. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  1131. function localeWeekdays(m, format) {
  1132. if (!m) {
  1133. return this._weekdays;
  1134. }
  1135. return isArray(this._weekdays) ? this._weekdays[m.day()] :
  1136. this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
  1137. }
  1138. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  1139. function localeWeekdaysShort(m) {
  1140. return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
  1141. }
  1142. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  1143. function localeWeekdaysMin(m) {
  1144. return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
  1145. }
  1146. function handleStrictParse$1(weekdayName, format, strict) {
  1147. var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
  1148. if (!this._weekdaysParse) {
  1149. this._weekdaysParse = [];
  1150. this._shortWeekdaysParse = [];
  1151. this._minWeekdaysParse = [];
  1152. for (i = 0; i < 7; ++i) {
  1153. mom = createUTC([2000, 1]).day(i);
  1154. this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
  1155. this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
  1156. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  1157. }
  1158. }
  1159. if (strict) {
  1160. if (format === 'dddd') {
  1161. ii = indexOf$1.call(this._weekdaysParse, llc);
  1162. return ii !== -1 ? ii : null;
  1163. } else if (format === 'ddd') {
  1164. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  1165. return ii !== -1 ? ii : null;
  1166. } else {
  1167. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  1168. return ii !== -1 ? ii : null;
  1169. }
  1170. } else {
  1171. if (format === 'dddd') {
  1172. ii = indexOf$1.call(this._weekdaysParse, llc);
  1173. if (ii !== -1) {
  1174. return ii;
  1175. }
  1176. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  1177. if (ii !== -1) {
  1178. return ii;
  1179. }
  1180. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  1181. return ii !== -1 ? ii : null;
  1182. } else if (format === 'ddd') {
  1183. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  1184. if (ii !== -1) {
  1185. return ii;
  1186. }
  1187. ii = indexOf$1.call(this._weekdaysParse, llc);
  1188. if (ii !== -1) {
  1189. return ii;
  1190. }
  1191. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  1192. return ii !== -1 ? ii : null;
  1193. } else {
  1194. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  1195. if (ii !== -1) {
  1196. return ii;
  1197. }
  1198. ii = indexOf$1.call(this._weekdaysParse, llc);
  1199. if (ii !== -1) {
  1200. return ii;
  1201. }
  1202. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  1203. return ii !== -1 ? ii : null;
  1204. }
  1205. }
  1206. }
  1207. function localeWeekdaysParse(weekdayName, format, strict) {
  1208. var i, mom, regex;
  1209. if (this._weekdaysParseExact) {
  1210. return handleStrictParse$1.call(this, weekdayName, format, strict);
  1211. }
  1212. if (!this._weekdaysParse) {
  1213. this._weekdaysParse = [];
  1214. this._minWeekdaysParse = [];
  1215. this._shortWeekdaysParse = [];
  1216. this._fullWeekdaysParse = [];
  1217. }
  1218. for (i = 0; i < 7; i++) {
  1219. // make the regex if we don't have it already
  1220. mom = createUTC([2000, 1]).day(i);
  1221. if (strict && !this._fullWeekdaysParse[i]) {
  1222. this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
  1223. this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
  1224. this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
  1225. }
  1226. if (!this._weekdaysParse[i]) {
  1227. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  1228. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  1229. }
  1230. // test the regex
  1231. if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
  1232. return i;
  1233. } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
  1234. return i;
  1235. } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
  1236. return i;
  1237. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  1238. return i;
  1239. }
  1240. }
  1241. }
  1242. // MOMENTS
  1243. function getSetDayOfWeek(input) {
  1244. if (!this.isValid()) {
  1245. return input != null ? this : NaN;
  1246. }
  1247. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  1248. if (input != null) {
  1249. input = parseWeekday(input, this.localeData());
  1250. return this.add(input - day, 'd');
  1251. } else {
  1252. return day;
  1253. }
  1254. }
  1255. function getSetLocaleDayOfWeek(input) {
  1256. if (!this.isValid()) {
  1257. return input != null ? this : NaN;
  1258. }
  1259. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  1260. return input == null ? weekday : this.add(input - weekday, 'd');
  1261. }
  1262. function getSetISODayOfWeek(input) {
  1263. if (!this.isValid()) {
  1264. return input != null ? this : NaN;
  1265. }
  1266. // behaves the same as moment#day except
  1267. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  1268. // as a setter, sunday should belong to the previous week.
  1269. if (input != null) {
  1270. var weekday = parseIsoWeekday(input, this.localeData());
  1271. return this.day(this.day() % 7 ? weekday : weekday - 7);
  1272. } else {
  1273. return this.day() || 7;
  1274. }
  1275. }
  1276. var defaultWeekdaysRegex = matchWord;
  1277. function weekdaysRegex(isStrict) {
  1278. if (this._weekdaysParseExact) {
  1279. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1280. computeWeekdaysParse.call(this);
  1281. }
  1282. if (isStrict) {
  1283. return this._weekdaysStrictRegex;
  1284. } else {
  1285. return this._weekdaysRegex;
  1286. }
  1287. } else {
  1288. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1289. this._weekdaysRegex = defaultWeekdaysRegex;
  1290. }
  1291. return this._weekdaysStrictRegex && isStrict ?
  1292. this._weekdaysStrictRegex : this._weekdaysRegex;
  1293. }
  1294. }
  1295. var defaultWeekdaysShortRegex = matchWord;
  1296. function weekdaysShortRegex(isStrict) {
  1297. if (this._weekdaysParseExact) {
  1298. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1299. computeWeekdaysParse.call(this);
  1300. }
  1301. if (isStrict) {
  1302. return this._weekdaysShortStrictRegex;
  1303. } else {
  1304. return this._weekdaysShortRegex;
  1305. }
  1306. } else {
  1307. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  1308. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  1309. }
  1310. return this._weekdaysShortStrictRegex && isStrict ?
  1311. this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
  1312. }
  1313. }
  1314. var defaultWeekdaysMinRegex = matchWord;
  1315. function weekdaysMinRegex(isStrict) {
  1316. if (this._weekdaysParseExact) {
  1317. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1318. computeWeekdaysParse.call(this);
  1319. }
  1320. if (isStrict) {
  1321. return this._weekdaysMinStrictRegex;
  1322. } else {
  1323. return this._weekdaysMinRegex;
  1324. }
  1325. } else {
  1326. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  1327. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  1328. }
  1329. return this._weekdaysMinStrictRegex && isStrict ?
  1330. this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
  1331. }
  1332. }
  1333. function computeWeekdaysParse() {
  1334. function cmpLenRev(a, b) {
  1335. return b.length - a.length;
  1336. }
  1337. var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
  1338. i, mom, minp, shortp, longp;
  1339. for (i = 0; i < 7; i++) {
  1340. // make the regex if we don't have it already
  1341. mom = createUTC([2000, 1]).day(i);
  1342. minp = this.weekdaysMin(mom, '');
  1343. shortp = this.weekdaysShort(mom, '');
  1344. longp = this.weekdays(mom, '');
  1345. minPieces.push(minp);
  1346. shortPieces.push(shortp);
  1347. longPieces.push(longp);
  1348. mixedPieces.push(minp);
  1349. mixedPieces.push(shortp);
  1350. mixedPieces.push(longp);
  1351. }
  1352. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  1353. // will match the longer piece.
  1354. minPieces.sort(cmpLenRev);
  1355. shortPieces.sort(cmpLenRev);
  1356. longPieces.sort(cmpLenRev);
  1357. mixedPieces.sort(cmpLenRev);
  1358. for (i = 0; i < 7; i++) {
  1359. shortPieces[i] = regexEscape(shortPieces[i]);
  1360. longPieces[i] = regexEscape(longPieces[i]);
  1361. mixedPieces[i] = regexEscape(mixedPieces[i]);
  1362. }
  1363. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  1364. this._weekdaysShortRegex = this._weekdaysRegex;
  1365. this._weekdaysMinRegex = this._weekdaysRegex;
  1366. this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  1367. this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  1368. this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
  1369. }
  1370. // FORMATTING
  1371. function hFormat() {
  1372. return this.hours() % 12 || 12;
  1373. }
  1374. function kFormat() {
  1375. return this.hours() || 24;
  1376. }
  1377. addFormatToken('H', ['HH', 2], 0, 'hour');
  1378. addFormatToken('h', ['hh', 2], 0, hFormat);
  1379. addFormatToken('k', ['kk', 2], 0, kFormat);
  1380. addFormatToken('hmm', 0, 0, function () {
  1381. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  1382. });
  1383. addFormatToken('hmmss', 0, 0, function () {
  1384. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
  1385. zeroFill(this.seconds(), 2);
  1386. });
  1387. addFormatToken('Hmm', 0, 0, function () {
  1388. return '' + this.hours() + zeroFill(this.minutes(), 2);
  1389. });
  1390. addFormatToken('Hmmss', 0, 0, function () {
  1391. return '' + this.hours() + zeroFill(this.minutes(), 2) +
  1392. zeroFill(this.seconds(), 2);
  1393. });
  1394. function meridiem(token, lowercase) {
  1395. addFormatToken(token, 0, 0, function () {
  1396. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  1397. });
  1398. }
  1399. meridiem('a', true);
  1400. meridiem('A', false);
  1401. // ALIASES
  1402. addUnitAlias('hour', 'h');
  1403. // PRIORITY
  1404. addUnitPriority('hour', 13);
  1405. // PARSING
  1406. function matchMeridiem(isStrict, locale) {
  1407. return locale._meridiemParse;
  1408. }
  1409. addRegexToken('a', matchMeridiem);
  1410. addRegexToken('A', matchMeridiem);
  1411. addRegexToken('H', match1to2);
  1412. addRegexToken('h', match1to2);
  1413. addRegexToken('HH', match1to2, match2);
  1414. addRegexToken('hh', match1to2, match2);
  1415. addRegexToken('hmm', match3to4);
  1416. addRegexToken('hmmss', match5to6);
  1417. addRegexToken('Hmm', match3to4);
  1418. addRegexToken('Hmmss', match5to6);
  1419. addParseToken(['H', 'HH'], HOUR);
  1420. addParseToken(['a', 'A'], function (input, array, config) {
  1421. config._isPm = config._locale.isPM(input);
  1422. config._meridiem = input;
  1423. });
  1424. addParseToken(['h', 'hh'], function (input, array, config) {
  1425. array[HOUR] = toInt(input);
  1426. getParsingFlags(config).bigHour = true;
  1427. });
  1428. addParseToken('hmm', function (input, array, config) {
  1429. var pos = input.length - 2;
  1430. array[HOUR] = toInt(input.substr(0, pos));
  1431. array[MINUTE] = toInt(input.substr(pos));
  1432. getParsingFlags(config).bigHour = true;
  1433. });
  1434. addParseToken('hmmss', function (input, array, config) {
  1435. var pos1 = input.length - 4;
  1436. var pos2 = input.length - 2;
  1437. array[HOUR] = toInt(input.substr(0, pos1));
  1438. array[MINUTE] = toInt(input.substr(pos1, 2));
  1439. array[SECOND] = toInt(input.substr(pos2));
  1440. getParsingFlags(config).bigHour = true;
  1441. });
  1442. addParseToken('Hmm', function (input, array, config) {
  1443. var pos = input.length - 2;
  1444. array[HOUR] = toInt(input.substr(0, pos));
  1445. array[MINUTE] = toInt(input.substr(pos));
  1446. });
  1447. addParseToken('Hmmss', function (input, array, config) {
  1448. var pos1 = input.length - 4;
  1449. var pos2 = input.length - 2;
  1450. array[HOUR] = toInt(input.substr(0, pos1));
  1451. array[MINUTE] = toInt(input.substr(pos1, 2));
  1452. array[SECOND] = toInt(input.substr(pos2));
  1453. });
  1454. // LOCALES
  1455. function localeIsPM(input) {
  1456. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  1457. // Using charAt should be more compatible.
  1458. return ((input + '').toLowerCase().charAt(0) === 'p');
  1459. }
  1460. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  1461. function localeMeridiem(hours, minutes, isLower) {
  1462. if (hours > 11) {
  1463. return isLower ? 'pm' : 'PM';
  1464. } else {
  1465. return isLower ? 'am' : 'AM';
  1466. }
  1467. }
  1468. // MOMENTS
  1469. // Setting the hour should keep the time, because the user explicitly
  1470. // specified which hour he wants. So trying to maintain the same hour (in
  1471. // a new timezone) makes sense. Adding/subtracting hours does not follow
  1472. // this rule.
  1473. var getSetHour = makeGetSet('Hours', true);
  1474. // months
  1475. // week
  1476. // weekdays
  1477. // meridiem
  1478. var baseConfig = {
  1479. calendar: defaultCalendar,
  1480. longDateFormat: defaultLongDateFormat,
  1481. invalidDate: defaultInvalidDate,
  1482. ordinal: defaultOrdinal,
  1483. ordinalParse: defaultOrdinalParse,
  1484. relativeTime: defaultRelativeTime,
  1485. months: defaultLocaleMonths,
  1486. monthsShort: defaultLocaleMonthsShort,
  1487. week: defaultLocaleWeek,
  1488. weekdays: defaultLocaleWeekdays,
  1489. weekdaysMin: defaultLocaleWeekdaysMin,
  1490. weekdaysShort: defaultLocaleWeekdaysShort,
  1491. meridiemParse: defaultLocaleMeridiemParse
  1492. };
  1493. // internal storage for locale config files
  1494. var locales = {};
  1495. var localeFamilies = {};
  1496. var globalLocale;
  1497. function normalizeLocale(key) {
  1498. return key ? key.toLowerCase().replace('_', '-') : key;
  1499. }
  1500. // pick the locale from the array
  1501. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  1502. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  1503. function chooseLocale(names) {
  1504. var i = 0, j, next, locale, split;
  1505. while (i < names.length) {
  1506. split = normalizeLocale(names[i]).split('-');
  1507. j = split.length;
  1508. next = normalizeLocale(names[i + 1]);
  1509. next = next ? next.split('-') : null;
  1510. while (j > 0) {
  1511. locale = loadLocale(split.slice(0, j).join('-'));
  1512. if (locale) {
  1513. return locale;
  1514. }
  1515. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  1516. //the next array item is better than a shallower substring of this one
  1517. break;
  1518. }
  1519. j--;
  1520. }
  1521. i++;
  1522. }
  1523. return null;
  1524. }
  1525. function loadLocale(name) {
  1526. var oldLocale = null;
  1527. // TODO: Find a better way to register and load all the locales in Node
  1528. if (!locales[name] && (typeof module !== 'undefined') &&
  1529. module && module.exports) {
  1530. try {
  1531. oldLocale = globalLocale._abbr;
  1532. require('./locale/' + name);
  1533. // because defineLocale currently also sets the global locale, we
  1534. // want to undo that for lazy loaded locales
  1535. getSetGlobalLocale(oldLocale);
  1536. } catch (e) { }
  1537. }
  1538. return locales[name];
  1539. }
  1540. // This function will load locale and then set the global locale. If
  1541. // no arguments are passed in, it will simply return the current global
  1542. // locale key.
  1543. function getSetGlobalLocale(key, values) {
  1544. var data;
  1545. if (key) {
  1546. if (isUndefined(values)) {
  1547. data = getLocale(key);
  1548. }
  1549. else {
  1550. data = defineLocale(key, values);
  1551. }
  1552. if (data) {
  1553. // moment.duration._locale = moment._locale = data;
  1554. globalLocale = data;
  1555. }
  1556. }
  1557. return globalLocale._abbr;
  1558. }
  1559. function defineLocale(name, config) {
  1560. if (config !== null) {
  1561. var parentConfig = baseConfig;
  1562. config.abbr = name;
  1563. if (locales[name] != null) {
  1564. deprecateSimple('defineLocaleOverride',
  1565. 'use moment.updateLocale(localeName, config) to change ' +
  1566. 'an existing locale. moment.defineLocale(localeName, ' +
  1567. 'config) should only be used for creating a new locale ' +
  1568. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
  1569. parentConfig = locales[name]._config;
  1570. } else if (config.parentLocale != null) {
  1571. if (locales[config.parentLocale] != null) {
  1572. parentConfig = locales[config.parentLocale]._config;
  1573. } else {
  1574. if (!localeFamilies[config.parentLocale]) {
  1575. localeFamilies[config.parentLocale] = [];
  1576. }
  1577. localeFamilies[config.parentLocale].push({
  1578. name: name,
  1579. config: config
  1580. });
  1581. return null;
  1582. }
  1583. }
  1584. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  1585. if (localeFamilies[name]) {
  1586. localeFamilies[name].forEach(function (x) {
  1587. defineLocale(x.name, x.config);
  1588. });
  1589. }
  1590. // backwards compat for now: also set the locale
  1591. // make sure we set the locale AFTER all child locales have been
  1592. // created, so we won't end up with the child locale set.
  1593. getSetGlobalLocale(name);
  1594. return locales[name];
  1595. } else {
  1596. // useful for testing
  1597. delete locales[name];
  1598. return null;
  1599. }
  1600. }
  1601. function updateLocale(name, config) {
  1602. if (config != null) {
  1603. var locale, parentConfig = baseConfig;
  1604. // MERGE
  1605. if (locales[name] != null) {
  1606. parentConfig = locales[name]._config;
  1607. }
  1608. config = mergeConfigs(parentConfig, config);
  1609. locale = new Locale(config);
  1610. locale.parentLocale = locales[name];
  1611. locales[name] = locale;
  1612. // backwards compat for now: also set the locale
  1613. getSetGlobalLocale(name);
  1614. } else {
  1615. // pass null for config to unupdate, useful for tests
  1616. if (locales[name] != null) {
  1617. if (locales[name].parentLocale != null) {
  1618. locales[name] = locales[name].parentLocale;
  1619. } else if (locales[name] != null) {
  1620. delete locales[name];
  1621. }
  1622. }
  1623. }
  1624. return locales[name];
  1625. }
  1626. // returns locale data
  1627. function getLocale(key) {
  1628. var locale;
  1629. if (key && key._locale && key._locale._abbr) {
  1630. key = key._locale._abbr;
  1631. }
  1632. if (!key) {
  1633. return globalLocale;
  1634. }
  1635. if (!isArray(key)) {
  1636. //short-circuit everything else
  1637. locale = loadLocale(key);
  1638. if (locale) {
  1639. return locale;
  1640. }
  1641. key = [key];
  1642. }
  1643. return chooseLocale(key);
  1644. }
  1645. function listLocales() {
  1646. return keys$1(locales);
  1647. }
  1648. function checkOverflow(m) {
  1649. var overflow;
  1650. var a = m._a;
  1651. if (a && getParsingFlags(m).overflow === -2) {
  1652. overflow =
  1653. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  1654. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  1655. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  1656. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  1657. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  1658. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  1659. -1;
  1660. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  1661. overflow = DATE;
  1662. }
  1663. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  1664. overflow = WEEK;
  1665. }
  1666. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  1667. overflow = WEEKDAY;
  1668. }
  1669. getParsingFlags(m).overflow = overflow;
  1670. }
  1671. return m;
  1672. }
  1673. // iso 8601 regex
  1674. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  1675. var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  1676. var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  1677. var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  1678. var isoDates = [
  1679. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  1680. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  1681. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  1682. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  1683. ['YYYY-DDD', /\d{4}-\d{3}/],
  1684. ['YYYY-MM', /\d{4}-\d\d/, false],
  1685. ['YYYYYYMMDD', /[+-]\d{10}/],
  1686. ['YYYYMMDD', /\d{8}/],
  1687. // YYYYMM is NOT allowed by the standard
  1688. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  1689. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  1690. ['YYYYDDD', /\d{7}/]
  1691. ];
  1692. // iso time formats and regexes
  1693. var isoTimes = [
  1694. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  1695. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  1696. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  1697. ['HH:mm', /\d\d:\d\d/],
  1698. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  1699. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  1700. ['HHmmss', /\d\d\d\d\d\d/],
  1701. ['HHmm', /\d\d\d\d/],
  1702. ['HH', /\d\d/]
  1703. ];
  1704. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  1705. // date from iso format
  1706. function configFromISO(config) {
  1707. var i, l,
  1708. string = config._i,
  1709. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  1710. allowTime, dateFormat, timeFormat, tzFormat;
  1711. if (match) {
  1712. getParsingFlags(config).iso = true;
  1713. for (i = 0, l = isoDates.length; i < l; i++) {
  1714. if (isoDates[i][1].exec(match[1])) {
  1715. dateFormat = isoDates[i][0];
  1716. allowTime = isoDates[i][2] !== false;
  1717. break;
  1718. }
  1719. }
  1720. if (dateFormat == null) {
  1721. config._isValid = false;
  1722. return;
  1723. }
  1724. if (match[3]) {
  1725. for (i = 0, l = isoTimes.length; i < l; i++) {
  1726. if (isoTimes[i][1].exec(match[3])) {
  1727. // match[2] should be 'T' or space
  1728. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  1729. break;
  1730. }
  1731. }
  1732. if (timeFormat == null) {
  1733. config._isValid = false;
  1734. return;
  1735. }
  1736. }
  1737. if (!allowTime && timeFormat != null) {
  1738. config._isValid = false;
  1739. return;
  1740. }
  1741. if (match[4]) {
  1742. if (tzRegex.exec(match[4])) {
  1743. tzFormat = 'Z';
  1744. } else {
  1745. config._isValid = false;
  1746. return;
  1747. }
  1748. }
  1749. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  1750. configFromStringAndFormat(config);
  1751. } else {
  1752. config._isValid = false;
  1753. }
  1754. }
  1755. // date from iso format or fallback
  1756. function configFromString(config) {
  1757. var matched = aspNetJsonRegex.exec(config._i);
  1758. if (matched !== null) {
  1759. config._d = new Date(+matched[1]);
  1760. return;
  1761. }
  1762. configFromISO(config);
  1763. if (config._isValid === false) {
  1764. delete config._isValid;
  1765. hooks.createFromInputFallback(config);
  1766. }
  1767. }
  1768. hooks.createFromInputFallback = deprecate(
  1769. 'value provided is not in a recognized ISO format. moment construction falls back to js Date(), ' +
  1770. 'which is not reliable across all browsers and versions. Non ISO date formats are ' +
  1771. 'discouraged and will be removed in an upcoming major release. Please refer to ' +
  1772. 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  1773. function (config) {
  1774. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  1775. }
  1776. );
  1777. // Pick the first defined of two or three arguments.
  1778. function defaults(a, b, c) {
  1779. if (a != null) {
  1780. return a;
  1781. }
  1782. if (b != null) {
  1783. return b;
  1784. }
  1785. return c;
  1786. }
  1787. function currentDateArray(config) {
  1788. // hooks is actually the exported moment object
  1789. var nowValue = new Date(hooks.now());
  1790. if (config._useUTC) {
  1791. return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  1792. }
  1793. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  1794. }
  1795. // convert an array to a date.
  1796. // the array should mirror the parameters below
  1797. // note: all values past the year are optional and will default to the lowest possible value.
  1798. // [year, month, day , hour, minute, second, millisecond]
  1799. function configFromArray(config) {
  1800. var i, date, input = [], currentDate, yearToUse;
  1801. if (config._d) {
  1802. return;
  1803. }
  1804. currentDate = currentDateArray(config);
  1805. //compute day of the year from weeks and weekdays
  1806. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  1807. dayOfYearFromWeekInfo(config);
  1808. }
  1809. //if the day of the year is set, figure out what it is
  1810. if (config._dayOfYear) {
  1811. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  1812. if (config._dayOfYear > daysInYear(yearToUse)) {
  1813. getParsingFlags(config)._overflowDayOfYear = true;
  1814. }
  1815. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  1816. config._a[MONTH] = date.getUTCMonth();
  1817. config._a[DATE] = date.getUTCDate();
  1818. }
  1819. // Default to current date.
  1820. // * if no year, month, day of month are given, default to today
  1821. // * if day of month is given, default month and year
  1822. // * if month is given, default only year
  1823. // * if year is given, don't default anything
  1824. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  1825. config._a[i] = input[i] = currentDate[i];
  1826. }
  1827. // Zero out whatever was not defaulted, including time
  1828. for (; i < 7; i++) {
  1829. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  1830. }
  1831. // Check for 24:00:00.000
  1832. if (config._a[HOUR] === 24 &&
  1833. config._a[MINUTE] === 0 &&
  1834. config._a[SECOND] === 0 &&
  1835. config._a[MILLISECOND] === 0) {
  1836. config._nextDay = true;
  1837. config._a[HOUR] = 0;
  1838. }
  1839. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  1840. // Apply timezone offset from input. The actual utcOffset can be changed
  1841. // with parseZone.
  1842. if (config._tzm != null) {
  1843. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  1844. }
  1845. if (config._nextDay) {
  1846. config._a[HOUR] = 24;
  1847. }
  1848. }
  1849. function dayOfYearFromWeekInfo(config) {
  1850. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  1851. w = config._w;
  1852. if (w.GG != null || w.W != null || w.E != null) {
  1853. dow = 1;
  1854. doy = 4;
  1855. // TODO: We need to take the current isoWeekYear, but that depends on
  1856. // how we interpret now (local, utc, fixed offset). So create
  1857. // a now version of current config (take local/utc/offset flags, and
  1858. // create now).
  1859. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
  1860. week = defaults(w.W, 1);
  1861. weekday = defaults(w.E, 1);
  1862. if (weekday < 1 || weekday > 7) {
  1863. weekdayOverflow = true;
  1864. }
  1865. } else {
  1866. dow = config._locale._week.dow;
  1867. doy = config._locale._week.doy;
  1868. var curWeek = weekOfYear(createLocal(), dow, doy);
  1869. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  1870. // Default to current week.
  1871. week = defaults(w.w, curWeek.week);
  1872. if (w.d != null) {
  1873. // weekday -- low day numbers are considered next week
  1874. weekday = w.d;
  1875. if (weekday < 0 || weekday > 6) {
  1876. weekdayOverflow = true;
  1877. }
  1878. } else if (w.e != null) {
  1879. // local weekday -- counting starts from begining of week
  1880. weekday = w.e + dow;
  1881. if (w.e < 0 || w.e > 6) {
  1882. weekdayOverflow = true;
  1883. }
  1884. } else {
  1885. // default to begining of week
  1886. weekday = dow;
  1887. }
  1888. }
  1889. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  1890. getParsingFlags(config)._overflowWeeks = true;
  1891. } else if (weekdayOverflow != null) {
  1892. getParsingFlags(config)._overflowWeekday = true;
  1893. } else {
  1894. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  1895. config._a[YEAR] = temp.year;
  1896. config._dayOfYear = temp.dayOfYear;
  1897. }
  1898. }
  1899. // constant that refers to the ISO standard
  1900. hooks.ISO_8601 = function () { };
  1901. // date from string and format string
  1902. function configFromStringAndFormat(config) {
  1903. // TODO: Move this to another part of the creation flow to prevent circular deps
  1904. if (config._f === hooks.ISO_8601) {
  1905. configFromISO(config);
  1906. return;
  1907. }
  1908. config._a = [];
  1909. getParsingFlags(config).empty = true;
  1910. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  1911. var string = '' + config._i,
  1912. i, parsedInput, tokens, token, skipped,
  1913. stringLength = string.length,
  1914. totalParsedInputLength = 0;
  1915. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  1916. for (i = 0; i < tokens.length; i++) {
  1917. token = tokens[i];
  1918. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  1919. // console.log('token', token, 'parsedInput', parsedInput,
  1920. // 'regex', getParseRegexForToken(token, config));
  1921. if (parsedInput) {
  1922. skipped = string.substr(0, string.indexOf(parsedInput));
  1923. if (skipped.length > 0) {
  1924. getParsingFlags(config).unusedInput.push(skipped);
  1925. }
  1926. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  1927. totalParsedInputLength += parsedInput.length;
  1928. }
  1929. // don't parse if it's not a known token
  1930. if (formatTokenFunctions[token]) {
  1931. if (parsedInput) {
  1932. getParsingFlags(config).empty = false;
  1933. }
  1934. else {
  1935. getParsingFlags(config).unusedTokens.push(token);
  1936. }
  1937. addTimeToArrayFromToken(token, parsedInput, config);
  1938. }
  1939. else if (config._strict && !parsedInput) {
  1940. getParsingFlags(config).unusedTokens.push(token);
  1941. }
  1942. }
  1943. // add remaining unparsed input length to the string
  1944. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  1945. if (string.length > 0) {
  1946. getParsingFlags(config).unusedInput.push(string);
  1947. }
  1948. // clear _12h flag if hour is <= 12
  1949. if (config._a[HOUR] <= 12 &&
  1950. getParsingFlags(config).bigHour === true &&
  1951. config._a[HOUR] > 0) {
  1952. getParsingFlags(config).bigHour = undefined;
  1953. }
  1954. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  1955. getParsingFlags(config).meridiem = config._meridiem;
  1956. // handle meridiem
  1957. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  1958. configFromArray(config);
  1959. checkOverflow(config);
  1960. }
  1961. function meridiemFixWrap(locale, hour, meridiem) {
  1962. var isPm;
  1963. if (meridiem == null) {
  1964. // nothing to do
  1965. return hour;
  1966. }
  1967. if (locale.meridiemHour != null) {
  1968. return locale.meridiemHour(hour, meridiem);
  1969. } else if (locale.isPM != null) {
  1970. // Fallback
  1971. isPm = locale.isPM(meridiem);
  1972. if (isPm && hour < 12) {
  1973. hour += 12;
  1974. }
  1975. if (!isPm && hour === 12) {
  1976. hour = 0;
  1977. }
  1978. return hour;
  1979. } else {
  1980. // this is not supposed to happen
  1981. return hour;
  1982. }
  1983. }
  1984. // date from string and array of format strings
  1985. function configFromStringAndArray(config) {
  1986. var tempConfig,
  1987. bestMoment,
  1988. scoreToBeat,
  1989. i,
  1990. currentScore;
  1991. if (config._f.length === 0) {
  1992. getParsingFlags(config).invalidFormat = true;
  1993. config._d = new Date(NaN);
  1994. return;
  1995. }
  1996. for (i = 0; i < config._f.length; i++) {
  1997. currentScore = 0;
  1998. tempConfig = copyConfig({}, config);
  1999. if (config._useUTC != null) {
  2000. tempConfig._useUTC = config._useUTC;
  2001. }
  2002. tempConfig._f = config._f[i];
  2003. configFromStringAndFormat(tempConfig);
  2004. if (!isValid(tempConfig)) {
  2005. continue;
  2006. }
  2007. // if there is any input that was not parsed add a penalty for that format
  2008. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  2009. //or tokens
  2010. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  2011. getParsingFlags(tempConfig).score = currentScore;
  2012. if (scoreToBeat == null || currentScore < scoreToBeat) {
  2013. scoreToBeat = currentScore;
  2014. bestMoment = tempConfig;
  2015. }
  2016. }
  2017. extend(config, bestMoment || tempConfig);
  2018. }
  2019. function configFromObject(config) {
  2020. if (config._d) {
  2021. return;
  2022. }
  2023. var i = normalizeObjectUnits(config._i);
  2024. config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  2025. return obj && parseInt(obj, 10);
  2026. });
  2027. configFromArray(config);
  2028. }
  2029. function createFromConfig(config) {
  2030. var res = new Moment(checkOverflow(prepareConfig(config)));
  2031. if (res._nextDay) {
  2032. // Adding is smart enough around DST
  2033. res.add(1, 'd');
  2034. res._nextDay = undefined;
  2035. }
  2036. return res;
  2037. }
  2038. function prepareConfig(config) {
  2039. var input = config._i,
  2040. format = config._f;
  2041. config._locale = config._locale || getLocale(config._l);
  2042. if (input === null || (format === undefined && input === '')) {
  2043. return createInvalid({ nullInput: true });
  2044. }
  2045. if (typeof input === 'string') {
  2046. config._i = input = config._locale.preparse(input);
  2047. }
  2048. if (isMoment(input)) {
  2049. return new Moment(checkOverflow(input));
  2050. } else if (isDate(input)) {
  2051. config._d = input;
  2052. } else if (isArray(format)) {
  2053. configFromStringAndArray(config);
  2054. } else if (format) {
  2055. configFromStringAndFormat(config);
  2056. } else {
  2057. configFromInput(config);
  2058. }
  2059. if (!isValid(config)) {
  2060. config._d = null;
  2061. }
  2062. return config;
  2063. }
  2064. function configFromInput(config) {
  2065. var input = config._i;
  2066. if (input === undefined) {
  2067. config._d = new Date(hooks.now());
  2068. } else if (isDate(input)) {
  2069. config._d = new Date(input.valueOf());
  2070. } else if (typeof input === 'string') {
  2071. configFromString(config);
  2072. } else if (isArray(input)) {
  2073. config._a = map(input.slice(0), function (obj) {
  2074. return parseInt(obj, 10);
  2075. });
  2076. configFromArray(config);
  2077. } else if (typeof (input) === 'object') {
  2078. configFromObject(config);
  2079. } else if (isNumber(input)) {
  2080. // from milliseconds
  2081. config._d = new Date(input);
  2082. } else {
  2083. hooks.createFromInputFallback(config);
  2084. }
  2085. }
  2086. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  2087. var c = {};
  2088. if (locale === true || locale === false) {
  2089. strict = locale;
  2090. locale = undefined;
  2091. }
  2092. if ((isObject(input) && isObjectEmpty(input)) ||
  2093. (isArray(input) && input.length === 0)) {
  2094. input = undefined;
  2095. }
  2096. // object construction must be done this way.
  2097. // https://github.com/moment/moment/issues/1423
  2098. c._isAMomentObject = true;
  2099. c._useUTC = c._isUTC = isUTC;
  2100. c._l = locale;
  2101. c._i = input;
  2102. c._f = format;
  2103. c._strict = strict;
  2104. return createFromConfig(c);
  2105. }
  2106. function createLocal(input, format, locale, strict) {
  2107. return createLocalOrUTC(input, format, locale, strict, false);
  2108. }
  2109. var prototypeMin = deprecate(
  2110. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  2111. function () {
  2112. var other = createLocal.apply(null, arguments);
  2113. if (this.isValid() && other.isValid()) {
  2114. return other < this ? this : other;
  2115. } else {
  2116. return createInvalid();
  2117. }
  2118. }
  2119. );
  2120. var prototypeMax = deprecate(
  2121. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  2122. function () {
  2123. var other = createLocal.apply(null, arguments);
  2124. if (this.isValid() && other.isValid()) {
  2125. return other > this ? this : other;
  2126. } else {
  2127. return createInvalid();
  2128. }
  2129. }
  2130. );
  2131. // Pick a moment m from moments so that m[fn](other) is true for all
  2132. // other. This relies on the function fn to be transitive.
  2133. //
  2134. // moments should either be an array of moment objects or an array, whose
  2135. // first element is an array of moment objects.
  2136. function pickBy(fn, moments) {
  2137. var res, i;
  2138. if (moments.length === 1 && isArray(moments[0])) {
  2139. moments = moments[0];
  2140. }
  2141. if (!moments.length) {
  2142. return createLocal();
  2143. }
  2144. res = moments[0];
  2145. for (i = 1; i < moments.length; ++i) {
  2146. if (!moments[i].isValid() || moments[i][fn](res)) {
  2147. res = moments[i];
  2148. }
  2149. }
  2150. return res;
  2151. }
  2152. // TODO: Use [].sort instead?
  2153. function min() {
  2154. var args = [].slice.call(arguments, 0);
  2155. return pickBy('isBefore', args);
  2156. }
  2157. function max() {
  2158. var args = [].slice.call(arguments, 0);
  2159. return pickBy('isAfter', args);
  2160. }
  2161. var now = function () {
  2162. return Date.now ? Date.now() : +(new Date());
  2163. };
  2164. function Duration(duration) {
  2165. var normalizedInput = normalizeObjectUnits(duration),
  2166. years = normalizedInput.year || 0,
  2167. quarters = normalizedInput.quarter || 0,
  2168. months = normalizedInput.month || 0,
  2169. weeks = normalizedInput.week || 0,
  2170. days = normalizedInput.day || 0,
  2171. hours = normalizedInput.hour || 0,
  2172. minutes = normalizedInput.minute || 0,
  2173. seconds = normalizedInput.second || 0,
  2174. milliseconds = normalizedInput.millisecond || 0;
  2175. // representation for dateAddRemove
  2176. this._milliseconds = +milliseconds +
  2177. seconds * 1e3 + // 1000
  2178. minutes * 6e4 + // 1000 * 60
  2179. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  2180. // Because of dateAddRemove treats 24 hours as different from a
  2181. // day when working around DST, we need to store them separately
  2182. this._days = +days +
  2183. weeks * 7;
  2184. // It is impossible translate months into days without knowing
  2185. // which months you are are talking about, so we have to store
  2186. // it separately.
  2187. this._months = +months +
  2188. quarters * 3 +
  2189. years * 12;
  2190. this._data = {};
  2191. this._locale = getLocale();
  2192. this._bubble();
  2193. }
  2194. function isDuration(obj) {
  2195. return obj instanceof Duration;
  2196. }
  2197. function absRound(number) {
  2198. if (number < 0) {
  2199. return Math.round(-1 * number) * -1;
  2200. } else {
  2201. return Math.round(number);
  2202. }
  2203. }
  2204. // FORMATTING
  2205. function offset(token, separator) {
  2206. addFormatToken(token, 0, 0, function () {
  2207. var offset = this.utcOffset();
  2208. var sign = '+';
  2209. if (offset < 0) {
  2210. offset = -offset;
  2211. sign = '-';
  2212. }
  2213. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  2214. });
  2215. }
  2216. offset('Z', ':');
  2217. offset('ZZ', '');
  2218. // PARSING
  2219. addRegexToken('Z', matchShortOffset);
  2220. addRegexToken('ZZ', matchShortOffset);
  2221. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  2222. config._useUTC = true;
  2223. config._tzm = offsetFromString(matchShortOffset, input);
  2224. });
  2225. // HELPERS
  2226. // timezone chunker
  2227. // '+10:00' > ['10', '00']
  2228. // '-1530' > ['-15', '30']
  2229. var chunkOffset = /([\+\-]|\d\d)/gi;
  2230. function offsetFromString(matcher, string) {
  2231. var matches = (string || '').match(matcher);
  2232. if (matches === null) {
  2233. return null;
  2234. }
  2235. var chunk = matches[matches.length - 1] || [];
  2236. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  2237. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  2238. return minutes === 0 ?
  2239. 0 :
  2240. parts[0] === '+' ? minutes : -minutes;
  2241. }
  2242. // Return a moment from input, that is local/utc/zone equivalent to model.
  2243. function cloneWithOffset(input, model) {
  2244. var res, diff;
  2245. if (model._isUTC) {
  2246. res = model.clone();
  2247. diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
  2248. // Use low-level api, because this fn is low-level api.
  2249. res._d.setTime(res._d.valueOf() + diff);
  2250. hooks.updateOffset(res, false);
  2251. return res;
  2252. } else {
  2253. return createLocal(input).local();
  2254. }
  2255. }
  2256. function getDateOffset(m) {
  2257. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  2258. // https://github.com/moment/moment/pull/1871
  2259. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  2260. }
  2261. // HOOKS
  2262. // This function will be called whenever a moment is mutated.
  2263. // It is intended to keep the offset in sync with the timezone.
  2264. hooks.updateOffset = function () { };
  2265. // MOMENTS
  2266. // keepLocalTime = true means only change the timezone, without
  2267. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  2268. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  2269. // +0200, so we adjust the time as needed, to be valid.
  2270. //
  2271. // Keeping the time actually adds/subtracts (one hour)
  2272. // from the actual represented time. That is why we call updateOffset
  2273. // a second time. In case it wants us to change the offset again
  2274. // _changeInProgress == true case, then we have to adjust, because
  2275. // there is no such time in the given timezone.
  2276. function getSetOffset(input, keepLocalTime) {
  2277. var offset = this._offset || 0,
  2278. localAdjust;
  2279. if (!this.isValid()) {
  2280. return input != null ? this : NaN;
  2281. }
  2282. if (input != null) {
  2283. if (typeof input === 'string') {
  2284. input = offsetFromString(matchShortOffset, input);
  2285. if (input === null) {
  2286. return this;
  2287. }
  2288. } else if (Math.abs(input) < 16) {
  2289. input = input * 60;
  2290. }
  2291. if (!this._isUTC && keepLocalTime) {
  2292. localAdjust = getDateOffset(this);
  2293. }
  2294. this._offset = input;
  2295. this._isUTC = true;
  2296. if (localAdjust != null) {
  2297. this.add(localAdjust, 'm');
  2298. }
  2299. if (offset !== input) {
  2300. if (!keepLocalTime || this._changeInProgress) {
  2301. addSubtract(this, createDuration(input - offset, 'm'), 1, false);
  2302. } else if (!this._changeInProgress) {
  2303. this._changeInProgress = true;
  2304. hooks.updateOffset(this, true);
  2305. this._changeInProgress = null;
  2306. }
  2307. }
  2308. return this;
  2309. } else {
  2310. return this._isUTC ? offset : getDateOffset(this);
  2311. }
  2312. }
  2313. function getSetZone(input, keepLocalTime) {
  2314. if (input != null) {
  2315. if (typeof input !== 'string') {
  2316. input = -input;
  2317. }
  2318. this.utcOffset(input, keepLocalTime);
  2319. return this;
  2320. } else {
  2321. return -this.utcOffset();
  2322. }
  2323. }
  2324. function setOffsetToUTC(keepLocalTime) {
  2325. return this.utcOffset(0, keepLocalTime);
  2326. }
  2327. function setOffsetToLocal(keepLocalTime) {
  2328. if (this._isUTC) {
  2329. this.utcOffset(0, keepLocalTime);
  2330. this._isUTC = false;
  2331. if (keepLocalTime) {
  2332. this.subtract(getDateOffset(this), 'm');
  2333. }
  2334. }
  2335. return this;
  2336. }
  2337. function setOffsetToParsedOffset() {
  2338. if (this._tzm != null) {
  2339. this.utcOffset(this._tzm);
  2340. } else if (typeof this._i === 'string') {
  2341. var tZone = offsetFromString(matchOffset, this._i);
  2342. if (tZone != null) {
  2343. this.utcOffset(tZone);
  2344. }
  2345. else {
  2346. this.utcOffset(0, true);
  2347. }
  2348. }
  2349. return this;
  2350. }
  2351. function hasAlignedHourOffset(input) {
  2352. if (!this.isValid()) {
  2353. return false;
  2354. }
  2355. input = input ? createLocal(input).utcOffset() : 0;
  2356. return (this.utcOffset() - input) % 60 === 0;
  2357. }
  2358. function isDaylightSavingTime() {
  2359. return (
  2360. this.utcOffset() > this.clone().month(0).utcOffset() ||
  2361. this.utcOffset() > this.clone().month(5).utcOffset()
  2362. );
  2363. }
  2364. function isDaylightSavingTimeShifted() {
  2365. if (!isUndefined(this._isDSTShifted)) {
  2366. return this._isDSTShifted;
  2367. }
  2368. var c = {};
  2369. copyConfig(c, this);
  2370. c = prepareConfig(c);
  2371. if (c._a) {
  2372. var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  2373. this._isDSTShifted = this.isValid() &&
  2374. compareArrays(c._a, other.toArray()) > 0;
  2375. } else {
  2376. this._isDSTShifted = false;
  2377. }
  2378. return this._isDSTShifted;
  2379. }
  2380. function isLocal() {
  2381. return this.isValid() ? !this._isUTC : false;
  2382. }
  2383. function isUtcOffset() {
  2384. return this.isValid() ? this._isUTC : false;
  2385. }
  2386. function isUtc() {
  2387. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  2388. }
  2389. // ASP.NET json date format regex
  2390. var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
  2391. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  2392. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  2393. // and further modified to allow for strings containing both week and day
  2394. var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
  2395. function createDuration(input, key) {
  2396. var duration = input,
  2397. // matching against regexp is expensive, do it on demand
  2398. match = null,
  2399. sign,
  2400. ret,
  2401. diffRes;
  2402. if (isDuration(input)) {
  2403. duration = {
  2404. ms: input._milliseconds,
  2405. d: input._days,
  2406. M: input._months
  2407. };
  2408. } else if (isNumber(input)) {
  2409. duration = {};
  2410. if (key) {
  2411. duration[key] = input;
  2412. } else {
  2413. duration.milliseconds = input;
  2414. }
  2415. } else if (!!(match = aspNetRegex.exec(input))) {
  2416. sign = (match[1] === '-') ? -1 : 1;
  2417. duration = {
  2418. y: 0,
  2419. d: toInt(match[DATE]) * sign,
  2420. h: toInt(match[HOUR]) * sign,
  2421. m: toInt(match[MINUTE]) * sign,
  2422. s: toInt(match[SECOND]) * sign,
  2423. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
  2424. };
  2425. } else if (!!(match = isoRegex.exec(input))) {
  2426. sign = (match[1] === '-') ? -1 : 1;
  2427. duration = {
  2428. y: parseIso(match[2], sign),
  2429. M: parseIso(match[3], sign),
  2430. w: parseIso(match[4], sign),
  2431. d: parseIso(match[5], sign),
  2432. h: parseIso(match[6], sign),
  2433. m: parseIso(match[7], sign),
  2434. s: parseIso(match[8], sign)
  2435. };
  2436. } else if (duration == null) {// checks for null or undefined
  2437. duration = {};
  2438. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  2439. diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
  2440. duration = {};
  2441. duration.ms = diffRes.milliseconds;
  2442. duration.M = diffRes.months;
  2443. }
  2444. ret = new Duration(duration);
  2445. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  2446. ret._locale = input._locale;
  2447. }
  2448. return ret;
  2449. }
  2450. createDuration.fn = Duration.prototype;
  2451. function parseIso(inp, sign) {
  2452. // We'd normally use ~~inp for this, but unfortunately it also
  2453. // converts floats to ints.
  2454. // inp may be undefined, so careful calling replace on it.
  2455. var res = inp && parseFloat(inp.replace(',', '.'));
  2456. // apply sign while we're at it
  2457. return (isNaN(res) ? 0 : res) * sign;
  2458. }
  2459. function positiveMomentsDifference(base, other) {
  2460. var res = { milliseconds: 0, months: 0 };
  2461. res.months = other.month() - base.month() +
  2462. (other.year() - base.year()) * 12;
  2463. if (base.clone().add(res.months, 'M').isAfter(other)) {
  2464. --res.months;
  2465. }
  2466. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  2467. return res;
  2468. }
  2469. function momentsDifference(base, other) {
  2470. var res;
  2471. if (!(base.isValid() && other.isValid())) {
  2472. return { milliseconds: 0, months: 0 };
  2473. }
  2474. other = cloneWithOffset(other, base);
  2475. if (base.isBefore(other)) {
  2476. res = positiveMomentsDifference(base, other);
  2477. } else {
  2478. res = positiveMomentsDifference(other, base);
  2479. res.milliseconds = -res.milliseconds;
  2480. res.months = -res.months;
  2481. }
  2482. return res;
  2483. }
  2484. // TODO: remove 'name' arg after deprecation is removed
  2485. function createAdder(direction, name) {
  2486. return function (val, period) {
  2487. var dur, tmp;
  2488. //invert the arguments, but complain about it
  2489. if (period !== null && !isNaN(+period)) {
  2490. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
  2491. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
  2492. tmp = val; val = period; period = tmp;
  2493. }
  2494. val = typeof val === 'string' ? +val : val;
  2495. dur = createDuration(val, period);
  2496. addSubtract(this, dur, direction);
  2497. return this;
  2498. };
  2499. }
  2500. function addSubtract(mom, duration, isAdding, updateOffset) {
  2501. var milliseconds = duration._milliseconds,
  2502. days = absRound(duration._days),
  2503. months = absRound(duration._months);
  2504. if (!mom.isValid()) {
  2505. // No op
  2506. return;
  2507. }
  2508. updateOffset = updateOffset == null ? true : updateOffset;
  2509. if (milliseconds) {
  2510. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  2511. }
  2512. if (days) {
  2513. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  2514. }
  2515. if (months) {
  2516. setMonth(mom, get(mom, 'Month') + months * isAdding);
  2517. }
  2518. if (updateOffset) {
  2519. hooks.updateOffset(mom, days || months);
  2520. }
  2521. }
  2522. var add = createAdder(1, 'add');
  2523. var subtract = createAdder(-1, 'subtract');
  2524. function getCalendarFormat(myMoment, now) {
  2525. var diff = myMoment.diff(now, 'days', true);
  2526. return diff < -6 ? 'sameElse' :
  2527. diff < -1 ? 'lastWeek' :
  2528. diff < 0 ? 'lastDay' :
  2529. diff < 1 ? 'sameDay' :
  2530. diff < 2 ? 'nextDay' :
  2531. diff < 7 ? 'nextWeek' : 'sameElse';
  2532. }
  2533. function calendar$1(time, formats) {
  2534. // We want to compare the start of today, vs this.
  2535. // Getting start-of-today depends on whether we're local/utc/offset or not.
  2536. var now = time || createLocal(),
  2537. sod = cloneWithOffset(now, this).startOf('day'),
  2538. format = hooks.calendarFormat(this, sod) || 'sameElse';
  2539. var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
  2540. return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
  2541. }
  2542. function clone() {
  2543. return new Moment(this);
  2544. }
  2545. function isAfter(input, units) {
  2546. var localInput = isMoment(input) ? input : createLocal(input);
  2547. if (!(this.isValid() && localInput.isValid())) {
  2548. return false;
  2549. }
  2550. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  2551. if (units === 'millisecond') {
  2552. return this.valueOf() > localInput.valueOf();
  2553. } else {
  2554. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  2555. }
  2556. }
  2557. function isBefore(input, units) {
  2558. var localInput = isMoment(input) ? input : createLocal(input);
  2559. if (!(this.isValid() && localInput.isValid())) {
  2560. return false;
  2561. }
  2562. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  2563. if (units === 'millisecond') {
  2564. return this.valueOf() < localInput.valueOf();
  2565. } else {
  2566. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  2567. }
  2568. }
  2569. function isBetween(from, to, units, inclusivity) {
  2570. inclusivity = inclusivity || '()';
  2571. return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
  2572. (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
  2573. }
  2574. function isSame(input, units) {
  2575. var localInput = isMoment(input) ? input : createLocal(input),
  2576. inputMs;
  2577. if (!(this.isValid() && localInput.isValid())) {
  2578. return false;
  2579. }
  2580. units = normalizeUnits(units || 'millisecond');
  2581. if (units === 'millisecond') {
  2582. return this.valueOf() === localInput.valueOf();
  2583. } else {
  2584. inputMs = localInput.valueOf();
  2585. return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
  2586. }
  2587. }
  2588. function isSameOrAfter(input, units) {
  2589. return this.isSame(input, units) || this.isAfter(input, units);
  2590. }
  2591. function isSameOrBefore(input, units) {
  2592. return this.isSame(input, units) || this.isBefore(input, units);
  2593. }
  2594. function diff(input, units, asFloat) {
  2595. var that,
  2596. zoneDelta,
  2597. delta, output;
  2598. if (!this.isValid()) {
  2599. return NaN;
  2600. }
  2601. that = cloneWithOffset(input, this);
  2602. if (!that.isValid()) {
  2603. return NaN;
  2604. }
  2605. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  2606. units = normalizeUnits(units);
  2607. if (units === 'year' || units === 'month' || units === 'quarter') {
  2608. output = monthDiff(this, that);
  2609. if (units === 'quarter') {
  2610. output = output / 3;
  2611. } else if (units === 'year') {
  2612. output = output / 12;
  2613. }
  2614. } else {
  2615. delta = this - that;
  2616. output = units === 'second' ? delta / 1e3 : // 1000
  2617. units === 'minute' ? delta / 6e4 : // 1000 * 60
  2618. units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
  2619. units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
  2620. units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
  2621. delta;
  2622. }
  2623. return asFloat ? output : absFloor(output);
  2624. }
  2625. function monthDiff(a, b) {
  2626. // difference in months
  2627. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  2628. // b is in (anchor - 1 month, anchor + 1 month)
  2629. anchor = a.clone().add(wholeMonthDiff, 'months'),
  2630. anchor2, adjust;
  2631. if (b - anchor < 0) {
  2632. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  2633. // linear across the month
  2634. adjust = (b - anchor) / (anchor - anchor2);
  2635. } else {
  2636. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  2637. // linear across the month
  2638. adjust = (b - anchor) / (anchor2 - anchor);
  2639. }
  2640. //check for negative zero, return zero if negative zero
  2641. return -(wholeMonthDiff + adjust) || 0;
  2642. }
  2643. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  2644. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  2645. function toString() {
  2646. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  2647. }
  2648. function toISOString() {
  2649. var m = this.clone().utc();
  2650. if (0 < m.year() && m.year() <= 9999) {
  2651. if (isFunction(Date.prototype.toISOString)) {
  2652. // native implementation is ~50x faster, use it when we can
  2653. return this.toDate().toISOString();
  2654. } else {
  2655. return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  2656. }
  2657. } else {
  2658. return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  2659. }
  2660. }
  2661. /**
  2662. * Return a human readable representation of a moment that can
  2663. * also be evaluated to get a new moment which is the same
  2664. *
  2665. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  2666. */
  2667. function inspect() {
  2668. if (!this.isValid()) {
  2669. return 'moment.invalid(/* ' + this._i + ' */)';
  2670. }
  2671. var func = 'moment';
  2672. var zone = '';
  2673. if (!this.isLocal()) {
  2674. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  2675. zone = 'Z';
  2676. }
  2677. var prefix = '[' + func + '("]';
  2678. var year = (0 < this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
  2679. var datetime = '-MM-DD[T]HH:mm:ss.SSS';
  2680. var suffix = zone + '[")]';
  2681. return this.format(prefix + year + datetime + suffix);
  2682. }
  2683. function format(inputString) {
  2684. if (!inputString) {
  2685. inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
  2686. }
  2687. var output = formatMoment(this, inputString);
  2688. return this.localeData().postformat(output);
  2689. }
  2690. function from(time, withoutSuffix) {
  2691. if (this.isValid() &&
  2692. ((isMoment(time) && time.isValid()) ||
  2693. createLocal(time).isValid())) {
  2694. return createDuration({ to: this, from: time }).locale(this.locale()).humanize(!withoutSuffix);
  2695. } else {
  2696. return this.localeData().invalidDate();
  2697. }
  2698. }
  2699. function fromNow(withoutSuffix) {
  2700. return this.from(createLocal(), withoutSuffix);
  2701. }
  2702. function to(time, withoutSuffix) {
  2703. if (this.isValid() &&
  2704. ((isMoment(time) && time.isValid()) ||
  2705. createLocal(time).isValid())) {
  2706. return createDuration({ from: this, to: time }).locale(this.locale()).humanize(!withoutSuffix);
  2707. } else {
  2708. return this.localeData().invalidDate();
  2709. }
  2710. }
  2711. function toNow(withoutSuffix) {
  2712. return this.to(createLocal(), withoutSuffix);
  2713. }
  2714. // If passed a locale key, it will set the locale for this
  2715. // instance. Otherwise, it will return the locale configuration
  2716. // variables for this instance.
  2717. function locale(key) {
  2718. var newLocaleData;
  2719. if (key === undefined) {
  2720. return this._locale._abbr;
  2721. } else {
  2722. newLocaleData = getLocale(key);
  2723. if (newLocaleData != null) {
  2724. this._locale = newLocaleData;
  2725. }
  2726. return this;
  2727. }
  2728. }
  2729. var lang = deprecate(
  2730. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  2731. function (key) {
  2732. if (key === undefined) {
  2733. return this.localeData();
  2734. } else {
  2735. return this.locale(key);
  2736. }
  2737. }
  2738. );
  2739. function localeData() {
  2740. return this._locale;
  2741. }
  2742. function startOf(units) {
  2743. units = normalizeUnits(units);
  2744. // the following switch intentionally omits break keywords
  2745. // to utilize falling through the cases.
  2746. switch (units) {
  2747. case 'year':
  2748. this.month(0);
  2749. /* falls through */
  2750. case 'quarter':
  2751. case 'month':
  2752. this.date(1);
  2753. /* falls through */
  2754. case 'week':
  2755. case 'isoWeek':
  2756. case 'day':
  2757. case 'date':
  2758. this.hours(0);
  2759. /* falls through */
  2760. case 'hour':
  2761. this.minutes(0);
  2762. /* falls through */
  2763. case 'minute':
  2764. this.seconds(0);
  2765. /* falls through */
  2766. case 'second':
  2767. this.milliseconds(0);
  2768. }
  2769. // weeks are a special case
  2770. if (units === 'week') {
  2771. this.weekday(0);
  2772. }
  2773. if (units === 'isoWeek') {
  2774. this.isoWeekday(1);
  2775. }
  2776. // quarters are also special
  2777. if (units === 'quarter') {
  2778. this.month(Math.floor(this.month() / 3) * 3);
  2779. }
  2780. return this;
  2781. }
  2782. function endOf(units) {
  2783. units = normalizeUnits(units);
  2784. if (units === undefined || units === 'millisecond') {
  2785. return this;
  2786. }
  2787. // 'date' is an alias for 'day', so it should be considered as such.
  2788. if (units === 'date') {
  2789. units = 'day';
  2790. }
  2791. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  2792. }
  2793. function valueOf() {
  2794. return this._d.valueOf() - ((this._offset || 0) * 60000);
  2795. }
  2796. function unix() {
  2797. return Math.floor(this.valueOf() / 1000);
  2798. }
  2799. function toDate() {
  2800. return new Date(this.valueOf());
  2801. }
  2802. function toArray() {
  2803. var m = this;
  2804. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  2805. }
  2806. function toObject() {
  2807. var m = this;
  2808. return {
  2809. years: m.year(),
  2810. months: m.month(),
  2811. date: m.date(),
  2812. hours: m.hours(),
  2813. minutes: m.minutes(),
  2814. seconds: m.seconds(),
  2815. milliseconds: m.milliseconds()
  2816. };
  2817. }
  2818. function toJSON() {
  2819. // new Date(NaN).toJSON() === null
  2820. return this.isValid() ? this.toISOString() : null;
  2821. }
  2822. function isValid$1() {
  2823. return isValid(this);
  2824. }
  2825. function parsingFlags() {
  2826. return extend({}, getParsingFlags(this));
  2827. }
  2828. function invalidAt() {
  2829. return getParsingFlags(this).overflow;
  2830. }
  2831. function creationData() {
  2832. return {
  2833. input: this._i,
  2834. format: this._f,
  2835. locale: this._locale,
  2836. isUTC: this._isUTC,
  2837. strict: this._strict
  2838. };
  2839. }
  2840. // FORMATTING
  2841. addFormatToken(0, ['gg', 2], 0, function () {
  2842. return this.weekYear() % 100;
  2843. });
  2844. addFormatToken(0, ['GG', 2], 0, function () {
  2845. return this.isoWeekYear() % 100;
  2846. });
  2847. function addWeekYearFormatToken(token, getter) {
  2848. addFormatToken(0, [token, token.length], 0, getter);
  2849. }
  2850. addWeekYearFormatToken('gggg', 'weekYear');
  2851. addWeekYearFormatToken('ggggg', 'weekYear');
  2852. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  2853. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  2854. // ALIASES
  2855. addUnitAlias('weekYear', 'gg');
  2856. addUnitAlias('isoWeekYear', 'GG');
  2857. // PRIORITY
  2858. addUnitPriority('weekYear', 1);
  2859. addUnitPriority('isoWeekYear', 1);
  2860. // PARSING
  2861. addRegexToken('G', matchSigned);
  2862. addRegexToken('g', matchSigned);
  2863. addRegexToken('GG', match1to2, match2);
  2864. addRegexToken('gg', match1to2, match2);
  2865. addRegexToken('GGGG', match1to4, match4);
  2866. addRegexToken('gggg', match1to4, match4);
  2867. addRegexToken('GGGGG', match1to6, match6);
  2868. addRegexToken('ggggg', match1to6, match6);
  2869. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  2870. week[token.substr(0, 2)] = toInt(input);
  2871. });
  2872. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  2873. week[token] = hooks.parseTwoDigitYear(input);
  2874. });
  2875. // MOMENTS
  2876. function getSetWeekYear(input) {
  2877. return getSetWeekYearHelper.call(this,
  2878. input,
  2879. this.week(),
  2880. this.weekday(),
  2881. this.localeData()._week.dow,
  2882. this.localeData()._week.doy);
  2883. }
  2884. function getSetISOWeekYear(input) {
  2885. return getSetWeekYearHelper.call(this,
  2886. input, this.isoWeek(), this.isoWeekday(), 1, 4);
  2887. }
  2888. function getISOWeeksInYear() {
  2889. return weeksInYear(this.year(), 1, 4);
  2890. }
  2891. function getWeeksInYear() {
  2892. var weekInfo = this.localeData()._week;
  2893. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  2894. }
  2895. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  2896. var weeksTarget;
  2897. if (input == null) {
  2898. return weekOfYear(this, dow, doy).year;
  2899. } else {
  2900. weeksTarget = weeksInYear(input, dow, doy);
  2901. if (week > weeksTarget) {
  2902. week = weeksTarget;
  2903. }
  2904. return setWeekAll.call(this, input, week, weekday, dow, doy);
  2905. }
  2906. }
  2907. function setWeekAll(weekYear, week, weekday, dow, doy) {
  2908. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  2909. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  2910. this.year(date.getUTCFullYear());
  2911. this.month(date.getUTCMonth());
  2912. this.date(date.getUTCDate());
  2913. return this;
  2914. }
  2915. // FORMATTING
  2916. addFormatToken('Q', 0, 'Qo', 'quarter');
  2917. // ALIASES
  2918. addUnitAlias('quarter', 'Q');
  2919. // PRIORITY
  2920. addUnitPriority('quarter', 7);
  2921. // PARSING
  2922. addRegexToken('Q', match1);
  2923. addParseToken('Q', function (input, array) {
  2924. array[MONTH] = (toInt(input) - 1) * 3;
  2925. });
  2926. // MOMENTS
  2927. function getSetQuarter(input) {
  2928. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  2929. }
  2930. // FORMATTING
  2931. addFormatToken('D', ['DD', 2], 'Do', 'date');
  2932. // ALIASES
  2933. addUnitAlias('date', 'D');
  2934. // PRIOROITY
  2935. addUnitPriority('date', 9);
  2936. // PARSING
  2937. addRegexToken('D', match1to2);
  2938. addRegexToken('DD', match1to2, match2);
  2939. addRegexToken('Do', function (isStrict, locale) {
  2940. return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
  2941. });
  2942. addParseToken(['D', 'DD'], DATE);
  2943. addParseToken('Do', function (input, array) {
  2944. array[DATE] = toInt(input.match(match1to2)[0], 10);
  2945. });
  2946. // MOMENTS
  2947. var getSetDayOfMonth = makeGetSet('Date', true);
  2948. // FORMATTING
  2949. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  2950. // ALIASES
  2951. addUnitAlias('dayOfYear', 'DDD');
  2952. // PRIORITY
  2953. addUnitPriority('dayOfYear', 4);
  2954. // PARSING
  2955. addRegexToken('DDD', match1to3);
  2956. addRegexToken('DDDD', match3);
  2957. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  2958. config._dayOfYear = toInt(input);
  2959. });
  2960. // HELPERS
  2961. // MOMENTS
  2962. function getSetDayOfYear(input) {
  2963. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  2964. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  2965. }
  2966. // FORMATTING
  2967. addFormatToken('m', ['mm', 2], 0, 'minute');
  2968. // ALIASES
  2969. addUnitAlias('minute', 'm');
  2970. // PRIORITY
  2971. addUnitPriority('minute', 14);
  2972. // PARSING
  2973. addRegexToken('m', match1to2);
  2974. addRegexToken('mm', match1to2, match2);
  2975. addParseToken(['m', 'mm'], MINUTE);
  2976. // MOMENTS
  2977. var getSetMinute = makeGetSet('Minutes', false);
  2978. // FORMATTING
  2979. addFormatToken('s', ['ss', 2], 0, 'second');
  2980. // ALIASES
  2981. addUnitAlias('second', 's');
  2982. // PRIORITY
  2983. addUnitPriority('second', 15);
  2984. // PARSING
  2985. addRegexToken('s', match1to2);
  2986. addRegexToken('ss', match1to2, match2);
  2987. addParseToken(['s', 'ss'], SECOND);
  2988. // MOMENTS
  2989. var getSetSecond = makeGetSet('Seconds', false);
  2990. // FORMATTING
  2991. addFormatToken('S', 0, 0, function () {
  2992. return ~~(this.millisecond() / 100);
  2993. });
  2994. addFormatToken(0, ['SS', 2], 0, function () {
  2995. return ~~(this.millisecond() / 10);
  2996. });
  2997. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  2998. addFormatToken(0, ['SSSS', 4], 0, function () {
  2999. return this.millisecond() * 10;
  3000. });
  3001. addFormatToken(0, ['SSSSS', 5], 0, function () {
  3002. return this.millisecond() * 100;
  3003. });
  3004. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  3005. return this.millisecond() * 1000;
  3006. });
  3007. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  3008. return this.millisecond() * 10000;
  3009. });
  3010. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  3011. return this.millisecond() * 100000;
  3012. });
  3013. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  3014. return this.millisecond() * 1000000;
  3015. });
  3016. // ALIASES
  3017. addUnitAlias('millisecond', 'ms');
  3018. // PRIORITY
  3019. addUnitPriority('millisecond', 16);
  3020. // PARSING
  3021. addRegexToken('S', match1to3, match1);
  3022. addRegexToken('SS', match1to3, match2);
  3023. addRegexToken('SSS', match1to3, match3);
  3024. var token;
  3025. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  3026. addRegexToken(token, matchUnsigned);
  3027. }
  3028. function parseMs(input, array) {
  3029. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  3030. }
  3031. for (token = 'S'; token.length <= 9; token += 'S') {
  3032. addParseToken(token, parseMs);
  3033. }
  3034. // MOMENTS
  3035. var getSetMillisecond = makeGetSet('Milliseconds', false);
  3036. // FORMATTING
  3037. addFormatToken('z', 0, 0, 'zoneAbbr');
  3038. addFormatToken('zz', 0, 0, 'zoneName');
  3039. // MOMENTS
  3040. function getZoneAbbr() {
  3041. return this._isUTC ? 'UTC' : '';
  3042. }
  3043. function getZoneName() {
  3044. return this._isUTC ? 'Coordinated Universal Time' : '';
  3045. }
  3046. var proto = Moment.prototype;
  3047. proto.add = add;
  3048. proto.calendar = calendar$1;
  3049. proto.clone = clone;
  3050. proto.diff = diff;
  3051. proto.endOf = endOf;
  3052. proto.format = format;
  3053. proto.from = from;
  3054. proto.fromNow = fromNow;
  3055. proto.to = to;
  3056. proto.toNow = toNow;
  3057. proto.get = stringGet;
  3058. proto.invalidAt = invalidAt;
  3059. proto.isAfter = isAfter;
  3060. proto.isBefore = isBefore;
  3061. proto.isBetween = isBetween;
  3062. proto.isSame = isSame;
  3063. proto.isSameOrAfter = isSameOrAfter;
  3064. proto.isSameOrBefore = isSameOrBefore;
  3065. proto.isValid = isValid$1;
  3066. proto.lang = lang;
  3067. proto.locale = locale;
  3068. proto.localeData = localeData;
  3069. proto.max = prototypeMax;
  3070. proto.min = prototypeMin;
  3071. proto.parsingFlags = parsingFlags;
  3072. proto.set = stringSet;
  3073. proto.startOf = startOf;
  3074. proto.subtract = subtract;
  3075. proto.toArray = toArray;
  3076. proto.toObject = toObject;
  3077. proto.toDate = toDate;
  3078. proto.toISOString = toISOString;
  3079. proto.inspect = inspect;
  3080. proto.toJSON = toJSON;
  3081. proto.toString = toString;
  3082. proto.unix = unix;
  3083. proto.valueOf = valueOf;
  3084. proto.creationData = creationData;
  3085. // Year
  3086. proto.year = getSetYear;
  3087. proto.isLeapYear = getIsLeapYear;
  3088. // Week Year
  3089. proto.weekYear = getSetWeekYear;
  3090. proto.isoWeekYear = getSetISOWeekYear;
  3091. // Quarter
  3092. proto.quarter = proto.quarters = getSetQuarter;
  3093. // Month
  3094. proto.month = getSetMonth;
  3095. proto.daysInMonth = getDaysInMonth;
  3096. // Week
  3097. proto.week = proto.weeks = getSetWeek;
  3098. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  3099. proto.weeksInYear = getWeeksInYear;
  3100. proto.isoWeeksInYear = getISOWeeksInYear;
  3101. // Day
  3102. proto.date = getSetDayOfMonth;
  3103. proto.day = proto.days = getSetDayOfWeek;
  3104. proto.weekday = getSetLocaleDayOfWeek;
  3105. proto.isoWeekday = getSetISODayOfWeek;
  3106. proto.dayOfYear = getSetDayOfYear;
  3107. // Hour
  3108. proto.hour = proto.hours = getSetHour;
  3109. // Minute
  3110. proto.minute = proto.minutes = getSetMinute;
  3111. // Second
  3112. proto.second = proto.seconds = getSetSecond;
  3113. // Millisecond
  3114. proto.millisecond = proto.milliseconds = getSetMillisecond;
  3115. // Offset
  3116. proto.utcOffset = getSetOffset;
  3117. proto.utc = setOffsetToUTC;
  3118. proto.local = setOffsetToLocal;
  3119. proto.parseZone = setOffsetToParsedOffset;
  3120. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  3121. proto.isDST = isDaylightSavingTime;
  3122. proto.isLocal = isLocal;
  3123. proto.isUtcOffset = isUtcOffset;
  3124. proto.isUtc = isUtc;
  3125. proto.isUTC = isUtc;
  3126. // Timezone
  3127. proto.zoneAbbr = getZoneAbbr;
  3128. proto.zoneName = getZoneName;
  3129. // Deprecations
  3130. proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  3131. proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  3132. proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  3133. proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
  3134. proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
  3135. function createUnix(input) {
  3136. return createLocal(input * 1000);
  3137. }
  3138. function createInZone() {
  3139. return createLocal.apply(null, arguments).parseZone();
  3140. }
  3141. function preParsePostFormat(string) {
  3142. return string;
  3143. }
  3144. var proto$1 = Locale.prototype;
  3145. proto$1.calendar = calendar;
  3146. proto$1.longDateFormat = longDateFormat;
  3147. proto$1.invalidDate = invalidDate;
  3148. proto$1.ordinal = ordinal;
  3149. proto$1.preparse = preParsePostFormat;
  3150. proto$1.postformat = preParsePostFormat;
  3151. proto$1.relativeTime = relativeTime;
  3152. proto$1.pastFuture = pastFuture;
  3153. proto$1.set = set;
  3154. // Month
  3155. proto$1.months = localeMonths;
  3156. proto$1.monthsShort = localeMonthsShort;
  3157. proto$1.monthsParse = localeMonthsParse;
  3158. proto$1.monthsRegex = monthsRegex;
  3159. proto$1.monthsShortRegex = monthsShortRegex;
  3160. // Week
  3161. proto$1.week = localeWeek;
  3162. proto$1.firstDayOfYear = localeFirstDayOfYear;
  3163. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  3164. // Day of Week
  3165. proto$1.weekdays = localeWeekdays;
  3166. proto$1.weekdaysMin = localeWeekdaysMin;
  3167. proto$1.weekdaysShort = localeWeekdaysShort;
  3168. proto$1.weekdaysParse = localeWeekdaysParse;
  3169. proto$1.weekdaysRegex = weekdaysRegex;
  3170. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  3171. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  3172. // Hours
  3173. proto$1.isPM = localeIsPM;
  3174. proto$1.meridiem = localeMeridiem;
  3175. function get$1(format, index, field, setter) {
  3176. var locale = getLocale();
  3177. var utc = createUTC().set(setter, index);
  3178. return locale[field](utc, format);
  3179. }
  3180. function listMonthsImpl(format, index, field) {
  3181. if (isNumber(format)) {
  3182. index = format;
  3183. format = undefined;
  3184. }
  3185. format = format || '';
  3186. if (index != null) {
  3187. return get$1(format, index, field, 'month');
  3188. }
  3189. var i;
  3190. var out = [];
  3191. for (i = 0; i < 12; i++) {
  3192. out[i] = get$1(format, i, field, 'month');
  3193. }
  3194. return out;
  3195. }
  3196. // ()
  3197. // (5)
  3198. // (fmt, 5)
  3199. // (fmt)
  3200. // (true)
  3201. // (true, 5)
  3202. // (true, fmt, 5)
  3203. // (true, fmt)
  3204. function listWeekdaysImpl(localeSorted, format, index, field) {
  3205. if (typeof localeSorted === 'boolean') {
  3206. if (isNumber(format)) {
  3207. index = format;
  3208. format = undefined;
  3209. }
  3210. format = format || '';
  3211. } else {
  3212. format = localeSorted;
  3213. index = format;
  3214. localeSorted = false;
  3215. if (isNumber(format)) {
  3216. index = format;
  3217. format = undefined;
  3218. }
  3219. format = format || '';
  3220. }
  3221. var locale = getLocale(),
  3222. shift = localeSorted ? locale._week.dow : 0;
  3223. if (index != null) {
  3224. return get$1(format, (index + shift) % 7, field, 'day');
  3225. }
  3226. var i;
  3227. var out = [];
  3228. for (i = 0; i < 7; i++) {
  3229. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  3230. }
  3231. return out;
  3232. }
  3233. function listMonths(format, index) {
  3234. return listMonthsImpl(format, index, 'months');
  3235. }
  3236. function listMonthsShort(format, index) {
  3237. return listMonthsImpl(format, index, 'monthsShort');
  3238. }
  3239. function listWeekdays(localeSorted, format, index) {
  3240. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  3241. }
  3242. function listWeekdaysShort(localeSorted, format, index) {
  3243. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  3244. }
  3245. function listWeekdaysMin(localeSorted, format, index) {
  3246. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  3247. }
  3248. getSetGlobalLocale('en', {
  3249. ordinalParse: /\d{1,2}(th|st|nd|rd)/,
  3250. ordinal: function (number) {
  3251. var b = number % 10,
  3252. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  3253. (b === 1) ? 'st' :
  3254. (b === 2) ? 'nd' :
  3255. (b === 3) ? 'rd' : 'th';
  3256. return number + output;
  3257. }
  3258. });
  3259. // Side effect imports
  3260. hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
  3261. hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
  3262. var mathAbs = Math.abs;
  3263. function abs() {
  3264. var data = this._data;
  3265. this._milliseconds = mathAbs(this._milliseconds);
  3266. this._days = mathAbs(this._days);
  3267. this._months = mathAbs(this._months);
  3268. data.milliseconds = mathAbs(data.milliseconds);
  3269. data.seconds = mathAbs(data.seconds);
  3270. data.minutes = mathAbs(data.minutes);
  3271. data.hours = mathAbs(data.hours);
  3272. data.months = mathAbs(data.months);
  3273. data.years = mathAbs(data.years);
  3274. return this;
  3275. }
  3276. function addSubtract$1(duration, input, value, direction) {
  3277. var other = createDuration(input, value);
  3278. duration._milliseconds += direction * other._milliseconds;
  3279. duration._days += direction * other._days;
  3280. duration._months += direction * other._months;
  3281. return duration._bubble();
  3282. }
  3283. // supports only 2.0-style add(1, 's') or add(duration)
  3284. function add$1(input, value) {
  3285. return addSubtract$1(this, input, value, 1);
  3286. }
  3287. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  3288. function subtract$1(input, value) {
  3289. return addSubtract$1(this, input, value, -1);
  3290. }
  3291. function absCeil(number) {
  3292. if (number < 0) {
  3293. return Math.floor(number);
  3294. } else {
  3295. return Math.ceil(number);
  3296. }
  3297. }
  3298. function bubble() {
  3299. var milliseconds = this._milliseconds;
  3300. var days = this._days;
  3301. var months = this._months;
  3302. var data = this._data;
  3303. var seconds, minutes, hours, years, monthsFromDays;
  3304. // if we have a mix of positive and negative values, bubble down first
  3305. // check: https://github.com/moment/moment/issues/2166
  3306. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  3307. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  3308. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  3309. days = 0;
  3310. months = 0;
  3311. }
  3312. // The following code bubbles up values, see the tests for
  3313. // examples of what that means.
  3314. data.milliseconds = milliseconds % 1000;
  3315. seconds = absFloor(milliseconds / 1000);
  3316. data.seconds = seconds % 60;
  3317. minutes = absFloor(seconds / 60);
  3318. data.minutes = minutes % 60;
  3319. hours = absFloor(minutes / 60);
  3320. data.hours = hours % 24;
  3321. days += absFloor(hours / 24);
  3322. // convert days to months
  3323. monthsFromDays = absFloor(daysToMonths(days));
  3324. months += monthsFromDays;
  3325. days -= absCeil(monthsToDays(monthsFromDays));
  3326. // 12 months -> 1 year
  3327. years = absFloor(months / 12);
  3328. months %= 12;
  3329. data.days = days;
  3330. data.months = months;
  3331. data.years = years;
  3332. return this;
  3333. }
  3334. function daysToMonths(days) {
  3335. // 400 years have 146097 days (taking into account leap year rules)
  3336. // 400 years have 12 months === 4800
  3337. return days * 4800 / 146097;
  3338. }
  3339. function monthsToDays(months) {
  3340. // the reverse of daysToMonths
  3341. return months * 146097 / 4800;
  3342. }
  3343. function as(units) {
  3344. var days;
  3345. var months;
  3346. var milliseconds = this._milliseconds;
  3347. units = normalizeUnits(units);
  3348. if (units === 'month' || units === 'year') {
  3349. days = this._days + milliseconds / 864e5;
  3350. months = this._months + daysToMonths(days);
  3351. return units === 'month' ? months : months / 12;
  3352. } else {
  3353. // handle milliseconds separately because of floating point math errors (issue #1867)
  3354. days = this._days + Math.round(monthsToDays(this._months));
  3355. switch (units) {
  3356. case 'week': return days / 7 + milliseconds / 6048e5;
  3357. case 'day': return days + milliseconds / 864e5;
  3358. case 'hour': return days * 24 + milliseconds / 36e5;
  3359. case 'minute': return days * 1440 + milliseconds / 6e4;
  3360. case 'second': return days * 86400 + milliseconds / 1000;
  3361. // Math.floor prevents floating point math errors here
  3362. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  3363. default: throw new Error('Unknown unit ' + units);
  3364. }
  3365. }
  3366. }
  3367. // TODO: Use this.as('ms')?
  3368. function valueOf$1() {
  3369. return (
  3370. this._milliseconds +
  3371. this._days * 864e5 +
  3372. (this._months % 12) * 2592e6 +
  3373. toInt(this._months / 12) * 31536e6
  3374. );
  3375. }
  3376. function makeAs(alias) {
  3377. return function () {
  3378. return this.as(alias);
  3379. };
  3380. }
  3381. var asMilliseconds = makeAs('ms');
  3382. var asSeconds = makeAs('s');
  3383. var asMinutes = makeAs('m');
  3384. var asHours = makeAs('h');
  3385. var asDays = makeAs('d');
  3386. var asWeeks = makeAs('w');
  3387. var asMonths = makeAs('M');
  3388. var asYears = makeAs('y');
  3389. function get$2(units) {
  3390. units = normalizeUnits(units);
  3391. return this[units + 's']();
  3392. }
  3393. function makeGetter(name) {
  3394. return function () {
  3395. return this._data[name];
  3396. };
  3397. }
  3398. var milliseconds = makeGetter('milliseconds');
  3399. var seconds = makeGetter('seconds');
  3400. var minutes = makeGetter('minutes');
  3401. var hours = makeGetter('hours');
  3402. var days = makeGetter('days');
  3403. var months = makeGetter('months');
  3404. var years = makeGetter('years');
  3405. function weeks() {
  3406. return absFloor(this.days() / 7);
  3407. }
  3408. var round = Math.round;
  3409. var thresholds = {
  3410. s: 45, // seconds to minute
  3411. m: 45, // minutes to hour
  3412. h: 22, // hours to day
  3413. d: 26, // days to month
  3414. M: 11 // months to year
  3415. };
  3416. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  3417. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  3418. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  3419. }
  3420. function relativeTime$1(posNegDuration, withoutSuffix, locale) {
  3421. var duration = createDuration(posNegDuration).abs();
  3422. var seconds = round(duration.as('s'));
  3423. var minutes = round(duration.as('m'));
  3424. var hours = round(duration.as('h'));
  3425. var days = round(duration.as('d'));
  3426. var months = round(duration.as('M'));
  3427. var years = round(duration.as('y'));
  3428. var a = seconds < thresholds.s && ['s', seconds] ||
  3429. minutes <= 1 && ['m'] ||
  3430. minutes < thresholds.m && ['mm', minutes] ||
  3431. hours <= 1 && ['h'] ||
  3432. hours < thresholds.h && ['hh', hours] ||
  3433. days <= 1 && ['d'] ||
  3434. days < thresholds.d && ['dd', days] ||
  3435. months <= 1 && ['M'] ||
  3436. months < thresholds.M && ['MM', months] ||
  3437. years <= 1 && ['y'] || ['yy', years];
  3438. a[2] = withoutSuffix;
  3439. a[3] = +posNegDuration > 0;
  3440. a[4] = locale;
  3441. return substituteTimeAgo.apply(null, a);
  3442. }
  3443. // This function allows you to set the rounding function for relative time strings
  3444. function getSetRelativeTimeRounding(roundingFunction) {
  3445. if (roundingFunction === undefined) {
  3446. return round;
  3447. }
  3448. if (typeof (roundingFunction) === 'function') {
  3449. round = roundingFunction;
  3450. return true;
  3451. }
  3452. return false;
  3453. }
  3454. // This function allows you to set a threshold for relative time strings
  3455. function getSetRelativeTimeThreshold(threshold, limit) {
  3456. if (thresholds[threshold] === undefined) {
  3457. return false;
  3458. }
  3459. if (limit === undefined) {
  3460. return thresholds[threshold];
  3461. }
  3462. thresholds[threshold] = limit;
  3463. return true;
  3464. }
  3465. function humanize(withSuffix) {
  3466. var locale = this.localeData();
  3467. var output = relativeTime$1(this, !withSuffix, locale);
  3468. if (withSuffix) {
  3469. output = locale.pastFuture(+this, output);
  3470. }
  3471. return locale.postformat(output);
  3472. }
  3473. var abs$1 = Math.abs;
  3474. function toISOString$1() {
  3475. // for ISO strings we do not use the normal bubbling rules:
  3476. // * milliseconds bubble up until they become hours
  3477. // * days do not bubble at all
  3478. // * months bubble up until they become years
  3479. // This is because there is no context-free conversion between hours and days
  3480. // (think of clock changes)
  3481. // and also not between days and months (28-31 days per month)
  3482. var seconds = abs$1(this._milliseconds) / 1000;
  3483. var days = abs$1(this._days);
  3484. var months = abs$1(this._months);
  3485. var minutes, hours, years;
  3486. // 3600 seconds -> 60 minutes -> 1 hour
  3487. minutes = absFloor(seconds / 60);
  3488. hours = absFloor(minutes / 60);
  3489. seconds %= 60;
  3490. minutes %= 60;
  3491. // 12 months -> 1 year
  3492. years = absFloor(months / 12);
  3493. months %= 12;
  3494. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  3495. var Y = years;
  3496. var M = months;
  3497. var D = days;
  3498. var h = hours;
  3499. var m = minutes;
  3500. var s = seconds;
  3501. var total = this.asSeconds();
  3502. if (!total) {
  3503. // this is the same as C#'s (Noda) and python (isodate)...
  3504. // but not other JS (goog.date)
  3505. return 'P0D';
  3506. }
  3507. return (total < 0 ? '-' : '') +
  3508. 'P' +
  3509. (Y ? Y + 'Y' : '') +
  3510. (M ? M + 'M' : '') +
  3511. (D ? D + 'D' : '') +
  3512. ((h || m || s) ? 'T' : '') +
  3513. (h ? h + 'H' : '') +
  3514. (m ? m + 'M' : '') +
  3515. (s ? s + 'S' : '');
  3516. }
  3517. var proto$2 = Duration.prototype;
  3518. proto$2.abs = abs;
  3519. proto$2.add = add$1;
  3520. proto$2.subtract = subtract$1;
  3521. proto$2.as = as;
  3522. proto$2.asMilliseconds = asMilliseconds;
  3523. proto$2.asSeconds = asSeconds;
  3524. proto$2.asMinutes = asMinutes;
  3525. proto$2.asHours = asHours;
  3526. proto$2.asDays = asDays;
  3527. proto$2.asWeeks = asWeeks;
  3528. proto$2.asMonths = asMonths;
  3529. proto$2.asYears = asYears;
  3530. proto$2.valueOf = valueOf$1;
  3531. proto$2._bubble = bubble;
  3532. proto$2.get = get$2;
  3533. proto$2.milliseconds = milliseconds;
  3534. proto$2.seconds = seconds;
  3535. proto$2.minutes = minutes;
  3536. proto$2.hours = hours;
  3537. proto$2.days = days;
  3538. proto$2.weeks = weeks;
  3539. proto$2.months = months;
  3540. proto$2.years = years;
  3541. proto$2.humanize = humanize;
  3542. proto$2.toISOString = toISOString$1;
  3543. proto$2.toString = toISOString$1;
  3544. proto$2.toJSON = toISOString$1;
  3545. proto$2.locale = locale;
  3546. proto$2.localeData = localeData;
  3547. // Deprecations
  3548. proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
  3549. proto$2.lang = lang;
  3550. // Side effect imports
  3551. // FORMATTING
  3552. addFormatToken('X', 0, 0, 'unix');
  3553. addFormatToken('x', 0, 0, 'valueOf');
  3554. // PARSING
  3555. addRegexToken('x', matchSigned);
  3556. addRegexToken('X', matchTimestamp);
  3557. addParseToken('X', function (input, array, config) {
  3558. config._d = new Date(parseFloat(input, 10) * 1000);
  3559. });
  3560. addParseToken('x', function (input, array, config) {
  3561. config._d = new Date(toInt(input));
  3562. });
  3563. // Side effect imports
  3564. hooks.version = '2.17.1';
  3565. setHookCallback(createLocal);
  3566. hooks.fn = proto;
  3567. hooks.min = min;
  3568. hooks.max = max;
  3569. hooks.now = now;
  3570. hooks.utc = createUTC;
  3571. hooks.unix = createUnix;
  3572. hooks.months = listMonths;
  3573. hooks.isDate = isDate;
  3574. hooks.locale = getSetGlobalLocale;
  3575. hooks.invalid = createInvalid;
  3576. hooks.duration = createDuration;
  3577. hooks.isMoment = isMoment;
  3578. hooks.weekdays = listWeekdays;
  3579. hooks.parseZone = createInZone;
  3580. hooks.localeData = getLocale;
  3581. hooks.isDuration = isDuration;
  3582. hooks.monthsShort = listMonthsShort;
  3583. hooks.weekdaysMin = listWeekdaysMin;
  3584. hooks.defineLocale = defineLocale;
  3585. hooks.updateLocale = updateLocale;
  3586. hooks.locales = listLocales;
  3587. hooks.weekdaysShort = listWeekdaysShort;
  3588. hooks.normalizeUnits = normalizeUnits;
  3589. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  3590. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  3591. hooks.calendarFormat = getCalendarFormat;
  3592. hooks.prototype = proto;
  3593. return hooks;
  3594. })));