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