vendor: 5,797 bytes, lines 1-201
1var luxon = (function (exports) { 2 'use strict'; 3 4 function _defineProperties(target, props) { 5 for (var i = 0; i < props.length; i++) { 6 var descriptor = props[i]; 7 descriptor.enumerable = descriptor.enumerable || false; 8 descriptor.configurable = true; 9 if ("value" in descriptor) descriptor.writable = true; 10 Object.defineProperty(target, descriptor.key, descriptor); 11 } 12 } 13 14 function _createClass(Constructor, protoProps, staticProps) { 15 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 16 if (staticProps) _defineProperties(Constructor, staticProps); 17 return Constructor; 18 } 19 20 function _extends() { 21 _extends = Object.assign || function (target) { 22 for (var i = 1; i < arguments.length; i++) { 23 var source = arguments[i]; 24 25 for (var key in source) { 26 if (Object.prototype.hasOwnProperty.call(source, key)) { 27 target[key] = source[key]; 28 } 29 } 30 } 31 32 return target; 33 }; 34 35 return _extends.apply(this, arguments); 36 } 37 38 function _inheritsLoose(subClass, superClass) { 39 subClass.prototype = Object.create(superClass.prototype); 40 subClass.prototype.constructor = subClass; 41 42 _setPrototypeOf(subClass, superClass); 43 } 44 45 function _getPrototypeOf(o) { 46 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 47 return o.__proto__ || Object.getPrototypeOf(o); 48 }; 49 return _getPrototypeOf(o); 50 } 51 52 function _setPrototypeOf(o, p) { 53 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 54 o.__proto__ = p; 55 return o; 56 }; 57 58 return _setPrototypeOf(o, p); 59 } 60 61 function _isNativeReflectConstruct() { 62 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 63 if (Reflect.construct.sham) return false; 64 if (typeof Proxy === "function") return true; 65 66 try { 67 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); 68 return true; 69 } catch (e) { 70 return false; 71 } 72 } 73 74 function _construct(Parent, args, Class) { 75 if (_isNativeReflectConstruct()) { 76 _construct = Reflect.construct; 77 } else { 78 _construct = function _construct(Parent, args, Class) { 79 var a = [null]; 80 a.push.apply(a, args); 81 var Constructor = Function.bind.apply(Parent, a); 82 var instance = new Constructor(); 83 if (Class) _setPrototypeOf(instance, Class.prototype); 84 return instance; 85 }; 86 } 87 88 return _construct.apply(null, arguments); 89 } 90 91 function _isNativeFunction(fn) { 92 return Function.toString.call(fn).indexOf("[native code]") !== -1; 93 } 94 95 function _wrapNativeSuper(Class) { 96 var _cache = typeof Map === "function" ? new Map() : undefined; 97 98 _wrapNativeSuper = function _wrapNativeSuper(Class) { 99 if (Class === null || !_isNativeFunction(Class)) return Class; 100 101 if (typeof Class !== "function") { 102 throw new TypeError("Super expression must either be null or a function"); 103 } 104 105 if (typeof _cache !== "undefined") { 106 if (_cache.has(Class)) return _cache.get(Class); 107 108 _cache.set(Class, Wrapper); 109 } 110 111 function Wrapper() { 112 return _construct(Class, arguments, _getPrototypeOf(this).constructor); 113 } 114 115 Wrapper.prototype = Object.create(Class.prototype, { 116 constructor: { 117 value: Wrapper, 118 enumerable: false, 119 writable: true, 120 configurable: true 121 } 122 }); 123 return _setPrototypeOf(Wrapper, Class); 124 }; 125 126 return _wrapNativeSuper(Class); 127 } 128 129 function _objectWithoutPropertiesLoose(source, excluded) { 130 if (source == null) return {}; 131 var target = {}; 132 var sourceKeys = Object.keys(source); 133 var key, i; 134 135 for (i = 0; i < sourceKeys.length; i++) { 136 key = sourceKeys[i]; 137 if (excluded.indexOf(key) >= 0) continue; 138 target[key] = source[key]; 139 } 140 141 return target; 142 } 143 144 function _unsupportedIterableToArray(o, minLen) { 145 if (!o) return; 146 if (typeof o === "string") return _arrayLikeToArray(o, minLen); 147 var n = Object.prototype.toString.call(o).slice(8, -1); 148 if (n === "Object" && o.constructor) n = o.constructor.name; 149 if (n === "Map" || n === "Set") return Array.from(o); 150 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); 151 } 152 153 function _arrayLikeToArray(arr, len) { 154 if (len == null || len > arr.length) len = arr.length; 155 156 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; 157 158 return arr2; 159 } 160 161 function _createForOfIteratorHelperLoose(o, allowArrayLike) { 162 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; 163 if (it) return (it = it.call(o)).next.bind(it); 164 165 if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { 166 if (it) o = it; 167 var i = 0; 168 return function () { 169 if (i >= o.length) return { 170 done: true 171 }; 172 return { 173 done: false, 174 value: o[i++] 175 }; 176 }; 177 } 178 179 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 180 } 181 182 // these aren't really private, but nor are they really useful to document 183 184 /** 185 * @private 186 */ 187 var LuxonError = /*#__PURE__*/function (_Error) { 188 _inheritsLoose(LuxonError, _Error); 189 190 function LuxonError() { 191 return _Error.apply(this, arguments) || this; 192 } 193 194 return LuxonError; 195 }( /*#__PURE__*/_wrapNativeSuper(Error)); 196 /** 197 * @private 198 */ 199 200 201 var InvalidDateTimeError = /*#__PURE__*/function (_LuxonError) {
vendor: 5,082 bytes, lines 202-468
202 _inheritsLoose(InvalidDateTimeError, _LuxonError); 203 204 function InvalidDateTimeError(reason) { 205 return _LuxonError.call(this, "Invalid DateTime: " + reason.toMessage()) || this; 206 } 207 208 return InvalidDateTimeError; 209 }(LuxonError); 210 /** 211 * @private 212 */ 213 214 var InvalidIntervalError = /*#__PURE__*/function (_LuxonError2) { 215 _inheritsLoose(InvalidIntervalError, _LuxonError2); 216 217 function InvalidIntervalError(reason) { 218 return _LuxonError2.call(this, "Invalid Interval: " + reason.toMessage()) || this; 219 } 220 221 return InvalidIntervalError; 222 }(LuxonError); 223 /** 224 * @private 225 */ 226 227 var InvalidDurationError = /*#__PURE__*/function (_LuxonError3) { 228 _inheritsLoose(InvalidDurationError, _LuxonError3); 229 230 function InvalidDurationError(reason) { 231 return _LuxonError3.call(this, "Invalid Duration: " + reason.toMessage()) || this; 232 } 233 234 return InvalidDurationError; 235 }(LuxonError); 236 /** 237 * @private 238 */ 239 240 var ConflictingSpecificationError = /*#__PURE__*/function (_LuxonError4) { 241 _inheritsLoose(ConflictingSpecificationError, _LuxonError4); 242 243 function ConflictingSpecificationError() { 244 return _LuxonError4.apply(this, arguments) || this; 245 } 246 247 return ConflictingSpecificationError; 248 }(LuxonError); 249 /** 250 * @private 251 */ 252 253 var InvalidUnitError = /*#__PURE__*/function (_LuxonError5) { 254 _inheritsLoose(InvalidUnitError, _LuxonError5); 255 256 function InvalidUnitError(unit) { 257 return _LuxonError5.call(this, "Invalid unit " + unit) || this; 258 } 259 260 return InvalidUnitError; 261 }(LuxonError); 262 /** 263 * @private 264 */ 265 266 var InvalidArgumentError = /*#__PURE__*/function (_LuxonError6) { 267 _inheritsLoose(InvalidArgumentError, _LuxonError6); 268 269 function InvalidArgumentError() { 270 return _LuxonError6.apply(this, arguments) || this; 271 } 272 273 return InvalidArgumentError; 274 }(LuxonError); 275 /** 276 * @private 277 */ 278 279 var ZoneIsAbstractError = /*#__PURE__*/function (_LuxonError7) { 280 _inheritsLoose(ZoneIsAbstractError, _LuxonError7); 281 282 function ZoneIsAbstractError() { 283 return _LuxonError7.call(this, "Zone is an abstract class") || this; 284 } 285 286 return ZoneIsAbstractError; 287 }(LuxonError); 288 289 /** 290 * @private 291 */ 292 var n = "numeric", 293 s = "short", 294 l = "long"; 295 var DATE_SHORT = { 296 year: n, 297 month: n, 298 day: n 299 }; 300 var DATE_MED = { 301 year: n, 302 month: s, 303 day: n 304 }; 305 var DATE_MED_WITH_WEEKDAY = { 306 year: n, 307 month: s, 308 day: n, 309 weekday: s 310 }; 311 var DATE_FULL = { 312 year: n, 313 month: l, 314 day: n 315 }; 316 var DATE_HUGE = { 317 year: n, 318 month: l, 319 day: n, 320 weekday: l 321 }; 322 var TIME_SIMPLE = { 323 hour: n, 324 minute: n 325 }; 326 var TIME_WITH_SECONDS = { 327 hour: n, 328 minute: n, 329 second: n 330 }; 331 var TIME_WITH_SHORT_OFFSET = { 332 hour: n, 333 minute: n, 334 second: n, 335 timeZoneName: s 336 }; 337 var TIME_WITH_LONG_OFFSET = { 338 hour: n, 339 minute: n, 340 second: n, 341 timeZoneName: l 342 }; 343 var TIME_24_SIMPLE = { 344 hour: n, 345 minute: n, 346 hourCycle: "h23" 347 }; 348 var TIME_24_WITH_SECONDS = { 349 hour: n, 350 minute: n, 351 second: n, 352 hourCycle: "h23" 353 }; 354 var TIME_24_WITH_SHORT_OFFSET = { 355 hour: n, 356 minute: n, 357 second: n, 358 hourCycle: "h23", 359 timeZoneName: s 360 }; 361 var TIME_24_WITH_LONG_OFFSET = { 362 hour: n, 363 minute: n, 364 second: n, 365 hourCycle: "h23", 366 timeZoneName: l 367 }; 368 var DATETIME_SHORT = { 369 year: n, 370 month: n, 371 day: n, 372 hour: n, 373 minute: n 374 }; 375 var DATETIME_SHORT_WITH_SECONDS = { 376 year: n, 377 month: n, 378 day: n, 379 hour: n, 380 minute: n, 381 second: n 382 }; 383 var DATETIME_MED = { 384 year: n, 385 month: s, 386 day: n, 387 hour: n, 388 minute: n 389 }; 390 var DATETIME_MED_WITH_SECONDS = { 391 year: n, 392 month: s, 393 day: n, 394 hour: n, 395 minute: n, 396 second: n 397 }; 398 var DATETIME_MED_WITH_WEEKDAY = { 399 year: n, 400 month: s, 401 day: n, 402 weekday: s, 403 hour: n, 404 minute: n 405 }; 406 var DATETIME_FULL = { 407 year: n, 408 month: l, 409 day: n, 410 hour: n, 411 minute: n, 412 timeZoneName: s 413 }; 414 var DATETIME_FULL_WITH_SECONDS = { 415 year: n, 416 month: l, 417 day: n, 418 hour: n, 419 minute: n, 420 second: n, 421 timeZoneName: s 422 }; 423 var DATETIME_HUGE = { 424 year: n, 425 month: l, 426 day: n, 427 weekday: l, 428 hour: n, 429 minute: n, 430 timeZoneName: l 431 }; 432 var DATETIME_HUGE_WITH_SECONDS = { 433 year: n, 434 month: l, 435 day: n, 436 weekday: l, 437 hour: n, 438 minute: n, 439 second: n, 440 timeZoneName: l 441 }; 442 443 /** 444 * @private 445 */ 446 // TYPES 447 448 function isUndefined(o) { 449 return typeof o === "undefined"; 450 } 451 function isNumber(o) { 452 return typeof o === "number"; 453 } 454 function isInteger(o) { 455 return typeof o === "number" && o % 1 === 0; 456 } 457 function isString(o) { 458 return typeof o === "string"; 459 } 460 function isDate(o) { 461 return Object.prototype.toString.call(o) === "[object Date]"; 462 } // CAPABILITIES 463 464 function hasRelative() { 465 try { 466 return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat; 467 } catch (e) { 468 return false;
vendor: 6,007 bytes, lines 469-678
469 } 470 } // OBJECTS AND ARRAYS 471 472 function maybeArray(thing) { 473 return Array.isArray(thing) ? thing : [thing]; 474 } 475 function bestBy(arr, by, compare) { 476 if (arr.length === 0) { 477 return undefined; 478 } 479 480 return arr.reduce(function (best, next) { 481 var pair = [by(next), next]; 482 483 if (!best) { 484 return pair; 485 } else if (compare(best[0], pair[0]) === best[0]) { 486 return best; 487 } else { 488 return pair; 489 } 490 }, null)[1]; 491 } 492 function pick(obj, keys) { 493 return keys.reduce(function (a, k) { 494 a[k] = obj[k]; 495 return a; 496 }, {}); 497 } 498 function hasOwnProperty(obj, prop) { 499 return Object.prototype.hasOwnProperty.call(obj, prop); 500 } // NUMBERS AND STRINGS 501 502 function integerBetween(thing, bottom, top) { 503 return isInteger(thing) && thing >= bottom && thing <= top; 504 } // x % n but takes the sign of n instead of x 505 506 function floorMod(x, n) { 507 return x - n * Math.floor(x / n); 508 } 509 function padStart(input, n) { 510 if (n === void 0) { 511 n = 2; 512 } 513 514 var isNeg = input < 0; 515 var padded; 516 517 if (isNeg) { 518 padded = "-" + ("" + -input).padStart(n, "0"); 519 } else { 520 padded = ("" + input).padStart(n, "0"); 521 } 522 523 return padded; 524 } 525 function parseInteger(string) { 526 if (isUndefined(string) || string === null || string === "") { 527 return undefined; 528 } else { 529 return parseInt(string, 10); 530 } 531 } 532 function parseFloating(string) { 533 if (isUndefined(string) || string === null || string === "") { 534 return undefined; 535 } else { 536 return parseFloat(string); 537 } 538 } 539 function parseMillis(fraction) { 540 // Return undefined (instead of 0) in these cases, where fraction is not set 541 if (isUndefined(fraction) || fraction === null || fraction === "") { 542 return undefined; 543 } else { 544 var f = parseFloat("0." + fraction) * 1000; 545 return Math.floor(f); 546 } 547 } 548 function roundTo(number, digits, towardZero) { 549 if (towardZero === void 0) { 550 towardZero = false; 551 } 552 553 var factor = Math.pow(10, digits), 554 rounder = towardZero ? Math.trunc : Math.round; 555 return rounder(number * factor) / factor; 556 } // DATE BASICS 557 558 function isLeapYear(year) { 559 return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); 560 } 561 function daysInYear(year) { 562 return isLeapYear(year) ? 366 : 365; 563 } 564 function daysInMonth(year, month) { 565 var modMonth = floorMod(month - 1, 12) + 1, 566 modYear = year + (month - modMonth) / 12; 567 568 if (modMonth === 2) { 569 return isLeapYear(modYear) ? 29 : 28; 570 } else { 571 return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1]; 572 } 573 } // covert a calendar object to a local timestamp (epoch, but with the offset baked in) 574 575 function objToLocalTS(obj) { 576 var d = Date.UTC(obj.year, obj.month - 1, obj.day, obj.hour, obj.minute, obj.second, obj.millisecond); // for legacy reasons, years between 0 and 99 are interpreted as 19XX; revert that 577 578 if (obj.year < 100 && obj.year >= 0) { 579 d = new Date(d); 580 d.setUTCFullYear(d.getUTCFullYear() - 1900); 581 } 582 583 return +d; 584 } 585 function weeksInWeekYear(weekYear) { 586 var p1 = (weekYear + Math.floor(weekYear / 4) - Math.floor(weekYear / 100) + Math.floor(weekYear / 400)) % 7, 587 last = weekYear - 1, 588 p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7; 589 return p1 === 4 || p2 === 3 ? 53 : 52; 590 } 591 function untruncateYear(year) { 592 if (year > 99) { 593 return year; 594 } else return year > 60 ? 1900 + year : 2000 + year; 595 } // PARSING 596 597 function parseZoneInfo(ts, offsetFormat, locale, timeZone) { 598 if (timeZone === void 0) { 599 timeZone = null; 600 } 601 602 var date = new Date(ts), 603 intlOpts = { 604 hourCycle: "h23", 605 year: "numeric", 606 month: "2-digit", 607 day: "2-digit", 608 hour: "2-digit", 609 minute: "2-digit" 610 }; 611 612 if (timeZone) { 613 intlOpts.timeZone = timeZone; 614 } 615 616 var modified = _extends({ 617 timeZoneName: offsetFormat 618 }, intlOpts); 619 620 var parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find(function (m) { 621 return m.type.toLowerCase() === "timezonename"; 622 }); 623 return parsed ? parsed.value : null; 624 } // signedOffset('-5', '30') -> -330 625 626 function signedOffset(offHourStr, offMinuteStr) { 627 var offHour = parseInt(offHourStr, 10); // don't || this because we want to preserve -0 628 629 if (Number.isNaN(offHour)) { 630 offHour = 0; 631 } 632 633 var offMin = parseInt(offMinuteStr, 10) || 0, 634 offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin; 635 return offHour * 60 + offMinSigned; 636 } // COERCION 637 638 function asNumber(value) { 639 var numericValue = Number(value); 640 if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue)) throw new InvalidArgumentError("Invalid unit value " + value); 641 return numericValue; 642 } 643 function normalizeObject(obj, normalizer) { 644 var normalized = {}; 645 646 for (var u in obj) { 647 if (hasOwnProperty(obj, u)) { 648 var v = obj[u]; 649 if (v === undefined || v === null) continue; 650 normalized[normalizer(u)] = asNumber(v); 651 } 652 } 653 654 return normalized; 655 } 656 function formatOffset(offset, format) { 657 var hours = Math.trunc(Math.abs(offset / 60)), 658 minutes = Math.trunc(Math.abs(offset % 60)), 659 sign = offset >= 0 ? "+" : "-"; 660 661 switch (format) { 662 case "short": 663 return "" + sign + padStart(hours, 2) + ":" + padStart(minutes, 2); 664 665 case "narrow": 666 return "" + sign + hours + (minutes > 0 ? ":" + minutes : ""); 667 668 case "techie": 669 return "" + sign + padStart(hours, 2) + padStart(minutes, 2); 670 671 default: 672 throw new RangeError("Value format " + format + " is out of range for property format"); 673 } 674 } 675 function timeObject(obj) { 676 return pick(obj, ["hour", "minute", "second", "millisecond"]); 677 } 678 var ianaRegex = /[A-Za-z_+-]{1,256}
vendor: 4,860 bytes, lines 678-860
678(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/; 679 680 /** 681 * @private 682 */ 683 684 685 var monthsLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; 686 var monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 687 var monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"]; 688 function months(length) { 689 switch (length) { 690 case "narrow": 691 return [].concat(monthsNarrow); 692 693 case "short": 694 return [].concat(monthsShort); 695 696 case "long": 697 return [].concat(monthsLong); 698 699 case "numeric": 700 return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]; 701 702 case "2-digit": 703 return ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]; 704 705 default: 706 return null; 707 } 708 } 709 var weekdaysLong = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; 710 var weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; 711 var weekdaysNarrow = ["M", "T", "W", "T", "F", "S", "S"]; 712 function weekdays(length) { 713 switch (length) { 714 case "narrow": 715 return [].concat(weekdaysNarrow); 716 717 case "short": 718 return [].concat(weekdaysShort); 719 720 case "long": 721 return [].concat(weekdaysLong); 722 723 case "numeric": 724 return ["1", "2", "3", "4", "5", "6", "7"]; 725 726 default: 727 return null; 728 } 729 } 730 var meridiems = ["AM", "PM"]; 731 var erasLong = ["Before Christ", "Anno Domini"]; 732 var erasShort = ["BC", "AD"]; 733 var erasNarrow = ["B", "A"]; 734 function eras(length) { 735 switch (length) { 736 case "narrow": 737 return [].concat(erasNarrow); 738 739 case "short": 740 return [].concat(erasShort); 741 742 case "long": 743 return [].concat(erasLong); 744 745 default: 746 return null; 747 } 748 } 749 function meridiemForDateTime(dt) { 750 return meridiems[dt.hour < 12 ? 0 : 1]; 751 } 752 function weekdayForDateTime(dt, length) { 753 return weekdays(length)[dt.weekday - 1]; 754 } 755 function monthForDateTime(dt, length) { 756 return months(length)[dt.month - 1]; 757 } 758 function eraForDateTime(dt, length) { 759 return eras(length)[dt.year < 0 ? 0 : 1]; 760 } 761 function formatRelativeTime(unit, count, numeric, narrow) { 762 if (numeric === void 0) { 763 numeric = "always"; 764 } 765 766 if (narrow === void 0) { 767 narrow = false; 768 } 769 770 var units = { 771 years: ["year", "yr."], 772 quarters: ["quarter", "qtr."], 773 months: ["month", "mo."], 774 weeks: ["week", "wk."], 775 days: ["day", "day", "days"], 776 hours: ["hour", "hr."], 777 minutes: ["minute", "min."], 778 seconds: ["second", "sec."] 779 }; 780 var lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1; 781 782 if (numeric === "auto" && lastable) { 783 var isDay = unit === "days"; 784 785 switch (count) { 786 case 1: 787 return isDay ? "tomorrow" : "next " + units[unit][0]; 788 789 case -1: 790 return isDay ? "yesterday" : "last " + units[unit][0]; 791 792 case 0: 793 return isDay ? "today" : "this " + units[unit][0]; 794 795 } 796 } 797 798 var isInPast = Object.is(count, -0) || count < 0, 799 fmtValue = Math.abs(count), 800 singular = fmtValue === 1, 801 lilUnits = units[unit], 802 fmtUnit = narrow ? singular ? lilUnits[1] : lilUnits[2] || lilUnits[1] : singular ? units[unit][0] : unit; 803 return isInPast ? fmtValue + " " + fmtUnit + " ago" : "in " + fmtValue + " " + fmtUnit; 804 } 805 806 function stringifyTokens(splits, tokenToString) { 807 var s = ""; 808 809 for (var _iterator = _createForOfIteratorHelperLoose(splits), _step; !(_step = _iterator()).done;) { 810 var token = _step.value; 811 812 if (token.literal) { 813 s += token.val; 814 } else { 815 s += tokenToString(token.val); 816 } 817 } 818 819 return s; 820 } 821 822 var _macroTokenToFormatOpts = { 823 D: DATE_SHORT, 824 DD: DATE_MED, 825 DDD: DATE_FULL, 826 DDDD: DATE_HUGE, 827 t: TIME_SIMPLE, 828 tt: TIME_WITH_SECONDS, 829 ttt: TIME_WITH_SHORT_OFFSET, 830 tttt: TIME_WITH_LONG_OFFSET, 831 T: TIME_24_SIMPLE, 832 TT: TIME_24_WITH_SECONDS, 833 TTT: TIME_24_WITH_SHORT_OFFSET, 834 TTTT: TIME_24_WITH_LONG_OFFSET, 835 f: DATETIME_SHORT, 836 ff: DATETIME_MED, 837 fff: DATETIME_FULL, 838 ffff: DATETIME_HUGE, 839 F: DATETIME_SHORT_WITH_SECONDS, 840 FF: DATETIME_MED_WITH_SECONDS, 841 FFF: DATETIME_FULL_WITH_SECONDS, 842 FFFF: DATETIME_HUGE_WITH_SECONDS 843 }; 844 /** 845 * @private 846 */ 847 848 var Formatter = /*#__PURE__*/function () { 849 Formatter.create = function create(locale, opts) { 850 if (opts === void 0) { 851 opts = {}; 852 } 853 854 return new Formatter(locale, opts); 855 }; 856 857 Formatter.parseFormat = function parseFormat(fmt) { 858 var current = null, 859 currentFull = "", 860 bracketed = false;
vendor: 6,560 bytes, lines 861-1106
861 var splits = []; 862 863 for (var i = 0; i < fmt.length; i++) { 864 var c = fmt.charAt(i); 865 866 if (c === "'") { 867 if (currentFull.length > 0) { 868 splits.push({ 869 literal: bracketed, 870 val: currentFull 871 }); 872 } 873 874 current = null; 875 currentFull = ""; 876 bracketed = !bracketed; 877 } else if (bracketed) { 878 currentFull += c; 879 } else if (c === current) { 880 currentFull += c; 881 } else { 882 if (currentFull.length > 0) { 883 splits.push({ 884 literal: false, 885 val: currentFull 886 }); 887 } 888 889 currentFull = c; 890 current = c; 891 } 892 } 893 894 if (currentFull.length > 0) { 895 splits.push({ 896 literal: bracketed, 897 val: currentFull 898 }); 899 } 900 901 return splits; 902 }; 903 904 Formatter.macroTokenToFormatOpts = function macroTokenToFormatOpts(token) { 905 return _macroTokenToFormatOpts[token]; 906 }; 907 908 function Formatter(locale, formatOpts) { 909 this.opts = formatOpts; 910 this.loc = locale; 911 this.systemLoc = null; 912 } 913 914 var _proto = Formatter.prototype; 915 916 _proto.formatWithSystemDefault = function formatWithSystemDefault(dt, opts) { 917 if (this.systemLoc === null) { 918 this.systemLoc = this.loc.redefaultToSystem(); 919 } 920 921 var df = this.systemLoc.dtFormatter(dt, _extends({}, this.opts, opts)); 922 return df.format(); 923 }; 924 925 _proto.formatDateTime = function formatDateTime(dt, opts) { 926 if (opts === void 0) { 927 opts = {}; 928 } 929 930 var df = this.loc.dtFormatter(dt, _extends({}, this.opts, opts)); 931 return df.format(); 932 }; 933 934 _proto.formatDateTimeParts = function formatDateTimeParts(dt, opts) { 935 if (opts === void 0) { 936 opts = {}; 937 } 938 939 var df = this.loc.dtFormatter(dt, _extends({}, this.opts, opts)); 940 return df.formatToParts(); 941 }; 942 943 _proto.resolvedOptions = function resolvedOptions(dt, opts) { 944 if (opts === void 0) { 945 opts = {}; 946 } 947 948 var df = this.loc.dtFormatter(dt, _extends({}, this.opts, opts)); 949 return df.resolvedOptions(); 950 }; 951 952 _proto.num = function num(n, p) { 953 if (p === void 0) { 954 p = 0; 955 } 956 957 // we get some perf out of doing this here, annoyingly 958 if (this.opts.forceSimple) { 959 return padStart(n, p); 960 } 961 962 var opts = _extends({}, this.opts); 963 964 if (p > 0) { 965 opts.padTo = p; 966 } 967 968 return this.loc.numberFormatter(opts).format(n); 969 }; 970 971 _proto.formatDateTimeFromString = function formatDateTimeFromString(dt, fmt) { 972 var _this = this; 973 974 var knownEnglish = this.loc.listingMode() === "en", 975 useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory", 976 string = function string(opts, extract) { 977 return _this.loc.extract(dt, opts, extract); 978 }, 979 formatOffset = function formatOffset(opts) { 980 if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) { 981 return "Z"; 982 } 983 984 return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : ""; 985 }, 986 meridiem = function meridiem() { 987 return knownEnglish ? meridiemForDateTime(dt) : string({ 988 hour: "numeric", 989 hourCycle: "h12" 990 }, "dayperiod"); 991 }, 992 month = function month(length, standalone) { 993 return knownEnglish ? monthForDateTime(dt, length) : string(standalone ? { 994 month: length 995 } : { 996 month: length, 997 day: "numeric" 998 }, "month"); 999 }, 1000 weekday = function weekday(length, standalone) { 1001 return knownEnglish ? weekdayForDateTime(dt, length) : string(standalone ? { 1002 weekday: length 1003 } : { 1004 weekday: length, 1005 month: "long", 1006 day: "numeric" 1007 }, "weekday"); 1008 }, 1009 maybeMacro = function maybeMacro(token) { 1010 var formatOpts = Formatter.macroTokenToFormatOpts(token); 1011 1012 if (formatOpts) { 1013 return _this.formatWithSystemDefault(dt, formatOpts); 1014 } else { 1015 return token; 1016 } 1017 }, 1018 era = function era(length) { 1019 return knownEnglish ? eraForDateTime(dt, length) : string({ 1020 era: length 1021 }, "era"); 1022 }, 1023 tokenToString = function tokenToString(token) { 1024 // Where possible: http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles 1025 switch (token) { 1026 // ms 1027 case "S": 1028 return _this.num(dt.millisecond); 1029 1030 case "u": // falls through 1031 1032 case "SSS": 1033 return _this.num(dt.millisecond, 3); 1034 // seconds 1035 1036 case "s": 1037 return _this.num(dt.second); 1038 1039 case "ss": 1040 return _this.num(dt.second, 2); 1041 // fractional seconds 1042 1043 case "uu": 1044 return _this.num(Math.floor(dt.millisecond / 10), 2); 1045 1046 case "uuu": 1047 return _this.num(Math.floor(dt.millisecond / 100)); 1048 // minutes 1049 1050 case "m": 1051 return _this.num(dt.minute); 1052 1053 case "mm": 1054 return _this.num(dt.minute, 2); 1055 // hours 1056 1057 case "h": 1058 return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12); 1059 1060 case "hh": 1061 return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12, 2); 1062 1063 case "H": 1064 return _this.num(dt.hour); 1065 1066 case "HH": 1067 return _this.num(dt.hour, 2); 1068 // offset 1069 1070 case "Z": 1071 // like +6 1072 return formatOffset({ 1073 format: "narrow", 1074 allowZ: _this.opts.allowZ 1075 }); 1076 1077 case "ZZ": 1078 // like +06:00 1079 return formatOffset({ 1080 format: "short", 1081 allowZ: _this.opts.allowZ 1082 }); 1083 1084 case "ZZZ": 1085 // like +0600 1086 return formatOffset({ 1087 format: "techie", 1088 allowZ: _this.opts.allowZ 1089 }); 1090 1091 case "ZZZZ": 1092 // like EST 1093 return dt.zone.offsetName(dt.ts, { 1094 format: "short", 1095 locale: _this.loc.locale 1096 }); 1097 1098 case "ZZZZZ": 1099 // like Eastern Standard Time 1100 return dt.zone.offsetName(dt.ts, { 1101 format: "long", 1102 locale: _this.loc.locale 1103 }); 1104 // zone 1105 1106 case "z":
vendor: 23,132 bytes, lines 1107-2067
1107 // like America/New_York 1108 return dt.zoneName; 1109 // meridiems 1110 1111 case "a": 1112 return meridiem(); 1113 // dates 1114 1115 case "d": 1116 return useDateTimeFormatter ? string({ 1117 day: "numeric" 1118 }, "day") : _this.num(dt.day); 1119 1120 case "dd": 1121 return useDateTimeFormatter ? string({ 1122 day: "2-digit" 1123 }, "day") : _this.num(dt.day, 2); 1124 // weekdays - standalone 1125 1126 case "c": 1127 // like 1 1128 return _this.num(dt.weekday); 1129 1130 case "ccc": 1131 // like 'Tues' 1132 return weekday("short", true); 1133 1134 case "cccc": 1135 // like 'Tuesday' 1136 return weekday("long", true); 1137 1138 case "ccccc": 1139 // like 'T' 1140 return weekday("narrow", true); 1141 // weekdays - format 1142 1143 case "E": 1144 // like 1 1145 return _this.num(dt.weekday); 1146 1147 case "EEE": 1148 // like 'Tues' 1149 return weekday("short", false); 1150 1151 case "EEEE": 1152 // like 'Tuesday' 1153 return weekday("long", false); 1154 1155 case "EEEEE": 1156 // like 'T' 1157 return weekday("narrow", false); 1158 // months - standalone 1159 1160 case "L": 1161 // like 1 1162 return useDateTimeFormatter ? string({ 1163 month: "numeric", 1164 day: "numeric" 1165 }, "month") : _this.num(dt.month); 1166 1167 case "LL": 1168 // like 01, doesn't seem to work 1169 return useDateTimeFormatter ? string({ 1170 month: "2-digit", 1171 day: "numeric" 1172 }, "month") : _this.num(dt.month, 2); 1173 1174 case "LLL": 1175 // like Jan 1176 return month("short", true); 1177 1178 case "LLLL": 1179 // like January 1180 return month("long", true); 1181 1182 case "LLLLL": 1183 // like J 1184 return month("narrow", true); 1185 // months - format 1186 1187 case "M": 1188 // like 1 1189 return useDateTimeFormatter ? string({ 1190 month: "numeric" 1191 }, "month") : _this.num(dt.month); 1192 1193 case "MM": 1194 // like 01 1195 return useDateTimeFormatter ? string({ 1196 month: "2-digit" 1197 }, "month") : _this.num(dt.month, 2); 1198 1199 case "MMM": 1200 // like Jan 1201 return month("short", false); 1202 1203 case "MMMM": 1204 // like January 1205 return month("long", false); 1206 1207 case "MMMMM": 1208 // like J 1209 return month("narrow", false); 1210 // years 1211 1212 case "y": 1213 // like 2014 1214 return useDateTimeFormatter ? string({ 1215 year: "numeric" 1216 }, "year") : _this.num(dt.year); 1217 1218 case "yy": 1219 // like 14 1220 return useDateTimeFormatter ? string({ 1221 year: "2-digit" 1222 }, "year") : _this.num(dt.year.toString().slice(-2), 2); 1223 1224 case "yyyy": 1225 // like 0012 1226 return useDateTimeFormatter ? string({ 1227 year: "numeric" 1228 }, "year") : _this.num(dt.year, 4); 1229 1230 case "yyyyyy": 1231 // like 000012 1232 return useDateTimeFormatter ? string({ 1233 year: "numeric" 1234 }, "year") : _this.num(dt.year, 6); 1235 // eras 1236 1237 case "G": 1238 // like AD 1239 return era("short"); 1240 1241 case "GG": 1242 // like Anno Domini 1243 return era("long"); 1244 1245 case "GGGGG": 1246 return era("narrow"); 1247 1248 case "kk": 1249 return _this.num(dt.weekYear.toString().slice(-2), 2); 1250 1251 case "kkkk": 1252 return _this.num(dt.weekYear, 4); 1253 1254 case "W": 1255 return _this.num(dt.weekNumber); 1256 1257 case "WW": 1258 return _this.num(dt.weekNumber, 2); 1259 1260 case "o": 1261 return _this.num(dt.ordinal); 1262 1263 case "ooo": 1264 return _this.num(dt.ordinal, 3); 1265 1266 case "q": 1267 // like 1 1268 return _this.num(dt.quarter); 1269 1270 case "qq": 1271 // like 01 1272 return _this.num(dt.quarter, 2); 1273 1274 case "X": 1275 return _this.num(Math.floor(dt.ts / 1000)); 1276 1277 case "x": 1278 return _this.num(dt.ts); 1279 1280 default: 1281 return maybeMacro(token); 1282 } 1283 }; 1284 1285 return stringifyTokens(Formatter.parseFormat(fmt), tokenToString); 1286 }; 1287 1288 _proto.formatDurationFromString = function formatDurationFromString(dur, fmt) { 1289 var _this2 = this; 1290 1291 var tokenToField = function tokenToField(token) { 1292 switch (token[0]) { 1293 case "S": 1294 return "millisecond"; 1295 1296 case "s": 1297 return "second"; 1298 1299 case "m": 1300 return "minute"; 1301 1302 case "h": 1303 return "hour"; 1304 1305 case "d": 1306 return "day"; 1307 1308 case "w": 1309 return "week"; 1310 1311 case "M": 1312 return "month"; 1313 1314 case "y": 1315 return "year"; 1316 1317 default: 1318 return null; 1319 } 1320 }, 1321 tokenToString = function tokenToString(lildur) { 1322 return function (token) { 1323 var mapped = tokenToField(token); 1324 1325 if (mapped) { 1326 return _this2.num(lildur.get(mapped), token.length); 1327 } else { 1328 return token; 1329 } 1330 }; 1331 }, 1332 tokens = Formatter.parseFormat(fmt), 1333 realTokens = tokens.reduce(function (found, _ref) { 1334 var literal = _ref.literal, 1335 val = _ref.val; 1336 return literal ? found : found.concat(val); 1337 }, []), 1338 collapsed = dur.shiftTo.apply(dur, realTokens.map(tokenToField).filter(function (t) { 1339 return t; 1340 })); 1341 1342 return stringifyTokens(tokens, tokenToString(collapsed)); 1343 }; 1344 1345 return Formatter; 1346 }(); 1347 1348 var Invalid = /*#__PURE__*/function () { 1349 function Invalid(reason, explanation) { 1350 this.reason = reason; 1351 this.explanation = explanation; 1352 } 1353 1354 var _proto = Invalid.prototype; 1355 1356 _proto.toMessage = function toMessage() { 1357 if (this.explanation) { 1358 return this.reason + ": " + this.explanation; 1359 } else { 1360 return this.reason; 1361 } 1362 }; 1363 1364 return Invalid; 1365 }(); 1366 1367 /** 1368 * @interface 1369 */ 1370 1371 var Zone = /*#__PURE__*/function () { 1372 function Zone() {} 1373 1374 var _proto = Zone.prototype; 1375 1376 /** 1377 * Returns the offset's common name (such as EST) at the specified timestamp 1378 * @abstract 1379 * @param {number} ts - Epoch milliseconds for which to get the name 1380 * @param {Object} opts - Options to affect the format 1381 * @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'. 1382 * @param {string} opts.locale - What locale to return the offset name in. 1383 * @return {string} 1384 */ 1385 _proto.offsetName = function offsetName(ts, opts) { 1386 throw new ZoneIsAbstractError(); 1387 } 1388 /** 1389 * Returns the offset's value as a string 1390 * @abstract 1391 * @param {number} ts - Epoch milliseconds for which to get the offset 1392 * @param {string} format - What style of offset to return. 1393 * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively 1394 * @return {string} 1395 */ 1396 ; 1397 1398 _proto.formatOffset = function formatOffset(ts, format) { 1399 throw new ZoneIsAbstractError(); 1400 } 1401 /** 1402 * Return the offset in minutes for this zone at the specified timestamp. 1403 * @abstract 1404 * @param {number} ts - Epoch milliseconds for which to compute the offset 1405 * @return {number} 1406 */ 1407 ; 1408 1409 _proto.offset = function offset(ts) { 1410 throw new ZoneIsAbstractError(); 1411 } 1412 /** 1413 * Return whether this Zone is equal to another zone 1414 * @abstract 1415 * @param {Zone} otherZone - the zone to compare 1416 * @return {boolean} 1417 */ 1418 ; 1419 1420 _proto.equals = function equals(otherZone) { 1421 throw new ZoneIsAbstractError(); 1422 } 1423 /** 1424 * Return whether this Zone is valid. 1425 * @abstract 1426 * @type {boolean} 1427 */ 1428 ; 1429 1430 _createClass(Zone, [{ 1431 key: "type", 1432 get: 1433 /** 1434 * The type of zone 1435 * @abstract 1436 * @type {string} 1437 */ 1438 function get() { 1439 throw new ZoneIsAbstractError(); 1440 } 1441 /** 1442 * The name of this zone. 1443 * @abstract 1444 * @type {string} 1445 */ 1446 1447 }, { 1448 key: "name", 1449 get: function get() { 1450 throw new ZoneIsAbstractError(); 1451 } 1452 }, { 1453 key: "ianaName", 1454 get: function get() { 1455 return this.name; 1456 } 1457 /** 1458 * Returns whether the offset is known to be fixed for the whole year. 1459 * @abstract 1460 * @type {boolean} 1461 */ 1462 1463 }, { 1464 key: "isUniversal", 1465 get: function get() { 1466 throw new ZoneIsAbstractError(); 1467 } 1468 }, { 1469 key: "isValid", 1470 get: function get() { 1471 throw new ZoneIsAbstractError(); 1472 } 1473 }]); 1474 1475 return Zone; 1476 }(); 1477 1478 var singleton$1 = null; 1479 /** 1480 * Represents the local zone for this JavaScript environment. 1481 * @implements {Zone} 1482 */ 1483 1484 var SystemZone = /*#__PURE__*/function (_Zone) { 1485 _inheritsLoose(SystemZone, _Zone); 1486 1487 function SystemZone() { 1488 return _Zone.apply(this, arguments) || this; 1489 } 1490 1491 var _proto = SystemZone.prototype; 1492 1493 /** @override **/ 1494 _proto.offsetName = function offsetName(ts, _ref) { 1495 var format = _ref.format, 1496 locale = _ref.locale; 1497 return parseZoneInfo(ts, format, locale); 1498 } 1499 /** @override **/ 1500 ; 1501 1502 _proto.formatOffset = function formatOffset$1(ts, format) { 1503 return formatOffset(this.offset(ts), format); 1504 } 1505 /** @override **/ 1506 ; 1507 1508 _proto.offset = function offset(ts) { 1509 return -new Date(ts).getTimezoneOffset(); 1510 } 1511 /** @override **/ 1512 ; 1513 1514 _proto.equals = function equals(otherZone) { 1515 return otherZone.type === "system"; 1516 } 1517 /** @override **/ 1518 ; 1519 1520 _createClass(SystemZone, [{ 1521 key: "type", 1522 get: 1523 /** @override **/ 1524 function get() { 1525 return "system"; 1526 } 1527 /** @override **/ 1528 1529 }, { 1530 key: "name", 1531 get: function get() { 1532 return new Intl.DateTimeFormat().resolvedOptions().timeZone; 1533 } 1534 /** @override **/ 1535 1536 }, { 1537 key: "isUniversal", 1538 get: function get() { 1539 return false; 1540 } 1541 }, { 1542 key: "isValid", 1543 get: function get() { 1544 return true; 1545 } 1546 }], [{ 1547 key: "instance", 1548 get: 1549 /** 1550 * Get a singleton instance of the local zone 1551 * @return {SystemZone} 1552 */ 1553 function get() { 1554 if (singleton$1 === null) { 1555 singleton$1 = new SystemZone(); 1556 } 1557 1558 return singleton$1; 1559 } 1560 }]); 1561 1562 return SystemZone; 1563 }(Zone); 1564 1565 var dtfCache = {}; 1566 1567 function makeDTF(zone) { 1568 if (!dtfCache[zone]) { 1569 dtfCache[zone] = new Intl.DateTimeFormat("en-US", { 1570 hour12: false, 1571 timeZone: zone, 1572 year: "numeric", 1573 month: "2-digit", 1574 day: "2-digit", 1575 hour: "2-digit", 1576 minute: "2-digit", 1577 second: "2-digit", 1578 era: "short" 1579 }); 1580 } 1581 1582 return dtfCache[zone]; 1583 } 1584 1585 var typeToPos = { 1586 year: 0, 1587 month: 1, 1588 day: 2, 1589 era: 3, 1590 hour: 4, 1591 minute: 5, 1592 second: 6 1593 }; 1594 1595 function hackyOffset(dtf, date) { 1596 var formatted = dtf.format(date).replace(/\u200E/g, ""), 1597 parsed = /(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(formatted), 1598 fMonth = parsed[1], 1599 fDay = parsed[2], 1600 fYear = parsed[3], 1601 fadOrBc = parsed[4], 1602 fHour = parsed[5], 1603 fMinute = parsed[6], 1604 fSecond = parsed[7]; 1605 return [fYear, fMonth, fDay, fadOrBc, fHour, fMinute, fSecond]; 1606 } 1607 1608 function partsOffset(dtf, date) { 1609 var formatted = dtf.formatToParts(date); 1610 var filled = []; 1611 1612 for (var i = 0; i < formatted.length; i++) { 1613 var _formatted$i = formatted[i], 1614 type = _formatted$i.type, 1615 value = _formatted$i.value; 1616 var pos = typeToPos[type]; 1617 1618 if (type === "era") { 1619 filled[pos] = value; 1620 } else if (!isUndefined(pos)) { 1621 filled[pos] = parseInt(value, 10); 1622 } 1623 } 1624 1625 return filled; 1626 } 1627 1628 var ianaZoneCache = {}; 1629 /** 1630 * A zone identified by an IANA identifier, like America/New_York 1631 * @implements {Zone} 1632 */ 1633 1634 var IANAZone = /*#__PURE__*/function (_Zone) { 1635 _inheritsLoose(IANAZone, _Zone); 1636 1637 /** 1638 * @param {string} name - Zone name 1639 * @return {IANAZone} 1640 */ 1641 IANAZone.create = function create(name) { 1642 if (!ianaZoneCache[name]) { 1643 ianaZoneCache[name] = new IANAZone(name); 1644 } 1645 1646 return ianaZoneCache[name]; 1647 } 1648 /** 1649 * Reset local caches. Should only be necessary in testing scenarios. 1650 * @return {void} 1651 */ 1652 ; 1653 1654 IANAZone.resetCache = function resetCache() { 1655 ianaZoneCache = {}; 1656 dtfCache = {}; 1657 } 1658 /** 1659 * Returns whether the provided string is a valid specifier. This only checks the string's format, not that the specifier identifies a known zone; see isValidZone for that. 1660 * @param {string} s - The string to check validity on 1661 * @example IANAZone.isValidSpecifier("America/New_York") //=> true 1662 * @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false 1663 * @deprecated This method returns false for some valid IANA names. Use isValidZone instead. 1664 * @return {boolean} 1665 */ 1666 ; 1667 1668 IANAZone.isValidSpecifier = function isValidSpecifier(s) { 1669 return this.isValidZone(s); 1670 } 1671 /** 1672 * Returns whether the provided string identifies a real zone 1673 * @param {string} zone - The string to check 1674 * @example IANAZone.isValidZone("America/New_York") //=> true 1675 * @example IANAZone.isValidZone("Fantasia/Castle") //=> false 1676 * @example IANAZone.isValidZone("Sport~~blorp") //=> false 1677 * @return {boolean} 1678 */ 1679 ; 1680 1681 IANAZone.isValidZone = function isValidZone(zone) { 1682 if (!zone) { 1683 return false; 1684 } 1685 1686 try { 1687 new Intl.DateTimeFormat("en-US", { 1688 timeZone: zone 1689 }).format(); 1690 return true; 1691 } catch (e) { 1692 return false; 1693 } 1694 }; 1695 1696 function IANAZone(name) { 1697 var _this; 1698 1699 _this = _Zone.call(this) || this; 1700 /** @private **/ 1701 1702 _this.zoneName = name; 1703 /** @private **/ 1704 1705 _this.valid = IANAZone.isValidZone(name); 1706 return _this; 1707 } 1708 /** @override **/ 1709 1710 1711 var _proto = IANAZone.prototype; 1712 1713 /** @override **/ 1714 _proto.offsetName = function offsetName(ts, _ref) { 1715 var format = _ref.format, 1716 locale = _ref.locale; 1717 return parseZoneInfo(ts, format, locale, this.name); 1718 } 1719 /** @override **/ 1720 ; 1721 1722 _proto.formatOffset = function formatOffset$1(ts, format) { 1723 return formatOffset(this.offset(ts), format); 1724 } 1725 /** @override **/ 1726 ; 1727 1728 _proto.offset = function offset(ts) { 1729 var date = new Date(ts); 1730 if (isNaN(date)) return NaN; 1731 var dtf = makeDTF(this.name); 1732 1733 var _ref2 = dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date), 1734 year = _ref2[0], 1735 month = _ref2[1], 1736 day = _ref2[2], 1737 adOrBc = _ref2[3], 1738 hour = _ref2[4], 1739 minute = _ref2[5], 1740 second = _ref2[6]; 1741 1742 if (adOrBc === "BC") { 1743 year = -Math.abs(year) + 1; 1744 } // because we're using hour12 and https://bugs.chromium.org/p/chromium/issues/detail?id=1025564&can=2&q=%2224%3A00%22%20datetimeformat 1745 1746 1747 var adjustedHour = hour === 24 ? 0 : hour; 1748 var asUTC = objToLocalTS({ 1749 year: year, 1750 month: month, 1751 day: day, 1752 hour: adjustedHour, 1753 minute: minute, 1754 second: second, 1755 millisecond: 0 1756 }); 1757 var asTS = +date; 1758 var over = asTS % 1000; 1759 asTS -= over >= 0 ? over : 1000 + over; 1760 return (asUTC - asTS) / (60 * 1000); 1761 } 1762 /** @override **/ 1763 ; 1764 1765 _proto.equals = function equals(otherZone) { 1766 return otherZone.type === "iana" && otherZone.name === this.name; 1767 } 1768 /** @override **/ 1769 ; 1770 1771 _createClass(IANAZone, [{ 1772 key: "type", 1773 get: function get() { 1774 return "iana"; 1775 } 1776 /** @override **/ 1777 1778 }, { 1779 key: "name", 1780 get: function get() { 1781 return this.zoneName; 1782 } 1783 /** @override **/ 1784 1785 }, { 1786 key: "isUniversal", 1787 get: function get() { 1788 return false; 1789 } 1790 }, { 1791 key: "isValid", 1792 get: function get() { 1793 return this.valid; 1794 } 1795 }]); 1796 1797 return IANAZone; 1798 }(Zone); 1799 1800 var singleton = null; 1801 /** 1802 * A zone with a fixed offset (meaning no DST) 1803 * @implements {Zone} 1804 */ 1805 1806 var FixedOffsetZone = /*#__PURE__*/function (_Zone) { 1807 _inheritsLoose(FixedOffsetZone, _Zone); 1808 1809 /** 1810 * Get an instance with a specified offset 1811 * @param {number} offset - The offset in minutes 1812 * @return {FixedOffsetZone} 1813 */ 1814 FixedOffsetZone.instance = function instance(offset) { 1815 return offset === 0 ? FixedOffsetZone.utcInstance : new FixedOffsetZone(offset); 1816 } 1817 /** 1818 * Get an instance of FixedOffsetZone from a UTC offset string, like "UTC+6" 1819 * @param {string} s - The offset string to parse 1820 * @example FixedOffsetZone.parseSpecifier("UTC+6") 1821 * @example FixedOffsetZone.parseSpecifier("UTC+06") 1822 * @example FixedOffsetZone.parseSpecifier("UTC-6:00") 1823 * @return {FixedOffsetZone} 1824 */ 1825 ; 1826 1827 FixedOffsetZone.parseSpecifier = function parseSpecifier(s) { 1828 if (s) { 1829 var r = s.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i); 1830 1831 if (r) { 1832 return new FixedOffsetZone(signedOffset(r[1], r[2])); 1833 } 1834 } 1835 1836 return null; 1837 }; 1838 1839 function FixedOffsetZone(offset) { 1840 var _this; 1841 1842 _this = _Zone.call(this) || this; 1843 /** @private **/ 1844 1845 _this.fixed = offset; 1846 return _this; 1847 } 1848 /** @override **/ 1849 1850 1851 var _proto = FixedOffsetZone.prototype; 1852 1853 /** @override **/ 1854 _proto.offsetName = function offsetName() { 1855 return this.name; 1856 } 1857 /** @override **/ 1858 ; 1859 1860 _proto.formatOffset = function formatOffset$1(ts, format) { 1861 return formatOffset(this.fixed, format); 1862 } 1863 /** @override **/ 1864 ; 1865 1866 /** @override **/ 1867 _proto.offset = function offset() { 1868 return this.fixed; 1869 } 1870 /** @override **/ 1871 ; 1872 1873 _proto.equals = function equals(otherZone) { 1874 return otherZone.type === "fixed" && otherZone.fixed === this.fixed; 1875 } 1876 /** @override **/ 1877 ; 1878 1879 _createClass(FixedOffsetZone, [{ 1880 key: "type", 1881 get: function get() { 1882 return "fixed"; 1883 } 1884 /** @override **/ 1885 1886 }, { 1887 key: "name", 1888 get: function get() { 1889 return this.fixed === 0 ? "UTC" : "UTC" + formatOffset(this.fixed, "narrow"); 1890 } 1891 }, { 1892 key: "ianaName", 1893 get: function get() { 1894 if (this.fixed === 0) { 1895 return "Etc/UTC"; 1896 } else { 1897 return "Etc/GMT" + formatOffset(-this.fixed, "narrow"); 1898 } 1899 } 1900 }, { 1901 key: "isUniversal", 1902 get: function get() { 1903 return true; 1904 } 1905 }, { 1906 key: "isValid", 1907 get: function get() { 1908 return true; 1909 } 1910 }], [{ 1911 key: "utcInstance", 1912 get: 1913 /** 1914 * Get a singleton instance of UTC 1915 * @return {FixedOffsetZone} 1916 */ 1917 function get() { 1918 if (singleton === null) { 1919 singleton = new FixedOffsetZone(0); 1920 } 1921 1922 return singleton; 1923 } 1924 }]); 1925 1926 return FixedOffsetZone; 1927 }(Zone); 1928 1929 /** 1930 * A zone that failed to parse. You should never need to instantiate this. 1931 * @implements {Zone} 1932 */ 1933 1934 var InvalidZone = /*#__PURE__*/function (_Zone) { 1935 _inheritsLoose(InvalidZone, _Zone); 1936 1937 function InvalidZone(zoneName) { 1938 var _this; 1939 1940 _this = _Zone.call(this) || this; 1941 /** @private */ 1942 1943 _this.zoneName = zoneName; 1944 return _this; 1945 } 1946 /** @override **/ 1947 1948 1949 var _proto = InvalidZone.prototype; 1950 1951 /** @override **/ 1952 _proto.offsetName = function offsetName() { 1953 return null; 1954 } 1955 /** @override **/ 1956 ; 1957 1958 _proto.formatOffset = function formatOffset() { 1959 return ""; 1960 } 1961 /** @override **/ 1962 ; 1963 1964 _proto.offset = function offset() { 1965 return NaN; 1966 } 1967 /** @override **/ 1968 ; 1969 1970 _proto.equals = function equals() { 1971 return false; 1972 } 1973 /** @override **/ 1974 ; 1975 1976 _createClass(InvalidZone, [{ 1977 key: "type", 1978 get: function get() { 1979 return "invalid"; 1980 } 1981 /** @override **/ 1982 1983 }, { 1984 key: "name", 1985 get: function get() { 1986 return this.zoneName; 1987 } 1988 /** @override **/ 1989 1990 }, { 1991 key: "isUniversal", 1992 get: function get() { 1993 return false; 1994 } 1995 }, { 1996 key: "isValid", 1997 get: function get() { 1998 return false; 1999 } 2000 }]); 2001 2002 return InvalidZone; 2003 }(Zone); 2004 2005 /** 2006 * @private 2007 */ 2008 function normalizeZone(input, defaultZone) { 2009 2010 if (isUndefined(input) || input === null) { 2011 return defaultZone; 2012 } else if (input instanceof Zone) { 2013 return input; 2014 } else if (isString(input)) { 2015 var lowered = input.toLowerCase(); 2016 if (lowered === "local" || lowered === "system") return defaultZone;else if (lowered === "utc" || lowered === "gmt") return FixedOffsetZone.utcInstance;else return FixedOffsetZone.parseSpecifier(lowered) || IANAZone.create(input); 2017 } else if (isNumber(input)) { 2018 return FixedOffsetZone.instance(input); 2019 } else if (typeof input === "object" && input.offset && typeof input.offset === "number") { 2020 // This is dumb, but the instanceof check above doesn't seem to really work 2021 // so we're duck checking it 2022 return input; 2023 } else { 2024 return new InvalidZone(input); 2025 } 2026 } 2027 2028 var now = function now() { 2029 return Date.now(); 2030 }, 2031 defaultZone = "system", 2032 defaultLocale = null, 2033 defaultNumberingSystem = null, 2034 defaultOutputCalendar = null, 2035 throwOnInvalid; 2036 /** 2037 * Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here. 2038 */ 2039 2040 2041 var Settings = /*#__PURE__*/function () { 2042 function Settings() {} 2043 2044 /** 2045 * Reset Luxon's global caches. Should only be necessary in testing scenarios. 2046 * @return {void} 2047 */ 2048 Settings.resetCaches = function resetCaches() { 2049 Locale.resetCache(); 2050 IANAZone.resetCache(); 2051 }; 2052 2053 _createClass(Settings, null, [{ 2054 key: "now", 2055 get: 2056 /** 2057 * Get the callback for returning the current timestamp. 2058 * @type {function} 2059 */ 2060 function get() { 2061 return now; 2062 } 2063 /** 2064 * Set the callback for returning the current timestamp. 2065 * The function should return a number, which will be interpreted as an Epoch millisecond count 2066 * @type {function} 2067 * @example Settings.now = () =>
vendor: 4,734 bytes, lines 2067-2261
2067 Date.now() + 3000 // pretend it is 3 seconds in the future 2068 * @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time 2069 */ 2070 , 2071 set: function set(n) { 2072 now = n; 2073 } 2074 /** 2075 * Set the default time zone to create DateTimes in. Does not affect existing instances. 2076 * Use the value "system" to reset this value to the system's time zone. 2077 * @type {string} 2078 */ 2079 2080 }, { 2081 key: "defaultZone", 2082 get: 2083 /** 2084 * Get the default time zone object currently used to create DateTimes. Does not affect existing instances. 2085 * The default value is the system's time zone (the one set on the machine that runs this code). 2086 * @type {Zone} 2087 */ 2088 function get() { 2089 return normalizeZone(defaultZone, SystemZone.instance); 2090 } 2091 /** 2092 * Get the default locale to create DateTimes with. Does not affect existing instances. 2093 * @type {string} 2094 */ 2095 , 2096 set: function set(zone) { 2097 defaultZone = zone; 2098 } 2099 }, { 2100 key: "defaultLocale", 2101 get: function get() { 2102 return defaultLocale; 2103 } 2104 /** 2105 * Set the default locale to create DateTimes with. Does not affect existing instances. 2106 * @type {string} 2107 */ 2108 , 2109 set: function set(locale) { 2110 defaultLocale = locale; 2111 } 2112 /** 2113 * Get the default numbering system to create DateTimes with. Does not affect existing instances. 2114 * @type {string} 2115 */ 2116 2117 }, { 2118 key: "defaultNumberingSystem", 2119 get: function get() { 2120 return defaultNumberingSystem; 2121 } 2122 /** 2123 * Set the default numbering system to create DateTimes with. Does not affect existing instances. 2124 * @type {string} 2125 */ 2126 , 2127 set: function set(numberingSystem) { 2128 defaultNumberingSystem = numberingSystem; 2129 } 2130 /** 2131 * Get the default output calendar to create DateTimes with. Does not affect existing instances. 2132 * @type {string} 2133 */ 2134 2135 }, { 2136 key: "defaultOutputCalendar", 2137 get: function get() { 2138 return defaultOutputCalendar; 2139 } 2140 /** 2141 * Set the default output calendar to create DateTimes with. Does not affect existing instances. 2142 * @type {string} 2143 */ 2144 , 2145 set: function set(outputCalendar) { 2146 defaultOutputCalendar = outputCalendar; 2147 } 2148 /** 2149 * Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals 2150 * @type {boolean} 2151 */ 2152 2153 }, { 2154 key: "throwOnInvalid", 2155 get: function get() { 2156 return throwOnInvalid; 2157 } 2158 /** 2159 * Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals 2160 * @type {boolean} 2161 */ 2162 , 2163 set: function set(t) { 2164 throwOnInvalid = t; 2165 } 2166 }]); 2167 2168 return Settings; 2169 }(); 2170 2171 var _excluded = ["base"], 2172 _excluded2 = ["padTo", "floor"]; 2173 2174 var intlLFCache = {}; 2175 2176 function getCachedLF(locString, opts) { 2177 if (opts === void 0) { 2178 opts = {}; 2179 } 2180 2181 var key = JSON.stringify([locString, opts]); 2182 var dtf = intlLFCache[key]; 2183 2184 if (!dtf) { 2185 dtf = new Intl.ListFormat(locString, opts); 2186 intlLFCache[key] = dtf; 2187 } 2188 2189 return dtf; 2190 } 2191 2192 var intlDTCache = {}; 2193 2194 function getCachedDTF(locString, opts) { 2195 if (opts === void 0) { 2196 opts = {}; 2197 } 2198 2199 var key = JSON.stringify([locString, opts]); 2200 var dtf = intlDTCache[key]; 2201 2202 if (!dtf) { 2203 dtf = new Intl.DateTimeFormat(locString, opts); 2204 intlDTCache[key] = dtf; 2205 } 2206 2207 return dtf; 2208 } 2209 2210 var intlNumCache = {}; 2211 2212 function getCachedINF(locString, opts) { 2213 if (opts === void 0) { 2214 opts = {}; 2215 } 2216 2217 var key = JSON.stringify([locString, opts]); 2218 var inf = intlNumCache[key]; 2219 2220 if (!inf) { 2221 inf = new Intl.NumberFormat(locString, opts); 2222 intlNumCache[key] = inf; 2223 } 2224 2225 return inf; 2226 } 2227 2228 var intlRelCache = {}; 2229 2230 function getCachedRTF(locString, opts) { 2231 if (opts === void 0) { 2232 opts = {}; 2233 } 2234 2235 var _opts = opts; 2236 _opts.base; 2237 var cacheKeyOpts = _objectWithoutPropertiesLoose(_opts, _excluded); // exclude `base` from the options 2238 2239 2240 var key = JSON.stringify([locString, cacheKeyOpts]); 2241 var inf = intlRelCache[key]; 2242 2243 if (!inf) { 2244 inf = new Intl.RelativeTimeFormat(locString, opts); 2245 intlRelCache[key] = inf; 2246 } 2247 2248 return inf; 2249 } 2250 2251 var sysLocaleCache = null; 2252 2253 function systemLocale() { 2254 if (sysLocaleCache) { 2255 return sysLocaleCache; 2256 } else { 2257 sysLocaleCache = new Intl.DateTimeFormat().resolvedOptions().locale; 2258 return sysLocaleCache; 2259 } 2260 } 2261
vendor: 6,895 bytes, lines 2262-2509
2262 function parseLocaleString(localeStr) { 2263 // I really want to avoid writing a BCP 47 parser 2264 // see, e.g. https://github.com/wooorm/bcp-47 2265 // Instead, we'll do this: 2266 // a) if the string has no -u extensions, just leave it alone 2267 // b) if it does, use Intl to resolve everything 2268 // c) if Intl fails, try again without the -u 2269 var uIndex = localeStr.indexOf("-u-"); 2270 2271 if (uIndex === -1) { 2272 return [localeStr]; 2273 } else { 2274 var options; 2275 var smaller = localeStr.substring(0, uIndex); 2276 2277 try { 2278 options = getCachedDTF(localeStr).resolvedOptions(); 2279 } catch (e) { 2280 options = getCachedDTF(smaller).resolvedOptions(); 2281 } 2282 2283 var _options = options, 2284 numberingSystem = _options.numberingSystem, 2285 calendar = _options.calendar; // return the smaller one so that we can append the calendar and numbering overrides to it 2286 2287 return [smaller, numberingSystem, calendar]; 2288 } 2289 } 2290 2291 function intlConfigString(localeStr, numberingSystem, outputCalendar) { 2292 if (outputCalendar || numberingSystem) { 2293 localeStr += "-u"; 2294 2295 if (outputCalendar) { 2296 localeStr += "-ca-" + outputCalendar; 2297 } 2298 2299 if (numberingSystem) { 2300 localeStr += "-nu-" + numberingSystem; 2301 } 2302 2303 return localeStr; 2304 } else { 2305 return localeStr; 2306 } 2307 } 2308 2309 function mapMonths(f) { 2310 var ms = []; 2311 2312 for (var i = 1; i <= 12; i++) { 2313 var dt = DateTime.utc(2016, i, 1); 2314 ms.push(f(dt)); 2315 } 2316 2317 return ms; 2318 } 2319 2320 function mapWeekdays(f) { 2321 var ms = []; 2322 2323 for (var i = 1; i <= 7; i++) { 2324 var dt = DateTime.utc(2016, 11, 13 + i); 2325 ms.push(f(dt)); 2326 } 2327 2328 return ms; 2329 } 2330 2331 function listStuff(loc, length, defaultOK, englishFn, intlFn) { 2332 var mode = loc.listingMode(defaultOK); 2333 2334 if (mode === "error") { 2335 return null; 2336 } else if (mode === "en") { 2337 return englishFn(length); 2338 } else { 2339 return intlFn(length); 2340 } 2341 } 2342 2343 function supportsFastNumbers(loc) { 2344 if (loc.numberingSystem && loc.numberingSystem !== "latn") { 2345 return false; 2346 } else { 2347 return loc.numberingSystem === "latn" || !loc.locale || loc.locale.startsWith("en") || new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn"; 2348 } 2349 } 2350 /** 2351 * @private 2352 */ 2353 2354 2355 var PolyNumberFormatter = /*#__PURE__*/function () { 2356 function PolyNumberFormatter(intl, forceSimple, opts) { 2357 this.padTo = opts.padTo || 0; 2358 this.floor = opts.floor || false; 2359 2360 opts.padTo; 2361 opts.floor; 2362 var otherOpts = _objectWithoutPropertiesLoose(opts, _excluded2); 2363 2364 if (!forceSimple || Object.keys(otherOpts).length > 0) { 2365 var intlOpts = _extends({ 2366 useGrouping: false 2367 }, opts); 2368 2369 if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo; 2370 this.inf = getCachedINF(intl, intlOpts); 2371 } 2372 } 2373 2374 var _proto = PolyNumberFormatter.prototype; 2375 2376 _proto.format = function format(i) { 2377 if (this.inf) { 2378 var fixed = this.floor ? Math.floor(i) : i; 2379 return this.inf.format(fixed); 2380 } else { 2381 // to match the browser's numberformatter defaults 2382 var _fixed = this.floor ? Math.floor(i) : roundTo(i, 3); 2383 2384 return padStart(_fixed, this.padTo); 2385 } 2386 }; 2387 2388 return PolyNumberFormatter; 2389 }(); 2390 /** 2391 * @private 2392 */ 2393 2394 2395 var PolyDateFormatter = /*#__PURE__*/function () { 2396 function PolyDateFormatter(dt, intl, opts) { 2397 this.opts = opts; 2398 var z; 2399 2400 if (dt.zone.isUniversal) { 2401 // UTC-8 or Etc/UTC-8 are not part of tzdata, only Etc/GMT+8 and the like. 2402 // That is why fixed-offset TZ is set to that unless it is: 2403 // 1. Representing offset 0 when UTC is used to maintain previous behavior and does not become GMT. 2404 // 2. Unsupported by the browser: 2405 // - some do not support Etc/ 2406 // - < Etc/GMT-14, > Etc/GMT+12, and 30-minute or 45-minute offsets are not part of tzdata 2407 var gmtOffset = -1 * (dt.offset / 60); 2408 var offsetZ = gmtOffset >= 0 ? "Etc/GMT+" + gmtOffset : "Etc/GMT" + gmtOffset; 2409 2410 if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) { 2411 z = offsetZ; 2412 this.dt = dt; 2413 } else { 2414 // Not all fixed-offset zones like Etc/+4:30 are present in tzdata. 2415 // So we have to make do. Two cases: 2416 // 1. The format options tell us to show the zone. We can't do that, so the best 2417 // we can do is format the date in UTC. 2418 // 2. The format options don't tell us to show the zone. Then we can adjust them 2419 // the time and tell the formatter to show it to us in UTC, so that the time is right 2420 // and the bad zone doesn't show up. 2421 z = "UTC"; 2422 2423 if (opts.timeZoneName) { 2424 this.dt = dt; 2425 } else { 2426 this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000); 2427 } 2428 } 2429 } else if (dt.zone.type === "system") { 2430 this.dt = dt; 2431 } else { 2432 this.dt = dt; 2433 z = dt.zone.name; 2434 } 2435 2436 var intlOpts = _extends({}, this.opts); 2437 2438 if (z) { 2439 intlOpts.timeZone = z; 2440 } 2441 2442 this.dtf = getCachedDTF(intl, intlOpts); 2443 } 2444 2445 var _proto2 = PolyDateFormatter.prototype; 2446 2447 _proto2.format = function format() { 2448 return this.dtf.format(this.dt.toJSDate()); 2449 }; 2450 2451 _proto2.formatToParts = function formatToParts() { 2452 return this.dtf.formatToParts(this.dt.toJSDate()); 2453 }; 2454 2455 _proto2.resolvedOptions = function resolvedOptions() { 2456 return this.dtf.resolvedOptions(); 2457 }; 2458 2459 return PolyDateFormatter; 2460 }(); 2461 /** 2462 * @private 2463 */ 2464 2465 2466 var PolyRelFormatter = /*#__PURE__*/function () { 2467 function PolyRelFormatter(intl, isEnglish, opts) { 2468 this.opts = _extends({ 2469 style: "long" 2470 }, opts); 2471 2472 if (!isEnglish && hasRelative()) { 2473 this.rtf = getCachedRTF(intl, opts); 2474 } 2475 } 2476 2477 var _proto3 = PolyRelFormatter.prototype; 2478 2479 _proto3.format = function format(count, unit) { 2480 if (this.rtf) { 2481 return this.rtf.format(count, unit); 2482 } else { 2483 return formatRelativeTime(unit, count, this.opts.numeric, this.opts.style !== "long"); 2484 } 2485 }; 2486 2487 _proto3.formatToParts = function formatToParts(count, unit) { 2488 if (this.rtf) { 2489 return this.rtf.formatToParts(count, unit); 2490 } else { 2491 return []; 2492 } 2493 }; 2494 2495 return PolyRelFormatter; 2496 }(); 2497 /** 2498 * @private 2499 */ 2500 2501 2502 var Locale = /*#__PURE__*/function () { 2503 Locale.fromOpts = function fromOpts(opts) { 2504 return Locale.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN); 2505 }; 2506 2507 Locale.create = function create(locale, numberingSystem, outputCalendar, defaultToEN) { 2508 if (defaultToEN === void 0) { 2509 defaultToEN = false;
vendor: 10,504 bytes, lines 2510-2838
2510 } 2511 2512 var specifiedLocale = locale || Settings.defaultLocale; // the system locale is useful for human readable strings but annoying for parsing/formatting known formats 2513 2514 var localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale()); 2515 var numberingSystemR = numberingSystem || Settings.defaultNumberingSystem; 2516 var outputCalendarR = outputCalendar || Settings.defaultOutputCalendar; 2517 return new Locale(localeR, numberingSystemR, outputCalendarR, specifiedLocale); 2518 }; 2519 2520 Locale.resetCache = function resetCache() { 2521 sysLocaleCache = null; 2522 intlDTCache = {}; 2523 intlNumCache = {}; 2524 intlRelCache = {}; 2525 }; 2526 2527 Locale.fromObject = function fromObject(_temp) { 2528 var _ref = _temp === void 0 ? {} : _temp, 2529 locale = _ref.locale, 2530 numberingSystem = _ref.numberingSystem, 2531 outputCalendar = _ref.outputCalendar; 2532 2533 return Locale.create(locale, numberingSystem, outputCalendar); 2534 }; 2535 2536 function Locale(locale, numbering, outputCalendar, specifiedLocale) { 2537 var _parseLocaleString = parseLocaleString(locale), 2538 parsedLocale = _parseLocaleString[0], 2539 parsedNumberingSystem = _parseLocaleString[1], 2540 parsedOutputCalendar = _parseLocaleString[2]; 2541 2542 this.locale = parsedLocale; 2543 this.numberingSystem = numbering || parsedNumberingSystem || null; 2544 this.outputCalendar = outputCalendar || parsedOutputCalendar || null; 2545 this.intl = intlConfigString(this.locale, this.numberingSystem, this.outputCalendar); 2546 this.weekdaysCache = { 2547 format: {}, 2548 standalone: {} 2549 }; 2550 this.monthsCache = { 2551 format: {}, 2552 standalone: {} 2553 }; 2554 this.meridiemCache = null; 2555 this.eraCache = {}; 2556 this.specifiedLocale = specifiedLocale; 2557 this.fastNumbersCached = null; 2558 } 2559 2560 var _proto4 = Locale.prototype; 2561 2562 _proto4.listingMode = function listingMode() { 2563 var isActuallyEn = this.isEnglish(); 2564 var hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory"); 2565 return isActuallyEn && hasNoWeirdness ? "en" : "intl"; 2566 }; 2567 2568 _proto4.clone = function clone(alts) { 2569 if (!alts || Object.getOwnPropertyNames(alts).length === 0) { 2570 return this; 2571 } else { 2572 return Locale.create(alts.locale || this.specifiedLocale, alts.numberingSystem || this.numberingSystem, alts.outputCalendar || this.outputCalendar, alts.defaultToEN || false); 2573 } 2574 }; 2575 2576 _proto4.redefaultToEN = function redefaultToEN(alts) { 2577 if (alts === void 0) { 2578 alts = {}; 2579 } 2580 2581 return this.clone(_extends({}, alts, { 2582 defaultToEN: true 2583 })); 2584 }; 2585 2586 _proto4.redefaultToSystem = function redefaultToSystem(alts) { 2587 if (alts === void 0) { 2588 alts = {}; 2589 } 2590 2591 return this.clone(_extends({}, alts, { 2592 defaultToEN: false 2593 })); 2594 }; 2595 2596 _proto4.months = function months$1(length, format, defaultOK) { 2597 var _this = this; 2598 2599 if (format === void 0) { 2600 format = false; 2601 } 2602 2603 if (defaultOK === void 0) { 2604 defaultOK = true; 2605 } 2606 2607 return listStuff(this, length, defaultOK, months, function () { 2608 var intl = format ? { 2609 month: length, 2610 day: "numeric" 2611 } : { 2612 month: length 2613 }, 2614 formatStr = format ? "format" : "standalone"; 2615 2616 if (!_this.monthsCache[formatStr][length]) { 2617 _this.monthsCache[formatStr][length] = mapMonths(function (dt) { 2618 return _this.extract(dt, intl, "month"); 2619 }); 2620 } 2621 2622 return _this.monthsCache[formatStr][length]; 2623 }); 2624 }; 2625 2626 _proto4.weekdays = function weekdays$1(length, format, defaultOK) { 2627 var _this2 = this; 2628 2629 if (format === void 0) { 2630 format = false; 2631 } 2632 2633 if (defaultOK === void 0) { 2634 defaultOK = true; 2635 } 2636 2637 return listStuff(this, length, defaultOK, weekdays, function () { 2638 var intl = format ? { 2639 weekday: length, 2640 year: "numeric", 2641 month: "long", 2642 day: "numeric" 2643 } : { 2644 weekday: length 2645 }, 2646 formatStr = format ? "format" : "standalone"; 2647 2648 if (!_this2.weekdaysCache[formatStr][length]) { 2649 _this2.weekdaysCache[formatStr][length] = mapWeekdays(function (dt) { 2650 return _this2.extract(dt, intl, "weekday"); 2651 }); 2652 } 2653 2654 return _this2.weekdaysCache[formatStr][length]; 2655 }); 2656 }; 2657 2658 _proto4.meridiems = function meridiems$1(defaultOK) { 2659 var _this3 = this; 2660 2661 if (defaultOK === void 0) { 2662 defaultOK = true; 2663 } 2664 2665 return listStuff(this, undefined, defaultOK, function () { 2666 return meridiems; 2667 }, function () { 2668 // In theory there could be aribitrary day periods. We're gonna assume there are exactly two 2669 // for AM and PM. This is probably wrong, but it's makes parsing way easier. 2670 if (!_this3.meridiemCache) { 2671 var intl = { 2672 hour: "numeric", 2673 hourCycle: "h12" 2674 }; 2675 _this3.meridiemCache = [DateTime.utc(2016, 11, 13, 9), DateTime.utc(2016, 11, 13, 19)].map(function (dt) { 2676 return _this3.extract(dt, intl, "dayperiod"); 2677 }); 2678 } 2679 2680 return _this3.meridiemCache; 2681 }); 2682 }; 2683 2684 _proto4.eras = function eras$1(length, defaultOK) { 2685 var _this4 = this; 2686 2687 if (defaultOK === void 0) { 2688 defaultOK = true; 2689 } 2690 2691 return listStuff(this, length, defaultOK, eras, function () { 2692 var intl = { 2693 era: length 2694 }; // This is problematic. Different calendars are going to define eras totally differently. What I need is the minimum set of dates 2695 // to definitely enumerate them. 2696 2697 if (!_this4.eraCache[length]) { 2698 _this4.eraCache[length] = [DateTime.utc(-40, 1, 1), DateTime.utc(2017, 1, 1)].map(function (dt) { 2699 return _this4.extract(dt, intl, "era"); 2700 }); 2701 } 2702 2703 return _this4.eraCache[length]; 2704 }); 2705 }; 2706 2707 _proto4.extract = function extract(dt, intlOpts, field) { 2708 var df = this.dtFormatter(dt, intlOpts), 2709 results = df.formatToParts(), 2710 matching = results.find(function (m) { 2711 return m.type.toLowerCase() === field; 2712 }); 2713 return matching ? matching.value : null; 2714 }; 2715 2716 _proto4.numberFormatter = function numberFormatter(opts) { 2717 if (opts === void 0) { 2718 opts = {}; 2719 } 2720 2721 // this forcesimple option is never used (the only caller short-circuits on it, but it seems safer to leave) 2722 // (in contrast, the rest of the condition is used heavily) 2723 return new PolyNumberFormatter(this.intl, opts.forceSimple || this.fastNumbers, opts); 2724 }; 2725 2726 _proto4.dtFormatter = function dtFormatter(dt, intlOpts) { 2727 if (intlOpts === void 0) { 2728 intlOpts = {}; 2729 } 2730 2731 return new PolyDateFormatter(dt, this.intl, intlOpts); 2732 }; 2733 2734 _proto4.relFormatter = function relFormatter(opts) { 2735 if (opts === void 0) { 2736 opts = {}; 2737 } 2738 2739 return new PolyRelFormatter(this.intl, this.isEnglish(), opts); 2740 }; 2741 2742 _proto4.listFormatter = function listFormatter(opts) { 2743 if (opts === void 0) { 2744 opts = {}; 2745 } 2746 2747 return getCachedLF(this.intl, opts); 2748 }; 2749 2750 _proto4.isEnglish = function isEnglish() { 2751 return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us"); 2752 }; 2753 2754 _proto4.equals = function equals(other) { 2755 return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar; 2756 }; 2757 2758 _createClass(Locale, [{ 2759 key: "fastNumbers", 2760 get: function get() { 2761 if (this.fastNumbersCached == null) { 2762 this.fastNumbersCached = supportsFastNumbers(this); 2763 } 2764 2765 return this.fastNumbersCached; 2766 } 2767 }]); 2768 2769 return Locale; 2770 }(); 2771 2772 /* 2773 * This file handles parsing for well-specified formats. Here's how it works: 2774 * Two things go into parsing: a regex to match with and an extractor to take apart the groups in the match. 2775 * An extractor is just a function that takes a regex match array and returns a { year: ..., month: ... } object 2776 * parse() does the work of executing the regex and applying the extractor. It takes multiple regex/extractor pairs to try in sequence. 2777 * Extractors can take a "cursor" representing the offset in the match to look at. This makes it easy to combine extractors. 2778 * combineExtractors() does the work of combining them, keeping track of the cursor through multiple extractions. 2779 * Some extractions are super dumb and simpleParse and fromStrings help DRY them. 2780 */ 2781 2782 function combineRegexes() { 2783 for (var _len = arguments.length, regexes = new Array(_len), _key = 0; _key < _len; _key++) { 2784 regexes[_key] = arguments[_key]; 2785 } 2786 2787 var full = regexes.reduce(function (f, r) { 2788 return f + r.source; 2789 }, ""); 2790 return RegExp("^" + full + "$"); 2791 } 2792 2793 function combineExtractors() { 2794 for (var _len2 = arguments.length, extractors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 2795 extractors[_key2] = arguments[_key2]; 2796 } 2797 2798 return function (m) { 2799 return extractors.reduce(function (_ref, ex) { 2800 var mergedVals = _ref[0], 2801 mergedZone = _ref[1], 2802 cursor = _ref[2]; 2803 2804 var _ex = ex(m, cursor), 2805 val = _ex[0], 2806 zone = _ex[1], 2807 next = _ex[2]; 2808 2809 return [_extends({}, mergedVals, val), zone || mergedZone, next]; 2810 }, [{}, null, 1]).slice(0, 2); 2811 }; 2812 } 2813 2814 function parse(s) { 2815 if (s == null) { 2816 return [null, null]; 2817 } 2818 2819 for (var _len3 = arguments.length, patterns = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { 2820 patterns[_key3 - 1] = arguments[_key3]; 2821 } 2822 2823 for (var _i = 0, _patterns = patterns; _i < _patterns.length; _i++) { 2824 var _patterns$_i = _patterns[_i], 2825 regex = _patterns$_i[0], 2826 extractor = _patterns$_i[1]; 2827 var m = regex.exec(s); 2828 2829 if (m) { 2830 return extractor(m); 2831 } 2832 } 2833 2834 return [null, null]; 2835 } 2836 2837 function simpleParse() { 2838 for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
vendor: 11,999 bytes, lines 2839-3169
2839 keys[_key4] = arguments[_key4]; 2840 } 2841 2842 return function (match, cursor) { 2843 var ret = {}; 2844 var i; 2845 2846 for (i = 0; i < keys.length; i++) { 2847 ret[keys[i]] = parseInteger(match[cursor + i]); 2848 } 2849 2850 return [ret, null, cursor + i]; 2851 }; 2852 } // ISO and SQL parsing 2853 2854 2855 var offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/; 2856 var isoExtendedZone = "(?:" + offsetRegex.source + "?(?:\\[(" + ianaRegex.source + ")\\])?)?"; 2857 var isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/; 2858 var isoTimeRegex = RegExp("" + isoTimeBaseRegex.source + isoExtendedZone); 2859 var isoTimeExtensionRegex = RegExp("(?:T" + isoTimeRegex.source + ")?"); 2860 var isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/; 2861 var isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/; 2862 var isoOrdinalRegex = /(\d{4})-?(\d{3})/; 2863 var extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay"); 2864 var extractISOOrdinalData = simpleParse("year", "ordinal"); 2865 var sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/; // dumbed-down version of the ISO one 2866 2867 var sqlTimeRegex = RegExp(isoTimeBaseRegex.source + " ?(?:" + offsetRegex.source + "|(" + ianaRegex.source + "))?"); 2868 var sqlTimeExtensionRegex = RegExp("(?: " + sqlTimeRegex.source + ")?"); 2869 2870 function int(match, pos, fallback) { 2871 var m = match[pos]; 2872 return isUndefined(m) ? fallback : parseInteger(m); 2873 } 2874 2875 function extractISOYmd(match, cursor) { 2876 var item = { 2877 year: int(match, cursor), 2878 month: int(match, cursor + 1, 1), 2879 day: int(match, cursor + 2, 1) 2880 }; 2881 return [item, null, cursor + 3]; 2882 } 2883 2884 function extractISOTime(match, cursor) { 2885 var item = { 2886 hours: int(match, cursor, 0), 2887 minutes: int(match, cursor + 1, 0), 2888 seconds: int(match, cursor + 2, 0), 2889 milliseconds: parseMillis(match[cursor + 3]) 2890 }; 2891 return [item, null, cursor + 4]; 2892 } 2893 2894 function extractISOOffset(match, cursor) { 2895 var local = !match[cursor] && !match[cursor + 1], 2896 fullOffset = signedOffset(match[cursor + 1], match[cursor + 2]), 2897 zone = local ? null : FixedOffsetZone.instance(fullOffset); 2898 return [{}, zone, cursor + 3]; 2899 } 2900 2901 function extractIANAZone(match, cursor) { 2902 var zone = match[cursor] ? IANAZone.create(match[cursor]) : null; 2903 return [{}, zone, cursor + 1]; 2904 } // ISO time parsing 2905 2906 2907 var isoTimeOnly = RegExp("^T?" + isoTimeBaseRegex.source + "$"); // ISO duration parsing 2908 2909 var isoDuration = /^-?P(?:(?:(-?\d{1,9}(?:\.\d{1,9})?)Y)?(?:(-?\d{1,9}(?:\.\d{1,9})?)M)?(?:(-?\d{1,9}(?:\.\d{1,9})?)W)?(?:(-?\d{1,9}(?:\.\d{1,9})?)D)?(?:T(?:(-?\d{1,9}(?:\.\d{1,9})?)H)?(?:(-?\d{1,9}(?:\.\d{1,9})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,9}))?S)?)?)$/; 2910 2911 function extractISODuration(match) { 2912 var s = match[0], 2913 yearStr = match[1], 2914 monthStr = match[2], 2915 weekStr = match[3], 2916 dayStr = match[4], 2917 hourStr = match[5], 2918 minuteStr = match[6], 2919 secondStr = match[7], 2920 millisecondsStr = match[8]; 2921 var hasNegativePrefix = s[0] === "-"; 2922 var negativeSeconds = secondStr && secondStr[0] === "-"; 2923 2924 var maybeNegate = function maybeNegate(num, force) { 2925 if (force === void 0) { 2926 force = false; 2927 } 2928 2929 return num !== undefined && (force || num && hasNegativePrefix) ? -num : num; 2930 }; 2931 2932 return [{ 2933 years: maybeNegate(parseFloating(yearStr)), 2934 months: maybeNegate(parseFloating(monthStr)), 2935 weeks: maybeNegate(parseFloating(weekStr)), 2936 days: maybeNegate(parseFloating(dayStr)), 2937 hours: maybeNegate(parseFloating(hourStr)), 2938 minutes: maybeNegate(parseFloating(minuteStr)), 2939 seconds: maybeNegate(parseFloating(secondStr), secondStr === "-0"), 2940 milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds) 2941 }]; 2942 } // These are a little braindead. EDT *should* tell us that we're in, say, America/New_York 2943 // and not just that we're in -240 *right now*. But since I don't think these are used that often 2944 // I'm just going to ignore that 2945 2946 2947 var obsOffsets = { 2948 GMT: 0, 2949 EDT: -4 * 60, 2950 EST: -5 * 60, 2951 CDT: -5 * 60, 2952 CST: -6 * 60, 2953 MDT: -6 * 60, 2954 MST: -7 * 60, 2955 PDT: -7 * 60, 2956 PST: -8 * 60 2957 }; 2958 2959 function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) { 2960 var result = { 2961 year: yearStr.length === 2 ? untruncateYear(parseInteger(yearStr)) : parseInteger(yearStr), 2962 month: monthsShort.indexOf(monthStr) + 1, 2963 day: parseInteger(dayStr), 2964 hour: parseInteger(hourStr), 2965 minute: parseInteger(minuteStr) 2966 }; 2967 if (secondStr) result.second = parseInteger(secondStr); 2968 2969 if (weekdayStr) { 2970 result.weekday = weekdayStr.length > 3 ? weekdaysLong.indexOf(weekdayStr) + 1 : weekdaysShort.indexOf(weekdayStr) + 1; 2971 } 2972 2973 return result; 2974 } // RFC 2822/5322 2975 2976 2977 var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/; 2978 2979 function extractRFC2822(match) { 2980 var weekdayStr = match[1], 2981 dayStr = match[2], 2982 monthStr = match[3], 2983 yearStr = match[4], 2984 hourStr = match[5], 2985 minuteStr = match[6], 2986 secondStr = match[7], 2987 obsOffset = match[8], 2988 milOffset = match[9], 2989 offHourStr = match[10], 2990 offMinuteStr = match[11], 2991 result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr); 2992 var offset; 2993 2994 if (obsOffset) { 2995 offset = obsOffsets[obsOffset]; 2996 } else if (milOffset) { 2997 offset = 0; 2998 } else { 2999 offset = signedOffset(offHourStr, offMinuteStr); 3000 } 3001 3002 return [result, new FixedOffsetZone(offset)]; 3003 } 3004 3005 function preprocessRFC2822(s) { 3006 // Remove comments and folding whitespace and replace multiple-spaces with a single space 3007 return s.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim(); 3008 } // http date 3009 3010 3011 var rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/, 3012 rfc850 = /^(Monday|Tuesday|Wedsday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/, 3013 ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/; 3014 3015 function extractRFC1123Or850(match) { 3016 var weekdayStr = match[1], 3017 dayStr = match[2], 3018 monthStr = match[3], 3019 yearStr = match[4], 3020 hourStr = match[5], 3021 minuteStr = match[6], 3022 secondStr = match[7], 3023 result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr); 3024 return [result, FixedOffsetZone.utcInstance]; 3025 } 3026 3027 function extractASCII(match) { 3028 var weekdayStr = match[1], 3029 monthStr = match[2], 3030 dayStr = match[3], 3031 hourStr = match[4], 3032 minuteStr = match[5], 3033 secondStr = match[6], 3034 yearStr = match[7], 3035 result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr); 3036 return [result, FixedOffsetZone.utcInstance]; 3037 } 3038 3039 var isoYmdWithTimeExtensionRegex = combineRegexes(isoYmdRegex, isoTimeExtensionRegex); 3040 var isoWeekWithTimeExtensionRegex = combineRegexes(isoWeekRegex, isoTimeExtensionRegex); 3041 var isoOrdinalWithTimeExtensionRegex = combineRegexes(isoOrdinalRegex, isoTimeExtensionRegex); 3042 var isoTimeCombinedRegex = combineRegexes(isoTimeRegex); 3043 var extractISOYmdTimeAndOffset = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset, extractIANAZone); 3044 var extractISOWeekTimeAndOffset = combineExtractors(extractISOWeekData, extractISOTime, extractISOOffset, extractIANAZone); 3045 var extractISOOrdinalDateAndTime = combineExtractors(extractISOOrdinalData, extractISOTime, extractISOOffset, extractIANAZone); 3046 var extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset, extractIANAZone); 3047 /* 3048 * @private 3049 */ 3050 3051 function parseISODate(s) { 3052 return parse(s, [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset], [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDateAndTime], [isoTimeCombinedRegex, extractISOTimeAndOffset]); 3053 } 3054 function parseRFC2822Date(s) { 3055 return parse(preprocessRFC2822(s), [rfc2822, extractRFC2822]); 3056 } 3057 function parseHTTPDate(s) { 3058 return parse(s, [rfc1123, extractRFC1123Or850], [rfc850, extractRFC1123Or850], [ascii, extractASCII]); 3059 } 3060 function parseISODuration(s) { 3061 return parse(s, [isoDuration, extractISODuration]); 3062 } 3063 var extractISOTimeOnly = combineExtractors(extractISOTime); 3064 function parseISOTimeOnly(s) { 3065 return parse(s, [isoTimeOnly, extractISOTimeOnly]); 3066 } 3067 var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex); 3068 var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex); 3069 var extractISOTimeOffsetAndIANAZone = combineExtractors(extractISOTime, extractISOOffset, extractIANAZone); 3070 function parseSQL(s) { 3071 return parse(s, [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]); 3072 } 3073 3074 var INVALID$2 = "Invalid Duration"; // unit conversion constants 3075 3076 var lowOrderMatrix = { 3077 weeks: { 3078 days: 7, 3079 hours: 7 * 24, 3080 minutes: 7 * 24 * 60, 3081 seconds: 7 * 24 * 60 * 60, 3082 milliseconds: 7 * 24 * 60 * 60 * 1000 3083 }, 3084 days: { 3085 hours: 24, 3086 minutes: 24 * 60, 3087 seconds: 24 * 60 * 60, 3088 milliseconds: 24 * 60 * 60 * 1000 3089 }, 3090 hours: { 3091 minutes: 60, 3092 seconds: 60 * 60, 3093 milliseconds: 60 * 60 * 1000 3094 }, 3095 minutes: { 3096 seconds: 60, 3097 milliseconds: 60 * 1000 3098 }, 3099 seconds: { 3100 milliseconds: 1000 3101 } 3102 }, 3103 casualMatrix = _extends({ 3104 years: { 3105 quarters: 4, 3106 months: 12, 3107 weeks: 52, 3108 days: 365, 3109 hours: 365 * 24, 3110 minutes: 365 * 24 * 60, 3111 seconds: 365 * 24 * 60 * 60, 3112 milliseconds: 365 * 24 * 60 * 60 * 1000 3113 }, 3114 quarters: { 3115 months: 3, 3116 weeks: 13, 3117 days: 91, 3118 hours: 91 * 24, 3119 minutes: 91 * 24 * 60, 3120 seconds: 91 * 24 * 60 * 60, 3121 milliseconds: 91 * 24 * 60 * 60 * 1000 3122 }, 3123 months: { 3124 weeks: 4, 3125 days: 30, 3126 hours: 30 * 24, 3127 minutes: 30 * 24 * 60, 3128 seconds: 30 * 24 * 60 * 60, 3129 milliseconds: 30 * 24 * 60 * 60 * 1000 3130 } 3131 }, lowOrderMatrix), 3132 daysInYearAccurate = 146097.0 / 400, 3133 daysInMonthAccurate = 146097.0 / 4800, 3134 accurateMatrix = _extends({ 3135 years: { 3136 quarters: 4, 3137 months: 12, 3138 weeks: daysInYearAccurate / 7, 3139 days: daysInYearAccurate, 3140 hours: daysInYearAccurate * 24, 3141 minutes: daysInYearAccurate * 24 * 60, 3142 seconds: daysInYearAccurate * 24 * 60 * 60, 3143 milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000 3144 }, 3145 quarters: { 3146 months: 3, 3147 weeks: daysInYearAccurate / 28, 3148 days: daysInYearAccurate / 4, 3149 hours: daysInYearAccurate * 24 / 4, 3150 minutes: daysInYearAccurate * 24 * 60 / 4, 3151 seconds: daysInYearAccurate * 24 * 60 * 60 / 4, 3152 milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000 / 4 3153 }, 3154 months: { 3155 weeks: daysInMonthAccurate / 7, 3156 days: daysInMonthAccurate, 3157 hours: daysInMonthAccurate * 24, 3158 minutes: daysInMonthAccurate * 24 * 60, 3159 seconds: daysInMonthAccurate * 24 * 60 * 60, 3160 milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1000 3161 } 3162 }, lowOrderMatrix); // units ordered by size 3163 3164 var orderedUnits$1 = ["years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds"]; 3165 var reverseUnits = orderedUnits$1.slice(0).reverse(); // clone really means "create another instance just like this one, but with these changes" 3166 3167 function clone$1(dur, alts, clear) { 3168 if (clear === void 0) { 3169 clear = false;
vendor: 5,461 bytes, lines 3170-3309
3170 } 3171 3172 // deep merge for vals 3173 var conf = { 3174 values: clear ? alts.values : _extends({}, dur.values, alts.values || {}), 3175 loc: dur.loc.clone(alts.loc), 3176 conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy 3177 }; 3178 return new Duration(conf); 3179 } 3180 3181 function antiTrunc(n) { 3182 return n < 0 ? Math.floor(n) : Math.ceil(n); 3183 } // NB: mutates parameters 3184 3185 3186 function convert(matrix, fromMap, fromUnit, toMap, toUnit) { 3187 var conv = matrix[toUnit][fromUnit], 3188 raw = fromMap[fromUnit] / conv, 3189 sameSign = Math.sign(raw) === Math.sign(toMap[toUnit]), 3190 // ok, so this is wild, but see the matrix in the tests 3191 added = !sameSign && toMap[toUnit] !== 0 && Math.abs(raw) <= 1 ? antiTrunc(raw) : Math.trunc(raw); 3192 toMap[toUnit] += added; 3193 fromMap[fromUnit] -= added * conv; 3194 } // NB: mutates parameters 3195 3196 3197 function normalizeValues(matrix, vals) { 3198 reverseUnits.reduce(function (previous, current) { 3199 if (!isUndefined(vals[current])) { 3200 if (previous) { 3201 convert(matrix, vals, previous, vals, current); 3202 } 3203 3204 return current; 3205 } else { 3206 return previous; 3207 } 3208 }, null); 3209 } 3210 /** 3211 * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". Conceptually, it's just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime#plus} to add a Duration object to a DateTime, producing another DateTime. 3212 * 3213 * Here is a brief overview of commonly used methods and getters in Duration: 3214 * 3215 * * **Creation** To create a Duration, use {@link Duration#fromMillis}, {@link Duration#fromObject}, or {@link Duration#fromISO}. 3216 * * **Unit values** See the {@link Duration#years}, {@link Duration.months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, {@link Duration#seconds}, {@link Duration#milliseconds} accessors. 3217 * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors. 3218 * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, {@link Duration#shiftTo}, and {@link Duration#negate}. 3219 * * **Output** To convert the Duration into other representations, see {@link Duration#as}, {@link Duration#toISO}, {@link Duration#toFormat}, and {@link Duration#toJSON} 3220 * 3221 * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation. 3222 */ 3223 3224 3225 var Duration = /*#__PURE__*/function () { 3226 /** 3227 * @private 3228 */ 3229 function Duration(config) { 3230 var accurate = config.conversionAccuracy === "longterm" || false; 3231 /** 3232 * @access private 3233 */ 3234 3235 this.values = config.values; 3236 /** 3237 * @access private 3238 */ 3239 3240 this.loc = config.loc || Locale.create(); 3241 /** 3242 * @access private 3243 */ 3244 3245 this.conversionAccuracy = accurate ? "longterm" : "casual"; 3246 /** 3247 * @access private 3248 */ 3249 3250 this.invalid = config.invalid || null; 3251 /** 3252 * @access private 3253 */ 3254 3255 this.matrix = accurate ? accurateMatrix : casualMatrix; 3256 /** 3257 * @access private 3258 */ 3259 3260 this.isLuxonDuration = true; 3261 } 3262 /** 3263 * Create Duration from a number of milliseconds. 3264 * @param {number} count of milliseconds 3265 * @param {Object} opts - options for parsing 3266 * @param {string} [opts.locale='en-US'] - the locale to use 3267 * @param {string} opts.numberingSystem - the numbering system to use 3268 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 3269 * @return {Duration} 3270 */ 3271 3272 3273 Duration.fromMillis = function fromMillis(count, opts) { 3274 return Duration.fromObject({ 3275 milliseconds: count 3276 }, opts); 3277 } 3278 /** 3279 * Create a Duration from a JavaScript object with keys like 'years' and 'hours'. 3280 * If this object is empty then a zero milliseconds duration is returned. 3281 * @param {Object} obj - the object to create the DateTime from 3282 * @param {number} obj.years 3283 * @param {number} obj.quarters 3284 * @param {number} obj.months 3285 * @param {number} obj.weeks 3286 * @param {number} obj.days 3287 * @param {number} obj.hours 3288 * @param {number} obj.minutes 3289 * @param {number} obj.seconds 3290 * @param {number} obj.milliseconds 3291 * @param {Object} [opts=[]] - options for creating this Duration 3292 * @param {string} [opts.locale='en-US'] - the locale to use 3293 * @param {string} opts.numberingSystem - the numbering system to use 3294 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 3295 * @return {Duration} 3296 */ 3297 ; 3298 3299 Duration.fromObject = function fromObject(obj, opts) { 3300 if (opts === void 0) { 3301 opts = {}; 3302 } 3303 3304 if (obj == null || typeof obj !== "object") { 3305 throw new InvalidArgumentError("Duration.fromObject: argument expected to be an object, got " + (obj === null ? "null" : typeof obj)); 3306 } 3307 3308 return new Duration({ 3309 values: normalizeObject(obj, Duration.normalizeUnit),
vendor: 3,767 bytes, lines 3310-3396
3310 loc: Locale.fromObject(opts), 3311 conversionAccuracy: opts.conversionAccuracy 3312 }); 3313 } 3314 /** 3315 * Create a Duration from DurationLike. 3316 * 3317 * @param {Object | number | Duration} durationLike 3318 * One of: 3319 * - object with keys like 'years' and 'hours'. 3320 * - number representing milliseconds 3321 * - Duration instance 3322 * @return {Duration} 3323 */ 3324 ; 3325 3326 Duration.fromDurationLike = function fromDurationLike(durationLike) { 3327 if (isNumber(durationLike)) { 3328 return Duration.fromMillis(durationLike); 3329 } else if (Duration.isDuration(durationLike)) { 3330 return durationLike; 3331 } else if (typeof durationLike === "object") { 3332 return Duration.fromObject(durationLike); 3333 } else { 3334 throw new InvalidArgumentError("Unknown duration argument " + durationLike + " of type " + typeof durationLike); 3335 } 3336 } 3337 /** 3338 * Create a Duration from an ISO 8601 duration string. 3339 * @param {string} text - text to parse 3340 * @param {Object} opts - options for parsing 3341 * @param {string} [opts.locale='en-US'] - the locale to use 3342 * @param {string} opts.numberingSystem - the numbering system to use 3343 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 3344 * @see https://en.wikipedia.org/wiki/ISO_8601#Durations 3345 * @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 } 3346 * @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 } 3347 * @example Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 } 3348 * @return {Duration} 3349 */ 3350 ; 3351 3352 Duration.fromISO = function fromISO(text, opts) { 3353 var _parseISODuration = parseISODuration(text), 3354 parsed = _parseISODuration[0]; 3355 3356 if (parsed) { 3357 return Duration.fromObject(parsed, opts); 3358 } else { 3359 return Duration.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601"); 3360 } 3361 } 3362 /** 3363 * Create a Duration from an ISO 8601 time string. 3364 * @param {string} text - text to parse 3365 * @param {Object} opts - options for parsing 3366 * @param {string} [opts.locale='en-US'] - the locale to use 3367 * @param {string} opts.numberingSystem - the numbering system to use 3368 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 3369 * @see https://en.wikipedia.org/wiki/ISO_8601#Times 3370 * @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 } 3371 * @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } 3372 * @example Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } 3373 * @example Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } 3374 * @example Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } 3375 * @return {Duration} 3376 */ 3377 ; 3378 3379 Duration.fromISOTime = function fromISOTime(text, opts) { 3380 var _parseISOTimeOnly = parseISOTimeOnly(text), 3381 parsed = _parseISOTimeOnly[0]; 3382 3383 if (parsed) { 3384 return Duration.fromObject(parsed, opts); 3385 } else { 3386 return Duration.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601"); 3387 } 3388 } 3389 /** 3390 * Create an invalid Duration. 3391 * @param {string} reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent 3392 * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information 3393 * @return {Duration} 3394 */ 3395 ; 3396
vendor: 6,854 bytes, lines 3397-3581
3397 Duration.invalid = function invalid(reason, explanation) { 3398 if (explanation === void 0) { 3399 explanation = null; 3400 } 3401 3402 if (!reason) { 3403 throw new InvalidArgumentError("need to specify a reason the Duration is invalid"); 3404 } 3405 3406 var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation); 3407 3408 if (Settings.throwOnInvalid) { 3409 throw new InvalidDurationError(invalid); 3410 } else { 3411 return new Duration({ 3412 invalid: invalid 3413 }); 3414 } 3415 } 3416 /** 3417 * @private 3418 */ 3419 ; 3420 3421 Duration.normalizeUnit = function normalizeUnit(unit) { 3422 var normalized = { 3423 year: "years", 3424 years: "years", 3425 quarter: "quarters", 3426 quarters: "quarters", 3427 month: "months", 3428 months: "months", 3429 week: "weeks", 3430 weeks: "weeks", 3431 day: "days", 3432 days: "days", 3433 hour: "hours", 3434 hours: "hours", 3435 minute: "minutes", 3436 minutes: "minutes", 3437 second: "seconds", 3438 seconds: "seconds", 3439 millisecond: "milliseconds", 3440 milliseconds: "milliseconds" 3441 }[unit ? unit.toLowerCase() : unit]; 3442 if (!normalized) throw new InvalidUnitError(unit); 3443 return normalized; 3444 } 3445 /** 3446 * Check if an object is a Duration. Works across context boundaries 3447 * @param {object} o 3448 * @return {boolean} 3449 */ 3450 ; 3451 3452 Duration.isDuration = function isDuration(o) { 3453 return o && o.isLuxonDuration || false; 3454 } 3455 /** 3456 * Get the locale of a Duration, such 'en-GB' 3457 * @type {string} 3458 */ 3459 ; 3460 3461 var _proto = Duration.prototype; 3462 3463 /** 3464 * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens: 3465 * * `S` for milliseconds 3466 * * `s` for seconds 3467 * * `m` for minutes 3468 * * `h` for hours 3469 * * `d` for days 3470 * * `w` for weeks 3471 * * `M` for months 3472 * * `y` for years 3473 * Notes: 3474 * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits 3475 * * The duration will be converted to the set of units in the format string using {@link Duration#shiftTo} and the Durations's conversion accuracy setting. 3476 * @param {string} fmt - the format string 3477 * @param {Object} opts - options 3478 * @param {boolean} [opts.floor=true] - floor numerical values 3479 * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2" 3480 * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002" 3481 * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000" 3482 * @return {string} 3483 */ 3484 _proto.toFormat = function toFormat(fmt, opts) { 3485 if (opts === void 0) { 3486 opts = {}; 3487 } 3488 3489 // reverse-compat since 1.2; we always round down now, never up, and we do it by default 3490 var fmtOpts = _extends({}, opts, { 3491 floor: opts.round !== false && opts.floor !== false 3492 }); 3493 3494 return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID$2; 3495 } 3496 /** 3497 * Returns a string representation of a Duration with all units included. 3498 * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. 3499 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat 3500 * @param opts - On option object to override the formatting. Accepts the same keys as the options parameter of the native `Int.NumberFormat` constructor, as well as `listStyle`. 3501 * @example 3502 * ```js 3503 * var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 }) 3504 * dur.toHuman() //=> '1 day, 5 hours, 6 minutes' 3505 * dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes' 3506 * dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min' 3507 * ``` 3508 */ 3509 ; 3510 3511 _proto.toHuman = function toHuman(opts) { 3512 var _this = this; 3513 3514 if (opts === void 0) { 3515 opts = {}; 3516 } 3517 3518 var l = orderedUnits$1.map(function (unit) { 3519 var val = _this.values[unit]; 3520 3521 if (isUndefined(val)) { 3522 return null; 3523 } 3524 3525 return _this.loc.numberFormatter(_extends({ 3526 style: "unit", 3527 unitDisplay: "long" 3528 }, opts, { 3529 unit: unit.slice(0, -1) 3530 })).format(val); 3531 }).filter(function (n) { 3532 return n; 3533 }); 3534 return this.loc.listFormatter(_extends({ 3535 type: "conjunction", 3536 style: opts.listStyle || "narrow" 3537 }, opts)).format(l); 3538 } 3539 /** 3540 * Returns a JavaScript object with this Duration's values. 3541 * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 } 3542 * @return {Object} 3543 */ 3544 ; 3545 3546 _proto.toObject = function toObject() { 3547 if (!this.isValid) return {}; 3548 return _extends({}, this.values); 3549 } 3550 /** 3551 * Returns an ISO 8601-compliant string representation of this Duration. 3552 * @see https://en.wikipedia.org/wiki/ISO_8601#Durations 3553 * @example Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S' 3554 * @example Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S' 3555 * @example Duration.fromObject({ months: 5 }).toISO() //=> 'P5M' 3556 * @example Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M' 3557 * @example Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S' 3558 * @return {string} 3559 */ 3560 ; 3561 3562 _proto.toISO = function toISO() { 3563 // we could use the formatter, but this is an easier way to get the minimum string 3564 if (!this.isValid) return null; 3565 var s = "P"; 3566 if (this.years !== 0) s += this.years + "Y"; 3567 if (this.months !== 0 || this.quarters !== 0) s += this.months + this.quarters * 3 + "M"; 3568 if (this.weeks !== 0) s += this.weeks + "W"; 3569 if (this.days !== 0) s += this.days + "D"; 3570 if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0) s += "T"; 3571 if (this.hours !== 0) s += this.hours + "H"; 3572 if (this.minutes !== 0) s += this.minutes + "M"; 3573 if (this.seconds !== 0 || this.milliseconds !== 0) // this will handle "floating point madness" by removing extra decimal places 3574 // https://stackoverflow.com/questions/588004/is-floating-point-math-broken 3575 s += roundTo(this.seconds + this.milliseconds / 1000, 3) + "S"; 3576 if (s === "P") s += "T0S"; 3577 return s; 3578 } 3579 /** 3580 * Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day. 3581 * Note that this will return null if the duration is invali
3581d, negative, or equal to or greater than 24 hours. 3582 * @see https://en.wikipedia.org/wiki/ISO_8601#Times 3583 * @param {Object} opts - options 3584 * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0 3585 * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0 3586 * @param {boolean} [opts.includePrefix=false] - include the `T` prefix 3587 * @param {string} [opts.format='extended'] - choose between the basic and extended format 3588 * @example Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000' 3589 * @example Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00' 3590 * @example Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00' 3591 * @example Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000' 3592 * @example Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000' 3593 * @return {string} 3594 */ 3595 ; 3596 3597 _proto.toISOTime = function toISOTime(opts) { 3598 if (opts === void 0) { 3599 opts = {}; 3600 } 3601 3602 if (!this.isValid) return null; 3603 var millis = this.toMillis(); 3604 if (millis < 0 || millis >= 86400000) return null; 3605 opts = _extends({ 3606 suppressMilliseconds: false, 3607 suppressSeconds: false, 3608 includePrefix: false, 3609 format: "extended" 3610 }, opts); 3611 var value = this.shiftTo("hours", "minutes", "seconds", "milliseconds"); 3612 var fmt = opts.format === "basic" ? "hhmm" : "hh:mm"; 3613 3614 if (!opts.suppressSeconds || value.seconds !== 0 || value.milliseconds !== 0) { 3615 fmt += opts.format === "basic" ? "ss" : ":ss"; 3616 3617 if (!opts.suppressMilliseconds || value.milliseconds !== 0) { 3618 fmt += ".SSS"; 3619 } 3620 } 3621 3622 var str = value.toFormat(fmt); 3623 3624 if (opts.includePrefix) { 3625 str = "T" + str; 3626 } 3627 3628 return str; 3629 } 3630 /** 3631 * Returns an ISO 8601 representation of this Duration appropriate for use in JSON. 3632 * @return {string} 3633 */ 3634 ; 3635 3636 _proto.toJSON = function toJSON() { 3637 return this.toISO(); 3638 } 3639 /** 3640 * Returns an ISO 8601 representation of this Duration appropriate for use in debugging. 3641 * @return {string} 3642 */ 3643 ; 3644 3645 _proto.toString = function toString() { 3646 return this.toISO(); 3647 } 3648 /** 3649 * Returns an milliseconds value of this Duration. 3650 * @return {number} 3651 */ 3652 ; 3653 3654 _proto.toMillis = function toMillis() { 3655 return this.as("milliseconds"); 3656 } 3657 /** 3658 * Returns an milliseconds value of this Duration. Alias of {@link toMillis} 3659 * @return {number} 3660 */ 3661 ; 3662 3663 _proto.valueOf = function valueOf() { 3664 return this.toMillis(); 3665 } 3666 /** 3667 * Make this Duration longer by the specified amount. Return a newly-constructed Duration. 3668 * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() 3669 * @return {Duration} 3670 */ 3671 ; 3672 3673 _proto.plus = function plus(duration) { 3674 if (!this.isValid) return this; 3675 var dur = Duration.fromDurationLike(duration), 3676 result = {}; 3677 3678 for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits$1), _step; !(_step = _iterator()).done;) { 3679 var k = _step.value; 3680 3681 if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) { 3682 result[k] = dur.get(k) + this.get(k); 3683 } 3684 } 3685 3686 return clone$1(this, { 3687 values: result 3688 }, true); 3689 } 3690 /** 3691 * Make this Duration shorter by the specified amount. Return a newly-constructed Duration. 3692 * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() 3693 * @return {Duration} 3694 */ 3695 ; 3696 3697 _proto.minus = function minus(duration) { 3698 if (!this.isValid) return this; 3699 var dur = Duration.fromDurationLike(duration); 3700 return this.plus(dur.negate()); 3701 } 3702 /** 3703 * Scale this Duration by the specified amount. Return a newly-constructed Duration. 3704 * @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Mu
vendor: 6,742 bytes, lines 3704-3915
3704st return a number. 3705 * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 } 3706 * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 } 3707 * @return {Duration} 3708 */ 3709 ; 3710 3711 _proto.mapUnits = function mapUnits(fn) { 3712 if (!this.isValid) return this; 3713 var result = {}; 3714 3715 for (var _i = 0, _Object$keys = Object.keys(this.values); _i < _Object$keys.length; _i++) { 3716 var k = _Object$keys[_i]; 3717 result[k] = asNumber(fn(this.values[k], k)); 3718 } 3719 3720 return clone$1(this, { 3721 values: result 3722 }, true); 3723 } 3724 /** 3725 * Get the value of unit. 3726 * @param {string} unit - a unit such as 'minute' or 'day' 3727 * @example Duration.fromObject({years: 2, days: 3}).get('years') //=> 2 3728 * @example Duration.fromObject({years: 2, days: 3}).get('months') //=> 0 3729 * @example Duration.fromObject({years: 2, days: 3}).get('days') //=> 3 3730 * @return {number} 3731 */ 3732 ; 3733 3734 _proto.get = function get(unit) { 3735 return this[Duration.normalizeUnit(unit)]; 3736 } 3737 /** 3738 * "Set" the values of specified units. Return a newly-constructed Duration. 3739 * @param {Object} values - a mapping of units to numbers 3740 * @example dur.set({ years: 2017 }) 3741 * @example dur.set({ hours: 8, minutes: 30 }) 3742 * @return {Duration} 3743 */ 3744 ; 3745 3746 _proto.set = function set(values) { 3747 if (!this.isValid) return this; 3748 3749 var mixed = _extends({}, this.values, normalizeObject(values, Duration.normalizeUnit)); 3750 3751 return clone$1(this, { 3752 values: mixed 3753 }); 3754 } 3755 /** 3756 * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration. 3757 * @example dur.reconfigure({ locale: 'en-GB' }) 3758 * @return {Duration} 3759 */ 3760 ; 3761 3762 _proto.reconfigure = function reconfigure(_temp) { 3763 var _ref = _temp === void 0 ? {} : _temp, 3764 locale = _ref.locale, 3765 numberingSystem = _ref.numberingSystem, 3766 conversionAccuracy = _ref.conversionAccuracy; 3767 3768 var loc = this.loc.clone({ 3769 locale: locale, 3770 numberingSystem: numberingSystem 3771 }), 3772 opts = { 3773 loc: loc 3774 }; 3775 3776 if (conversionAccuracy) { 3777 opts.conversionAccuracy = conversionAccuracy; 3778 } 3779 3780 return clone$1(this, opts); 3781 } 3782 /** 3783 * Return the length of the duration in the specified unit. 3784 * @param {string} unit - a unit such as 'minutes' or 'days' 3785 * @example Duration.fromObject({years: 1}).as('days') //=> 365 3786 * @example Duration.fromObject({years: 1}).as('months') //=> 12 3787 * @example Duration.fromObject({hours: 60}).as('days') //=> 2.5 3788 * @return {number} 3789 */ 3790 ; 3791 3792 _proto.as = function as(unit) { 3793 return this.isValid ? this.shiftTo(unit).get(unit) : NaN; 3794 } 3795 /** 3796 * Reduce this Duration to its canonical representation in its current units. 3797 * @example Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 } 3798 * @example Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 } 3799 * @return {Duration} 3800 */ 3801 ; 3802 3803 _proto.normalize = function normalize() { 3804 if (!this.isValid) return this; 3805 var vals = this.toObject(); 3806 normalizeValues(this.matrix, vals); 3807 return clone$1(this, { 3808 values: vals 3809 }, true); 3810 } 3811 /** 3812 * Convert this Duration into its representation in a different set of units. 3813 * @example Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 } 3814 * @return {Duration} 3815 */ 3816 ; 3817 3818 _proto.shiftTo = function shiftTo() { 3819 for (var _len = arguments.length, units = new Array(_len), _key = 0; _key < _len; _key++) { 3820 units[_key] = arguments[_key]; 3821 } 3822 3823 if (!this.isValid) return this; 3824 3825 if (units.length === 0) { 3826 return this; 3827 } 3828 3829 units = units.map(function (u) { 3830 return Duration.normalizeUnit(u); 3831 }); 3832 var built = {}, 3833 accumulated = {}, 3834 vals = this.toObject(); 3835 var lastUnit; 3836 3837 for (var _iterator2 = _createForOfIteratorHelperLoose(orderedUnits$1), _step2; !(_step2 = _iterator2()).done;) { 3838 var k = _step2.value; 3839 3840 if (units.indexOf(k) >= 0) { 3841 lastUnit = k; 3842 var own = 0; // anything we haven't boiled down yet should get boiled to this unit 3843 3844 for (var ak in accumulated) { 3845 own += this.matrix[ak][k] * accumulated[ak]; 3846 accumulated[ak] = 0; 3847 } // plus anything that's already in this unit 3848 3849 3850 if (isNumber(vals[k])) { 3851 own += vals[k]; 3852 } 3853 3854 var i = Math.trunc(own); 3855 built[k] = i; 3856 accumulated[k] = (own * 1000 - i * 1000) / 1000; // plus anything further down the chain that should be rolled up in to this 3857 3858 for (var down in vals) { 3859 if (orderedUnits$1.indexOf(down) > orderedUnits$1.indexOf(k)) { 3860 convert(this.matrix, vals, down, built, k); 3861 } 3862 } // otherwise, keep it in the wings to boil it later 3863 3864 } else if (isNumber(vals[k])) { 3865 accumulated[k] = vals[k]; 3866 } 3867 } // anything leftover becomes the decimal for the last unit 3868 // lastUnit must be defined since units is not empty 3869 3870 3871 for (var key in accumulated) { 3872 if (accumulated[key] !== 0) { 3873 built[lastUnit] += key === lastUnit ? accumulated[key] : accumulated[key] / this.matrix[lastUnit][key]; 3874 } 3875 } 3876 3877 return clone$1(this, { 3878 values: built 3879 }, true).normalize(); 3880 } 3881 /** 3882 * Return the negative of this Duration. 3883 * @example Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 } 3884 * @return {Duration} 3885 */ 3886 ; 3887 3888 _proto.negate = function negate() { 3889 if (!this.isValid) return this; 3890 var negated = {}; 3891 3892 for (var _i2 = 0, _Object$keys2 = Object.keys(this.values); _i2 < _Object$keys2.length; _i2++) { 3893 var k = _Object$keys2[_i2]; 3894 negated[k] = this.values[k] === 0 ? 0 : -this.values[k]; 3895 } 3896 3897 return clone$1(this, { 3898 values: negated 3899 }, true); 3900 } 3901 /** 3902 * Get the years. 3903 * @type {number} 3904 */ 3905 ; 3906 3907 /** 3908 * Equality check 3909 * Two Durations are equal iff they have the same units and the same values for each unit. 3910 * @param {Duration} other 3911 * @return {boolean} 3912 */ 3913 _proto.equals = function equals(other) { 3914 if (!this.isValid || !other.isValid) { 3915 return false;
vendor: 11,849 bytes, lines 3916-4309
3916 } 3917 3918 if (!this.loc.equals(other.loc)) { 3919 return false; 3920 } 3921 3922 function eq(v1, v2) { 3923 // Consider 0 and undefined as equal 3924 if (v1 === undefined || v1 === 0) return v2 === undefined || v2 === 0; 3925 return v1 === v2; 3926 } 3927 3928 for (var _iterator3 = _createForOfIteratorHelperLoose(orderedUnits$1), _step3; !(_step3 = _iterator3()).done;) { 3929 var u = _step3.value; 3930 3931 if (!eq(this.values[u], other.values[u])) { 3932 return false; 3933 } 3934 } 3935 3936 return true; 3937 }; 3938 3939 _createClass(Duration, [{ 3940 key: "locale", 3941 get: function get() { 3942 return this.isValid ? this.loc.locale : null; 3943 } 3944 /** 3945 * Get the numbering system of a Duration, such 'beng'. The numbering system is used when formatting the Duration 3946 * 3947 * @type {string} 3948 */ 3949 3950 }, { 3951 key: "numberingSystem", 3952 get: function get() { 3953 return this.isValid ? this.loc.numberingSystem : null; 3954 } 3955 }, { 3956 key: "years", 3957 get: function get() { 3958 return this.isValid ? this.values.years || 0 : NaN; 3959 } 3960 /** 3961 * Get the quarters. 3962 * @type {number} 3963 */ 3964 3965 }, { 3966 key: "quarters", 3967 get: function get() { 3968 return this.isValid ? this.values.quarters || 0 : NaN; 3969 } 3970 /** 3971 * Get the months. 3972 * @type {number} 3973 */ 3974 3975 }, { 3976 key: "months", 3977 get: function get() { 3978 return this.isValid ? this.values.months || 0 : NaN; 3979 } 3980 /** 3981 * Get the weeks 3982 * @type {number} 3983 */ 3984 3985 }, { 3986 key: "weeks", 3987 get: function get() { 3988 return this.isValid ? this.values.weeks || 0 : NaN; 3989 } 3990 /** 3991 * Get the days. 3992 * @type {number} 3993 */ 3994 3995 }, { 3996 key: "days", 3997 get: function get() { 3998 return this.isValid ? this.values.days || 0 : NaN; 3999 } 4000 /** 4001 * Get the hours. 4002 * @type {number} 4003 */ 4004 4005 }, { 4006 key: "hours", 4007 get: function get() { 4008 return this.isValid ? this.values.hours || 0 : NaN; 4009 } 4010 /** 4011 * Get the minutes. 4012 * @type {number} 4013 */ 4014 4015 }, { 4016 key: "minutes", 4017 get: function get() { 4018 return this.isValid ? this.values.minutes || 0 : NaN; 4019 } 4020 /** 4021 * Get the seconds. 4022 * @return {number} 4023 */ 4024 4025 }, { 4026 key: "seconds", 4027 get: function get() { 4028 return this.isValid ? this.values.seconds || 0 : NaN; 4029 } 4030 /** 4031 * Get the milliseconds. 4032 * @return {number} 4033 */ 4034 4035 }, { 4036 key: "milliseconds", 4037 get: function get() { 4038 return this.isValid ? this.values.milliseconds || 0 : NaN; 4039 } 4040 /** 4041 * Returns whether the Duration is invalid. Invalid durations are returned by diff operations 4042 * on invalid DateTimes or Intervals. 4043 * @return {boolean} 4044 */ 4045 4046 }, { 4047 key: "isValid", 4048 get: function get() { 4049 return this.invalid === null; 4050 } 4051 /** 4052 * Returns an error code if this Duration became invalid, or null if the Duration is valid 4053 * @return {string} 4054 */ 4055 4056 }, { 4057 key: "invalidReason", 4058 get: function get() { 4059 return this.invalid ? this.invalid.reason : null; 4060 } 4061 /** 4062 * Returns an explanation of why this Duration became invalid, or null if the Duration is valid 4063 * @type {string} 4064 */ 4065 4066 }, { 4067 key: "invalidExplanation", 4068 get: function get() { 4069 return this.invalid ? this.invalid.explanation : null; 4070 } 4071 }]); 4072 4073 return Duration; 4074 }(); 4075 4076 var INVALID$1 = "Invalid Interval"; // checks if the start is equal to or before the end 4077 4078 function validateStartEnd(start, end) { 4079 if (!start || !start.isValid) { 4080 return Interval.invalid("missing or invalid start"); 4081 } else if (!end || !end.isValid) { 4082 return Interval.invalid("missing or invalid end"); 4083 } else if (end < start) { 4084 return Interval.invalid("end before start", "The end of an interval must be after its start, but you had start=" + start.toISO() + " and end=" + end.toISO()); 4085 } else { 4086 return null; 4087 } 4088 } 4089 /** 4090 * An Interval object represents a half-open interval of time, where each endpoint is a {@link DateTime}. Conceptually, it's a container for those two endpoints, accompanied by methods for creating, parsing, interrogating, comparing, transforming, and formatting them. 4091 * 4092 * Here is a brief overview of the most commonly used methods and getters in Interval: 4093 * 4094 * * **Creation** To create an Interval, use {@link Interval#fromDateTimes}, {@link Interval#after}, {@link Interval#before}, or {@link Interval#fromISO}. 4095 * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end. 4096 * * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}. 4097 * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval#merge}, {@link Interval#xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}. 4098 * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs} 4099 * * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toISO}, {@link Interval#toISODate}, {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}. 4100 */ 4101 4102 4103 var Interval = /*#__PURE__*/function () { 4104 /** 4105 * @private 4106 */ 4107 function Interval(config) { 4108 /** 4109 * @access private 4110 */ 4111 this.s = config.start; 4112 /** 4113 * @access private 4114 */ 4115 4116 this.e = config.end; 4117 /** 4118 * @access private 4119 */ 4120 4121 this.invalid = config.invalid || null; 4122 /** 4123 * @access private 4124 */ 4125 4126 this.isLuxonInterval = true; 4127 } 4128 /** 4129 * Create an invalid Interval. 4130 * @param {string} reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent 4131 * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information 4132 * @return {Interval} 4133 */ 4134 4135 4136 Interval.invalid = function invalid(reason, explanation) { 4137 if (explanation === void 0) { 4138 explanation = null; 4139 } 4140 4141 if (!reason) { 4142 throw new InvalidArgumentError("need to specify a reason the Interval is invalid"); 4143 } 4144 4145 var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation); 4146 4147 if (Settings.throwOnInvalid) { 4148 throw new InvalidIntervalError(invalid); 4149 } else { 4150 return new Interval({ 4151 invalid: invalid 4152 }); 4153 } 4154 } 4155 /** 4156 * Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end. 4157 * @param {DateTime|Date|Object} start 4158 * @param {DateTime|Date|Object} end 4159 * @return {Interval} 4160 */ 4161 ; 4162 4163 Interval.fromDateTimes = function fromDateTimes(start, end) { 4164 var builtStart = friendlyDateTime(start), 4165 builtEnd = friendlyDateTime(end); 4166 var validateError = validateStartEnd(builtStart, builtEnd); 4167 4168 if (validateError == null) { 4169 return new Interval({ 4170 start: builtStart, 4171 end: builtEnd 4172 }); 4173 } else { 4174 return validateError; 4175 } 4176 } 4177 /** 4178 * Create an Interval from a start DateTime and a Duration to extend to. 4179 * @param {DateTime|Date|Object} start 4180 * @param {Duration|Object|number} duration - the length of the Interval. 4181 * @return {Interval} 4182 */ 4183 ; 4184 4185 Interval.after = function after(start, duration) { 4186 var dur = Duration.fromDurationLike(duration), 4187 dt = friendlyDateTime(start); 4188 return Interval.fromDateTimes(dt, dt.plus(dur)); 4189 } 4190 /** 4191 * Create an Interval from an end DateTime and a Duration to extend backwards to. 4192 * @param {DateTime|Date|Object} end 4193 * @param {Duration|Object|number} duration - the length of the Interval. 4194 * @return {Interval} 4195 */ 4196 ; 4197 4198 Interval.before = function before(end, duration) { 4199 var dur = Duration.fromDurationLike(duration), 4200 dt = friendlyDateTime(end); 4201 return Interval.fromDateTimes(dt.minus(dur), dt); 4202 } 4203 /** 4204 * Create an Interval from an ISO 8601 string. 4205 * Accepts `<start>/<end>`, `<start>/<duration>`, and `<duration>/<end>` formats. 4206 * @param {string} text - the ISO string to parse 4207 * @param {Object} [opts] - options to pass {@link DateTime#fromISO} and optionally {@link Duration#fromISO} 4208 * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals 4209 * @return {Interval} 4210 */ 4211 ; 4212 4213 Interval.fromISO = function fromISO(text, opts) { 4214 var _split = (text || "").split("/", 2), 4215 s = _split[0], 4216 e = _split[1]; 4217 4218 if (s && e) { 4219 var start, startIsValid; 4220 4221 try { 4222 start = DateTime.fromISO(s, opts); 4223 startIsValid = start.isValid; 4224 } catch (e) { 4225 startIsValid = false; 4226 } 4227 4228 var end, endIsValid; 4229 4230 try { 4231 end = DateTime.fromISO(e, opts); 4232 endIsValid = end.isValid; 4233 } catch (e) { 4234 endIsValid = false; 4235 } 4236 4237 if (startIsValid && endIsValid) { 4238 return Interval.fromDateTimes(start, end); 4239 } 4240 4241 if (startIsValid) { 4242 var dur = Duration.fromISO(e, opts); 4243 4244 if (dur.isValid) { 4245 return Interval.after(start, dur); 4246 } 4247 } else if (endIsValid) { 4248 var _dur = Duration.fromISO(s, opts); 4249 4250 if (_dur.isValid) { 4251 return Interval.before(end, _dur); 4252 } 4253 } 4254 } 4255 4256 return Interval.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601"); 4257 } 4258 /** 4259 * Check if an object is an Interval. Works across context boundaries 4260 * @param {object} o 4261 * @return {boolean} 4262 */ 4263 ; 4264 4265 Interval.isInterval = function isInterval(o) { 4266 return o && o.isLuxonInterval || false; 4267 } 4268 /** 4269 * Returns the start of the Interval 4270 * @type {DateTime} 4271 */ 4272 ; 4273 4274 var _proto = Interval.prototype; 4275 4276 /** 4277 * Returns the length of the Interval in the specified unit. 4278 * @param {string} unit - the unit (such as 'hours' or 'days') to return the length in. 4279 * @return {number} 4280 */ 4281 _proto.length = function length(unit) { 4282 if (unit === void 0) { 4283 unit = "milliseconds"; 4284 } 4285 4286 return this.isValid ? this.toDuration.apply(this, [unit]).get(unit) : NaN; 4287 } 4288 /** 4289 * Returns the count of minutes, hours, days, months, or years included in the Interval, even in part. 4290 * Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day' 4291 * asks 'what dates are included in this interval?', not 'how many days long is this interval?' 4292 * @param {string} [unit='milliseconds'] - the unit of time to count. 4293 * @return {number} 4294 */ 4295 ; 4296 4297 _proto.count = function count(unit) { 4298 if (unit === void 0) { 4299 unit = "milliseconds"; 4300 } 4301 4302 if (!this.isValid) return NaN; 4303 var start = this.start.startOf(unit), 4304 end = this.end.startOf(unit); 4305 return Math.floor(end.diff(start, unit).get(unit)) + 1; 4306 } 4307 /** 4308 * Returns whether this Interval's start and end are both in the same unit of time 4309 * @param {string}
vendor: 11,202 bytes, lines 4309-4688
4309 unit - the unit of time to check sameness on 4310 * @return {boolean} 4311 */ 4312 ; 4313 4314 _proto.hasSame = function hasSame(unit) { 4315 return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false; 4316 } 4317 /** 4318 * Return whether this Interval has the same start and end DateTimes. 4319 * @return {boolean} 4320 */ 4321 ; 4322 4323 _proto.isEmpty = function isEmpty() { 4324 return this.s.valueOf() === this.e.valueOf(); 4325 } 4326 /** 4327 * Return whether this Interval's start is after the specified DateTime. 4328 * @param {DateTime} dateTime 4329 * @return {boolean} 4330 */ 4331 ; 4332 4333 _proto.isAfter = function isAfter(dateTime) { 4334 if (!this.isValid) return false; 4335 return this.s > dateTime; 4336 } 4337 /** 4338 * Return whether this Interval's end is before the specified DateTime. 4339 * @param {DateTime} dateTime 4340 * @return {boolean} 4341 */ 4342 ; 4343 4344 _proto.isBefore = function isBefore(dateTime) { 4345 if (!this.isValid) return false; 4346 return this.e <= dateTime; 4347 } 4348 /** 4349 * Return whether this Interval contains the specified DateTime. 4350 * @param {DateTime} dateTime 4351 * @return {boolean} 4352 */ 4353 ; 4354 4355 _proto.contains = function contains(dateTime) { 4356 if (!this.isValid) return false; 4357 return this.s <= dateTime && this.e > dateTime; 4358 } 4359 /** 4360 * "Sets" the start and/or end dates. Returns a newly-constructed Interval. 4361 * @param {Object} values - the values to set 4362 * @param {DateTime} values.start - the starting DateTime 4363 * @param {DateTime} values.end - the ending DateTime 4364 * @return {Interval} 4365 */ 4366 ; 4367 4368 _proto.set = function set(_temp) { 4369 var _ref = _temp === void 0 ? {} : _temp, 4370 start = _ref.start, 4371 end = _ref.end; 4372 4373 if (!this.isValid) return this; 4374 return Interval.fromDateTimes(start || this.s, end || this.e); 4375 } 4376 /** 4377 * Split this Interval at each of the specified DateTimes 4378 * @param {...DateTime} dateTimes - the unit of time to count. 4379 * @return {Array} 4380 */ 4381 ; 4382 4383 _proto.splitAt = function splitAt() { 4384 var _this = this; 4385 4386 if (!this.isValid) return []; 4387 4388 for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) { 4389 dateTimes[_key] = arguments[_key]; 4390 } 4391 4392 var sorted = dateTimes.map(friendlyDateTime).filter(function (d) { 4393 return _this.contains(d); 4394 }).sort(), 4395 results = []; 4396 var s = this.s, 4397 i = 0; 4398 4399 while (s < this.e) { 4400 var added = sorted[i] || this.e, 4401 next = +added > +this.e ? this.e : added; 4402 results.push(Interval.fromDateTimes(s, next)); 4403 s = next; 4404 i += 1; 4405 } 4406 4407 return results; 4408 } 4409 /** 4410 * Split this Interval into smaller Intervals, each of the specified length. 4411 * Left over time is grouped into a smaller interval 4412 * @param {Duration|Object|number} duration - The length of each resulting interval. 4413 * @return {Array} 4414 */ 4415 ; 4416 4417 _proto.splitBy = function splitBy(duration) { 4418 var dur = Duration.fromDurationLike(duration); 4419 4420 if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) { 4421 return []; 4422 } 4423 4424 var s = this.s, 4425 idx = 1, 4426 next; 4427 var results = []; 4428 4429 while (s < this.e) { 4430 var added = this.start.plus(dur.mapUnits(function (x) { 4431 return x * idx; 4432 })); 4433 next = +added > +this.e ? this.e : added; 4434 results.push(Interval.fromDateTimes(s, next)); 4435 s = next; 4436 idx += 1; 4437 } 4438 4439 return results; 4440 } 4441 /** 4442 * Split this Interval into the specified number of smaller intervals. 4443 * @param {number} numberOfParts - The number of Intervals to divide the Interval into. 4444 * @return {Array} 4445 */ 4446 ; 4447 4448 _proto.divideEqually = function divideEqually(numberOfParts) { 4449 if (!this.isValid) return []; 4450 return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts); 4451 } 4452 /** 4453 * Return whether this Interval overlaps with the specified Interval 4454 * @param {Interval} other 4455 * @return {boolean} 4456 */ 4457 ; 4458 4459 _proto.overlaps = function overlaps(other) { 4460 return this.e > other.s && this.s < other.e; 4461 } 4462 /** 4463 * Return whether this Interval's end is adjacent to the specified Interval's start. 4464 * @param {Interval} other 4465 * @return {boolean} 4466 */ 4467 ; 4468 4469 _proto.abutsStart = function abutsStart(other) { 4470 if (!this.isValid) return false; 4471 return +this.e === +other.s; 4472 } 4473 /** 4474 * Return whether this Interval's start is adjacent to the specified Interval's end. 4475 * @param {Interval} other 4476 * @return {boolean} 4477 */ 4478 ; 4479 4480 _proto.abutsEnd = function abutsEnd(other) { 4481 if (!this.isValid) return false; 4482 return +other.e === +this.s; 4483 } 4484 /** 4485 * Return whether this Interval engulfs the start and end of the specified Interval. 4486 * @param {Interval} other 4487 * @return {boolean} 4488 */ 4489 ; 4490 4491 _proto.engulfs = function engulfs(other) { 4492 if (!this.isValid) return false; 4493 return this.s <= other.s && this.e >= other.e; 4494 } 4495 /** 4496 * Return whether this Interval has the same start and end as the specified Interval. 4497 * @param {Interval} other 4498 * @return {boolean} 4499 */ 4500 ; 4501 4502 _proto.equals = function equals(other) { 4503 if (!this.isValid || !other.isValid) { 4504 return false; 4505 } 4506 4507 return this.s.equals(other.s) && this.e.equals(other.e); 4508 } 4509 /** 4510 * Return an Interval representing the intersection of this Interval and the specified Interval. 4511 * Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals. 4512 * Returns null if the intersection is empty, meaning, the intervals don't intersect. 4513 * @param {Interval} other 4514 * @return {Interval} 4515 */ 4516 ; 4517 4518 _proto.intersection = function intersection(other) { 4519 if (!this.isValid) return this; 4520 var s = this.s > other.s ? this.s : other.s, 4521 e = this.e < other.e ? this.e : other.e; 4522 4523 if (s >= e) { 4524 return null; 4525 } else { 4526 return Interval.fromDateTimes(s, e); 4527 } 4528 } 4529 /** 4530 * Return an Interval representing the union of this Interval and the specified Interval. 4531 * Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals. 4532 * @param {Interval} other 4533 * @return {Interval} 4534 */ 4535 ; 4536 4537 _proto.union = function union(other) { 4538 if (!this.isValid) return this; 4539 var s = this.s < other.s ? this.s : other.s, 4540 e = this.e > other.e ? this.e : other.e; 4541 return Interval.fromDateTimes(s, e); 4542 } 4543 /** 4544 * Merge an array of Intervals into a equivalent minimal set of Intervals. 4545 * Combines overlapping and adjacent Intervals. 4546 * @param {Array} intervals 4547 * @return {Array} 4548 */ 4549 ; 4550 4551 Interval.merge = function merge(intervals) { 4552 var _intervals$sort$reduc = intervals.sort(function (a, b) { 4553 return a.s - b.s; 4554 }).reduce(function (_ref2, item) { 4555 var sofar = _ref2[0], 4556 current = _ref2[1]; 4557 4558 if (!current) { 4559 return [sofar, item]; 4560 } else if (current.overlaps(item) || current.abutsStart(item)) { 4561 return [sofar, current.union(item)]; 4562 } else { 4563 return [sofar.concat([current]), item]; 4564 } 4565 }, [[], null]), 4566 found = _intervals$sort$reduc[0], 4567 final = _intervals$sort$reduc[1]; 4568 4569 if (final) { 4570 found.push(final); 4571 } 4572 4573 return found; 4574 } 4575 /** 4576 * Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals. 4577 * @param {Array} intervals 4578 * @return {Array} 4579 */ 4580 ; 4581 4582 Interval.xor = function xor(intervals) { 4583 var _Array$prototype; 4584 4585 var start = null, 4586 currentCount = 0; 4587 4588 var results = [], 4589 ends = intervals.map(function (i) { 4590 return [{ 4591 time: i.s, 4592 type: "s" 4593 }, { 4594 time: i.e, 4595 type: "e" 4596 }]; 4597 }), 4598 flattened = (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, ends), 4599 arr = flattened.sort(function (a, b) { 4600 return a.time - b.time; 4601 }); 4602 4603 for (var _iterator = _createForOfIteratorHelperLoose(arr), _step; !(_step = _iterator()).done;) { 4604 var i = _step.value; 4605 currentCount += i.type === "s" ? 1 : -1; 4606 4607 if (currentCount === 1) { 4608 start = i.time; 4609 } else { 4610 if (start && +start !== +i.time) { 4611 results.push(Interval.fromDateTimes(start, i.time)); 4612 } 4613 4614 start = null; 4615 } 4616 } 4617 4618 return Interval.merge(results); 4619 } 4620 /** 4621 * Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals. 4622 * @param {...Interval} intervals 4623 * @return {Array} 4624 */ 4625 ; 4626 4627 _proto.difference = function difference() { 4628 var _this2 = this; 4629 4630 for (var _len2 = arguments.length, intervals = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 4631 intervals[_key2] = arguments[_key2]; 4632 } 4633 4634 return Interval.xor([this].concat(intervals)).map(function (i) { 4635 return _this2.intersection(i); 4636 }).filter(function (i) { 4637 return i && !i.isEmpty(); 4638 }); 4639 } 4640 /** 4641 * Returns a string representation of this Interval appropriate for debugging. 4642 * @return {string} 4643 */ 4644 ; 4645 4646 _proto.toString = function toString() { 4647 if (!this.isValid) return INVALID$1; 4648 return "[" + this.s.toISO() + " \u2013 " + this.e.toISO() + ")"; 4649 } 4650 /** 4651 * Returns an ISO 8601-compliant string representation of this Interval. 4652 * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals 4653 * @param {Object} opts - The same options as {@link DateTime#toISO} 4654 * @return {string} 4655 */ 4656 ; 4657 4658 _proto.toISO = function toISO(opts) { 4659 if (!this.isValid) return INVALID$1; 4660 return this.s.toISO(opts) + "/" + this.e.toISO(opts); 4661 } 4662 /** 4663 * Returns an ISO 8601-compliant string representation of date of this Interval. 4664 * The time components are ignored. 4665 * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals 4666 * @return {string} 4667 */ 4668 ; 4669 4670 _proto.toISODate = function toISODate() { 4671 if (!this.isValid) return INVALID$1; 4672 return this.s.toISODate() + "/" + this.e.toISODate(); 4673 } 4674 /** 4675 * Returns an ISO 8601-compliant string representation of time of this Interval. 4676 * The date components are ignored. 4677 * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals 4678 * @param {Object} opts - The same options as {@link DateTime#toISO} 4679 * @return {string} 4680 */ 4681 ; 4682 4683 _proto.toISOTime = function toISOTime(opts) { 4684 if (!this.isValid) return INVALID$1; 4685 return this.s.toISOTime(opts) + "/" + this.e.toISOTime(opts); 4686 } 4687 /** 4688 * Returns a string representation of this Interval formatted according to the specified format str
4688ing. 4689 * @param {string} dateFormat - the format string. This string formats the start and end time. See {@link DateTime#toFormat} for details. 4690 * @param {Object} opts - options 4691 * @param {string} [opts.separator = ' â '] - a separator to place between the start and end representations 4692 * @return {string} 4693 */ 4694 ; 4695 4696 _proto.toFormat = function toFormat(dateFormat, _temp2) { 4697 var _ref3 = _temp2 === void 0 ? {} : _temp2, 4698 _ref3$separator = _ref3.separator, 4699 separator = _ref3$separator === void 0 ? " â " : _ref3$separator; 4700 4701 if (!this.isValid) return INVALID$1; 4702 return "" + this.s.toFormat(dateFormat) + separator + this.e.toFormat(dateFormat); 4703 } 4704 /** 4705 * Return a Duration representing the time spanned by this interval. 4706 * @param {string|string[]} [unit=['milliseconds']] - the unit or units (such as 'hours' or 'days') to include in the duration. 4707 * @param {Object} opts - options that affect the creation of the Duration 4708 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 4709 * @example Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 } 4710 * @example Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 } 4711 * @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 } 4712 * @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 } 4713 * @example Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 } 4714 * @return {Duration} 4715 */ 4716 ; 4717 4718 _proto.toDuration = function toDuration(unit, opts) { 4719 if (!this.isValid) { 4720 return Duration.invalid(this.invalidReason); 4721 } 4722 4723 return this.e.diff(this.s, unit, opts); 4724 } 4725 /** 4726 * Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes 4727 * @param {function} mapFn 4728 * @return {Interval} 4729 * @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC()) 4730 * @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 })) 4731 */ 4732 ; 4733 4734 _proto.mapEndpoints = function mapEndpoints(mapFn) { 4735 return Interval.fromDateTimes(mapFn(this.s), mapFn(this.e)); 4736 }; 4737 4738 _createClass(Interval, [{ 4739 key: "start", 4740 get: function get() { 4741 return this.isValid ? this.s : null; 4742 } 4743 /** 4744 * Returns the end of the Interval 4745 * @type {DateTime} 4746 */ 4747 4748 }, { 4749 key: "end", 4750 get: function get() { 4751 return this.isValid ? this.e : null; 4752 } 4753 /** 4754 * Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'. 4755 * @type {boolean} 4756 */ 4757 4758 }, { 4759 key: "isValid", 4760 get: function get() { 4761 return this.invalidReason === null; 4762 } 4763 /** 4764 * Returns an error code if this Interval is invalid, or null if the Interval is valid 4765 * @type {string} 4766 */ 4767 4768 }, { 4769 key: "invalidReason", 4770 get: function get() { 4771 return this.invalid ? this.invalid.reason : null; 4772 } 4773 /** 4774 * Returns an explanation of why this Interval became invalid, or null if the Interval is valid 4775 * @type {string} 4776 */ 4777 4778 }, { 4779 key: "invalidExplanation", 4780 get: function get() { 4781 return this.invalid ? this.invalid.explanation : null; 4782 } 4783 }]); 4784 4785 return Interval; 4786 }(); 4787 4788 /** 4789 * The Info class contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a t
vendor: 9,247 bytes, lines 4789-5003
4789ime zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment. 4790 */ 4791 4792 var Info = /*#__PURE__*/function () { 4793 function Info() {} 4794 4795 /** 4796 * Return whether the specified zone contains a DST. 4797 * @param {string|Zone} [zone='local'] - Zone to check. Defaults to the environment's local zone. 4798 * @return {boolean} 4799 */ 4800 Info.hasDST = function hasDST(zone) { 4801 if (zone === void 0) { 4802 zone = Settings.defaultZone; 4803 } 4804 4805 var proto = DateTime.now().setZone(zone).set({ 4806 month: 12 4807 }); 4808 return !zone.isUniversal && proto.offset !== proto.set({ 4809 month: 6 4810 }).offset; 4811 } 4812 /** 4813 * Return whether the specified zone is a valid IANA specifier. 4814 * @param {string} zone - Zone to check 4815 * @return {boolean} 4816 */ 4817 ; 4818 4819 Info.isValidIANAZone = function isValidIANAZone(zone) { 4820 return IANAZone.isValidZone(zone); 4821 } 4822 /** 4823 * Converts the input into a {@link Zone} instance. 4824 * 4825 * * If `input` is already a Zone instance, it is returned unchanged. 4826 * * If `input` is a string containing a valid time zone name, a Zone instance 4827 * with that name is returned. 4828 * * If `input` is a string that doesn't refer to a known time zone, a Zone 4829 * instance with {@link Zone#isValid} == false is returned. 4830 * * If `input is a number, a Zone instance with the specified fixed offset 4831 * in minutes is returned. 4832 * * If `input` is `null` or `undefined`, the default zone is returned. 4833 * @param {string|Zone|number} [input] - the value to be converted 4834 * @return {Zone} 4835 */ 4836 ; 4837 4838 Info.normalizeZone = function normalizeZone$1(input) { 4839 return normalizeZone(input, Settings.defaultZone); 4840 } 4841 /** 4842 * Return an array of standalone month names. 4843 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat 4844 * @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long" 4845 * @param {Object} opts - options 4846 * @param {string} [opts.locale] - the locale code 4847 * @param {string} [opts.numberingSystem=null] - the numbering system 4848 * @param {string} [opts.locObj=null] - an existing locale object to use 4849 * @param {string} [opts.outputCalendar='gregory'] - the calendar 4850 * @example Info.months()[0] //=> 'January' 4851 * @example Info.months('short')[0] //=> 'Jan' 4852 * @example Info.months('numeric')[0] //=> '1' 4853 * @example Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.' 4854 * @example Info.months('numeric', { locale: 'ar' })[0] //=> 'Ù¡' 4855 * @example Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'RabiÊ» I' 4856 * @return {Array} 4857 */ 4858 ; 4859 4860 Info.months = function months(length, _temp) { 4861 if (length === void 0) { 4862 length = "long"; 4863 } 4864 4865 var _ref = _temp === void 0 ? {} : _temp, 4866 _ref$locale = _ref.locale, 4867 locale = _ref$locale === void 0 ? null : _ref$locale, 4868 _ref$numberingSystem = _ref.numberingSystem, 4869 numberingSystem = _ref$numberingSystem === void 0 ? null : _ref$numberingSystem, 4870 _ref$locObj = _ref.locObj, 4871 locObj = _ref$locObj === void 0 ? null : _ref$locObj, 4872 _ref$outputCalendar = _ref.outputCalendar, 4873 outputCalendar = _ref$outputCalendar === void 0 ? "gregory" : _ref$outputCalendar; 4874 4875 return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length); 4876 } 4877 /** 4878 * Return an array of format month names. 4879 * Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that 4880 * changes the string. 4881 * See {@link Info#months} 4882 * @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long" 4883 * @param {Object} opts - options 4884 * @param {string} [opts.locale] - the locale code 4885 * @param {string} [opts.numberingSystem=null] - the numbering system 4886 * @param {string} [opts.locObj=null] - an existing locale object to use 4887 * @param {string} [opts.outputCalendar='gregory'] - the calendar 4888 * @return {Array} 4889 */ 4890 ; 4891 4892 Info.monthsFormat = function monthsFormat(length, _temp2) { 4893 if (length === void 0) { 4894 length = "long"; 4895 } 4896 4897 var _ref2 = _temp2 === void 0 ? {} : _temp2, 4898 _ref2$locale = _ref2.locale, 4899 locale = _ref2$locale === void 0 ? null : _ref2$locale, 4900 _ref2$numberingSystem = _ref2.numberingSystem, 4901 numberingSystem = _ref2$numberingSystem === void 0 ? null : _ref2$numberingSystem, 4902 _ref2$locObj = _ref2.locObj, 4903 locObj = _ref2$locObj === void 0 ? null : _ref2$locObj, 4904 _ref2$outputCalendar = _ref2.outputCalendar, 4905 outputCalendar = _ref2$outputCalendar === void 0 ? "gregory" : _ref2$outputCalendar; 4906 4907 return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true); 4908 } 4909 /** 4910 * Return an array of standalone week names. 4911 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat 4912 * @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long". 4913 * @param {Object} opts - options 4914 * @param {string} [opts.locale] - the locale code 4915 * @param {string} [opts.numberingSystem=null] - the numbering system 4916 * @param {string} [opts.locObj=null] - an existing locale object to use 4917 * @example Info.weekdays()[0] //=> 'Monday' 4918 * @example Info.weekdays('short')[0] //=> 'Mon' 4919 * @example Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.' 4920 * @example Info.weekdays('short', { locale: 'ar' })[0] //=> 'Ø§ÙØ§Ø«ÙÙÙ' 4921 * @return {Array} 4922 */ 4923 ; 4924 4925 Info.weekdays = function weekdays(length, _temp3) { 4926 if (length === void 0) { 4927 length = "long"; 4928 } 4929 4930 var _ref3 = _temp3 === void 0 ? {} : _temp3, 4931 _ref3$locale = _ref3.locale, 4932 locale = _ref3$locale === void 0 ? null : _ref3$locale, 4933 _ref3$numberingSystem = _ref3.numberingSystem, 4934 numberingSystem = _ref3$numberingSystem === void 0 ? null : _ref3$numberingSystem, 4935 _ref3$locObj = _ref3.locObj, 4936 locObj = _ref3$locObj === void 0 ? null : _ref3$locObj; 4937 4938 return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length); 4939 } 4940 /** 4941 * Return an array of format week names. 4942 * Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that 4943 * changes the string. 4944 * See {@link Info#weekdays} 4945 * @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long". 4946 * @param {Object} opts - options 4947 * @param {string} [opts.locale=null] - the locale code 4948 * @param {string} [opts.numberingSystem=null] - the numbering system 4949 * @param {string} [opts.locObj=null] - an existing locale object to use 4950 * @return {Array} 4951 */ 4952 ; 4953 4954 Info.weekdaysFormat = function weekdaysFormat(length, _temp4) { 4955 if (length === void 0) { 4956 length = "long"; 4957 } 4958 4959 var _ref4 = _temp4 === void 0 ? {} : _temp4, 4960 _ref4$locale = _ref4.locale, 4961 locale = _ref4$locale === void 0 ? null : _ref4$locale, 4962 _ref4$numberingSystem = _ref4.numberingSystem, 4963 numberingSystem = _ref4$numberingSystem === void 0 ? null : _ref4$numberingSystem, 4964 _ref4$locObj = _ref4.locObj, 4965 locObj = _ref4$locObj === void 0 ? null : _ref4$locObj; 4966 4967 return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true); 4968 } 4969 /** 4970 * Return an array of meridiems. 4971 * @param {Object} opts - options 4972 * @param {string} [opts.locale] - the locale code 4973 * @example Info.meridiems() //=> [ 'AM', 'PM' ] 4974 * @example Info.meridiems({ locale: 'my' }) //=> [ 'áá¶áááº', 'ááá±' ] 4975 * @return {Array} 4976 */ 4977 ; 4978 4979 Info.meridiems = function meridiems(_temp5) { 4980 var _ref5 = _temp5 === void 0 ? {} : _temp5, 4981 _ref5$locale = _ref5.locale, 4982 locale = _ref5$locale === void 0 ? null : _ref5$locale; 4983 4984 return Locale.create(locale).meridiems(); 4985 } 4986 /** 4987 * Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian. 4988 * @param {string} [length='short'] - the length of the era representation, such as "short" or "long". 4989 * @param {Object} opts - options 4990 * @param {string} [opts.locale] - the locale code 4991 * @example Info.eras() //=> [ 'BC', 'AD' ] 4992 * @example Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ] 4993 * @example Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ] 4994 * @return {Array} 4995 */ 4996 ; 4997 4998 Info.eras = function eras(length, _temp6) { 4999 if (length === void 0) { 5000 length = "short"; 5001 } 5002 5003 var _ref6 = _temp6 === void 0 ? {}
vendor: 7,715 bytes, lines 5003-5280
5003 : _temp6, 5004 _ref6$locale = _ref6.locale, 5005 locale = _ref6$locale === void 0 ? null : _ref6$locale; 5006 5007 return Locale.create(locale, null, "gregory").eras(length); 5008 } 5009 /** 5010 * Return the set of available features in this environment. 5011 * Some features of Luxon are not available in all environments. For example, on older browsers, relative time formatting support is not available. Use this function to figure out if that's the case. 5012 * Keys: 5013 * * `relative`: whether this environment supports relative time formatting 5014 * @example Info.features() //=> { relative: false } 5015 * @return {Object} 5016 */ 5017 ; 5018 5019 Info.features = function features() { 5020 return { 5021 relative: hasRelative() 5022 }; 5023 }; 5024 5025 return Info; 5026 }(); 5027 5028 function dayDiff(earlier, later) { 5029 var utcDayStart = function utcDayStart(dt) { 5030 return dt.toUTC(0, { 5031 keepLocalTime: true 5032 }).startOf("day").valueOf(); 5033 }, 5034 ms = utcDayStart(later) - utcDayStart(earlier); 5035 5036 return Math.floor(Duration.fromMillis(ms).as("days")); 5037 } 5038 5039 function highOrderDiffs(cursor, later, units) { 5040 var differs = [["years", function (a, b) { 5041 return b.year - a.year; 5042 }], ["quarters", function (a, b) { 5043 return b.quarter - a.quarter; 5044 }], ["months", function (a, b) { 5045 return b.month - a.month + (b.year - a.year) * 12; 5046 }], ["weeks", function (a, b) { 5047 var days = dayDiff(a, b); 5048 return (days - days % 7) / 7; 5049 }], ["days", dayDiff]]; 5050 var results = {}; 5051 var lowestOrder, highWater; 5052 5053 for (var _i = 0, _differs = differs; _i < _differs.length; _i++) { 5054 var _differs$_i = _differs[_i], 5055 unit = _differs$_i[0], 5056 differ = _differs$_i[1]; 5057 5058 if (units.indexOf(unit) >= 0) { 5059 var _cursor$plus; 5060 5061 lowestOrder = unit; 5062 var delta = differ(cursor, later); 5063 highWater = cursor.plus((_cursor$plus = {}, _cursor$plus[unit] = delta, _cursor$plus)); 5064 5065 if (highWater > later) { 5066 var _cursor$plus2; 5067 5068 cursor = cursor.plus((_cursor$plus2 = {}, _cursor$plus2[unit] = delta - 1, _cursor$plus2)); 5069 delta -= 1; 5070 } else { 5071 cursor = highWater; 5072 } 5073 5074 results[unit] = delta; 5075 } 5076 } 5077 5078 return [cursor, results, highWater, lowestOrder]; 5079 } 5080 5081 function _diff (earlier, later, units, opts) { 5082 var _highOrderDiffs = highOrderDiffs(earlier, later, units), 5083 cursor = _highOrderDiffs[0], 5084 results = _highOrderDiffs[1], 5085 highWater = _highOrderDiffs[2], 5086 lowestOrder = _highOrderDiffs[3]; 5087 5088 var remainingMillis = later - cursor; 5089 var lowerOrderUnits = units.filter(function (u) { 5090 return ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0; 5091 }); 5092 5093 if (lowerOrderUnits.length === 0) { 5094 if (highWater < later) { 5095 var _cursor$plus3; 5096 5097 highWater = cursor.plus((_cursor$plus3 = {}, _cursor$plus3[lowestOrder] = 1, _cursor$plus3)); 5098 } 5099 5100 if (highWater !== cursor) { 5101 results[lowestOrder] = (results[lowestOrder] || 0) + remainingMillis / (highWater - cursor); 5102 } 5103 } 5104 5105 var duration = Duration.fromObject(results, opts); 5106 5107 if (lowerOrderUnits.length > 0) { 5108 var _Duration$fromMillis; 5109 5110 return (_Duration$fromMillis = Duration.fromMillis(remainingMillis, opts)).shiftTo.apply(_Duration$fromMillis, lowerOrderUnits).plus(duration); 5111 } else { 5112 return duration; 5113 } 5114 } 5115 5116 var numberingSystems = { 5117 arab: "[\u0660-\u0669]", 5118 arabext: "[\u06F0-\u06F9]", 5119 bali: "[\u1B50-\u1B59]", 5120 beng: "[\u09E6-\u09EF]", 5121 deva: "[\u0966-\u096F]", 5122 fullwide: "[\uFF10-\uFF19]", 5123 gujr: "[\u0AE6-\u0AEF]", 5124 hanidec: "[ã|ä¸|äº|ä¸|å|äº|å |ä¸|å «|ä¹]", 5125 khmr: "[\u17E0-\u17E9]", 5126 knda: "[\u0CE6-\u0CEF]", 5127 laoo: "[\u0ED0-\u0ED9]", 5128 limb: "[\u1946-\u194F]", 5129 mlym: "[\u0D66-\u0D6F]", 5130 mong: "[\u1810-\u1819]", 5131 mymr: "[\u1040-\u1049]", 5132 orya: "[\u0B66-\u0B6F]", 5133 tamldec: "[\u0BE6-\u0BEF]", 5134 telu: "[\u0C66-\u0C6F]", 5135 thai: "[\u0E50-\u0E59]", 5136 tibt: "[\u0F20-\u0F29]", 5137 latn: "\\d" 5138 }; 5139 var numberingSystemsUTF16 = { 5140 arab: [1632, 1641], 5141 arabext: [1776, 1785], 5142 bali: [6992, 7001], 5143 beng: [2534, 2543], 5144 deva: [2406, 2415], 5145 fullwide: [65296, 65303], 5146 gujr: [2790, 2799], 5147 khmr: [6112, 6121], 5148 knda: [3302, 3311], 5149 laoo: [3792, 3801], 5150 limb: [6470, 6479], 5151 mlym: [3430, 3439], 5152 mong: [6160, 6169], 5153 mymr: [4160, 4169], 5154 orya: [2918, 2927], 5155 tamldec: [3046, 3055], 5156 telu: [3174, 3183], 5157 thai: [3664, 3673], 5158 tibt: [3872, 3881] 5159 }; 5160 var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split(""); 5161 function parseDigits(str) { 5162 var value = parseInt(str, 10); 5163 5164 if (isNaN(value)) { 5165 value = ""; 5166 5167 for (var i = 0; i < str.length; i++) { 5168 var code = str.charCodeAt(i); 5169 5170 if (str[i].search(numberingSystems.hanidec) !== -1) { 5171 value += hanidecChars.indexOf(str[i]); 5172 } else { 5173 for (var key in numberingSystemsUTF16) { 5174 var _numberingSystemsUTF = numberingSystemsUTF16[key], 5175 min = _numberingSystemsUTF[0], 5176 max = _numberingSystemsUTF[1]; 5177 5178 if (code >= min && code <= max) { 5179 value += code - min; 5180 } 5181 } 5182 } 5183 } 5184 5185 return parseInt(value, 10); 5186 } else { 5187 return value; 5188 } 5189 } 5190 function digitRegex(_ref, append) { 5191 var numberingSystem = _ref.numberingSystem; 5192 5193 if (append === void 0) { 5194 append = ""; 5195 } 5196 5197 return new RegExp("" + numberingSystems[numberingSystem || "latn"] + append); 5198 } 5199 5200 var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support"; 5201 5202 function intUnit(regex, post) { 5203 if (post === void 0) { 5204 post = function post(i) { 5205 return i; 5206 }; 5207 } 5208 5209 return { 5210 regex: regex, 5211 deser: function deser(_ref) { 5212 var s = _ref[0]; 5213 return post(parseDigits(s)); 5214 } 5215 }; 5216 } 5217 5218 var NBSP = String.fromCharCode(160); 5219 var spaceOrNBSP = "[ " + NBSP + "]"; 5220 var spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g"); 5221 5222 function fixListRegex(s) { 5223 // make dots optional and also make them literal 5224 // make space and non breakable space characters interchangeable 5225 return s.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP); 5226 } 5227 5228 function stripInsensitivities(s) { 5229 return s.replace(/\./g, "") // ignore dots that were made optional 5230 .replace(spaceOrNBSPRegExp, " ") // interchange space and nbsp 5231 .toLowerCase(); 5232 } 5233 5234 function oneOf(strings, startIndex) { 5235 if (strings === null) { 5236 return null; 5237 } else { 5238 return { 5239 regex: RegExp(strings.map(fixListRegex).join("|")), 5240 deser: function deser(_ref2) { 5241 var s = _ref2[0]; 5242 return strings.findIndex(function (i) { 5243 return stripInsensitivities(s) === stripInsensitivities(i); 5244 }) + startIndex; 5245 } 5246 }; 5247 } 5248 } 5249 5250 function offset(regex, groups) { 5251 return { 5252 regex: regex, 5253 deser: function deser(_ref3) { 5254 var h = _ref3[1], 5255 m = _ref3[2]; 5256 return signedOffset(h, m); 5257 }, 5258 groups: groups 5259 }; 5260 } 5261 5262 function simple(regex) { 5263 return { 5264 regex: regex, 5265 deser: function deser(_ref4) { 5266 var s = _ref4[0]; 5267 return s; 5268 } 5269 }; 5270 } 5271 5272 function escapeToken(value) { 5273 return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); 5274 } 5275 5276 function unitForToken(token, loc) { 5277 var one = digitRegex(loc), 5278 two = digitRegex(loc, "{2}"), 5279 three = digitRegex(loc, "{3}"), 5280 four = digitRegex(loc, "{4}"),
vendor: 7,572 bytes, lines 5281-5651
5281 six = digitRegex(loc, "{6}"), 5282 oneOrTwo = digitRegex(loc, "{1,2}"), 5283 oneToThree = digitRegex(loc, "{1,3}"), 5284 oneToSix = digitRegex(loc, "{1,6}"), 5285 oneToNine = digitRegex(loc, "{1,9}"), 5286 twoToFour = digitRegex(loc, "{2,4}"), 5287 fourToSix = digitRegex(loc, "{4,6}"), 5288 literal = function literal(t) { 5289 return { 5290 regex: RegExp(escapeToken(t.val)), 5291 deser: function deser(_ref5) { 5292 var s = _ref5[0]; 5293 return s; 5294 }, 5295 literal: true 5296 }; 5297 }, 5298 unitate = function unitate(t) { 5299 if (token.literal) { 5300 return literal(t); 5301 } 5302 5303 switch (t.val) { 5304 // era 5305 case "G": 5306 return oneOf(loc.eras("short", false), 0); 5307 5308 case "GG": 5309 return oneOf(loc.eras("long", false), 0); 5310 // years 5311 5312 case "y": 5313 return intUnit(oneToSix); 5314 5315 case "yy": 5316 return intUnit(twoToFour, untruncateYear); 5317 5318 case "yyyy": 5319 return intUnit(four); 5320 5321 case "yyyyy": 5322 return intUnit(fourToSix); 5323 5324 case "yyyyyy": 5325 return intUnit(six); 5326 // months 5327 5328 case "M": 5329 return intUnit(oneOrTwo); 5330 5331 case "MM": 5332 return intUnit(two); 5333 5334 case "MMM": 5335 return oneOf(loc.months("short", true, false), 1); 5336 5337 case "MMMM": 5338 return oneOf(loc.months("long", true, false), 1); 5339 5340 case "L": 5341 return intUnit(oneOrTwo); 5342 5343 case "LL": 5344 return intUnit(two); 5345 5346 case "LLL": 5347 return oneOf(loc.months("short", false, false), 1); 5348 5349 case "LLLL": 5350 return oneOf(loc.months("long", false, false), 1); 5351 // dates 5352 5353 case "d": 5354 return intUnit(oneOrTwo); 5355 5356 case "dd": 5357 return intUnit(two); 5358 // ordinals 5359 5360 case "o": 5361 return intUnit(oneToThree); 5362 5363 case "ooo": 5364 return intUnit(three); 5365 // time 5366 5367 case "HH": 5368 return intUnit(two); 5369 5370 case "H": 5371 return intUnit(oneOrTwo); 5372 5373 case "hh": 5374 return intUnit(two); 5375 5376 case "h": 5377 return intUnit(oneOrTwo); 5378 5379 case "mm": 5380 return intUnit(two); 5381 5382 case "m": 5383 return intUnit(oneOrTwo); 5384 5385 case "q": 5386 return intUnit(oneOrTwo); 5387 5388 case "qq": 5389 return intUnit(two); 5390 5391 case "s": 5392 return intUnit(oneOrTwo); 5393 5394 case "ss": 5395 return intUnit(two); 5396 5397 case "S": 5398 return intUnit(oneToThree); 5399 5400 case "SSS": 5401 return intUnit(three); 5402 5403 case "u": 5404 return simple(oneToNine); 5405 5406 case "uu": 5407 return simple(oneOrTwo); 5408 5409 case "uuu": 5410 return intUnit(one); 5411 // meridiem 5412 5413 case "a": 5414 return oneOf(loc.meridiems(), 0); 5415 // weekYear (k) 5416 5417 case "kkkk": 5418 return intUnit(four); 5419 5420 case "kk": 5421 return intUnit(twoToFour, untruncateYear); 5422 // weekNumber (W) 5423 5424 case "W": 5425 return intUnit(oneOrTwo); 5426 5427 case "WW": 5428 return intUnit(two); 5429 // weekdays 5430 5431 case "E": 5432 case "c": 5433 return intUnit(one); 5434 5435 case "EEE": 5436 return oneOf(loc.weekdays("short", false, false), 1); 5437 5438 case "EEEE": 5439 return oneOf(loc.weekdays("long", false, false), 1); 5440 5441 case "ccc": 5442 return oneOf(loc.weekdays("short", true, false), 1); 5443 5444 case "cccc": 5445 return oneOf(loc.weekdays("long", true, false), 1); 5446 // offset/zone 5447 5448 case "Z": 5449 case "ZZ": 5450 return offset(new RegExp("([+-]" + oneOrTwo.source + ")(?::(" + two.source + "))?"), 2); 5451 5452 case "ZZZ": 5453 return offset(new RegExp("([+-]" + oneOrTwo.source + ")(" + two.source + ")?"), 2); 5454 // we don't support ZZZZ (PST) or ZZZZZ (Pacific Standard Time) in parsing 5455 // because we don't have any way to figure out what they are 5456 5457 case "z": 5458 return simple(/[a-z_+-/]{1,256}?/i); 5459 5460 default: 5461 return literal(t); 5462 } 5463 }; 5464 5465 var unit = unitate(token) || { 5466 invalidReason: MISSING_FTP 5467 }; 5468 unit.token = token; 5469 return unit; 5470 } 5471 5472 var partTypeStyleToTokenVal = { 5473 year: { 5474 "2-digit": "yy", 5475 numeric: "yyyyy" 5476 }, 5477 month: { 5478 numeric: "M", 5479 "2-digit": "MM", 5480 short: "MMM", 5481 long: "MMMM" 5482 }, 5483 day: { 5484 numeric: "d", 5485 "2-digit": "dd" 5486 }, 5487 weekday: { 5488 short: "EEE", 5489 long: "EEEE" 5490 }, 5491 dayperiod: "a", 5492 dayPeriod: "a", 5493 hour: { 5494 numeric: "h", 5495 "2-digit": "hh" 5496 }, 5497 minute: { 5498 numeric: "m", 5499 "2-digit": "mm" 5500 }, 5501 second: { 5502 numeric: "s", 5503 "2-digit": "ss" 5504 } 5505 }; 5506 5507 function tokenForPart(part, locale, formatOpts) { 5508 var type = part.type, 5509 value = part.value; 5510 5511 if (type === "literal") { 5512 return { 5513 literal: true, 5514 val: value 5515 }; 5516 } 5517 5518 var style = formatOpts[type]; 5519 var val = partTypeStyleToTokenVal[type]; 5520 5521 if (typeof val === "object") { 5522 val = val[style]; 5523 } 5524 5525 if (val) { 5526 return { 5527 literal: false, 5528 val: val 5529 }; 5530 } 5531 5532 return undefined; 5533 } 5534 5535 function buildRegex(units) { 5536 var re = units.map(function (u) { 5537 return u.regex; 5538 }).reduce(function (f, r) { 5539 return f + "(" + r.source + ")"; 5540 }, ""); 5541 return ["^" + re + "$", units]; 5542 } 5543 5544 function match(input, regex, handlers) { 5545 var matches = input.match(regex); 5546 5547 if (matches) { 5548 var all = {}; 5549 var matchIndex = 1; 5550 5551 for (var i in handlers) { 5552 if (hasOwnProperty(handlers, i)) { 5553 var h = handlers[i], 5554 groups = h.groups ? h.groups + 1 : 1; 5555 5556 if (!h.literal && h.token) { 5557 all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups)); 5558 } 5559 5560 matchIndex += groups; 5561 } 5562 } 5563 5564 return [matches, all]; 5565 } else { 5566 return [matches, {}]; 5567 } 5568 } 5569 5570 function dateTimeFromMatches(matches) { 5571 var toField = function toField(token) { 5572 switch (token) { 5573 case "S": 5574 return "millisecond"; 5575 5576 case "s": 5577 return "second"; 5578 5579 case "m": 5580 return "minute"; 5581 5582 case "h": 5583 case "H": 5584 return "hour"; 5585 5586 case "d": 5587 return "day"; 5588 5589 case "o": 5590 return "ordinal"; 5591 5592 case "L": 5593 case "M": 5594 return "month"; 5595 5596 case "y": 5597 return "year"; 5598 5599 case "E": 5600 case "c": 5601 return "weekday"; 5602 5603 case "W": 5604 return "weekNumber"; 5605 5606 case "k": 5607 return "weekYear"; 5608 5609 case "q": 5610 return "quarter"; 5611 5612 default: 5613 return null; 5614 } 5615 }; 5616 5617 var zone = null; 5618 var specificOffset; 5619 5620 if (!isUndefined(matches.z)) { 5621 zone = IANAZone.create(matches.z); 5622 } 5623 5624 if (!isUndefined(matches.Z)) { 5625 if (!zone) { 5626 zone = new FixedOffsetZone(matches.Z); 5627 } 5628 5629 specificOffset = matches.Z; 5630 } 5631 5632 if (!isUndefined(matches.q)) { 5633 matches.M = (matches.q - 1) * 3 + 1; 5634 } 5635 5636 if (!isUndefined(matches.h)) { 5637 if (matches.h < 12 && matches.a === 1) { 5638 matches.h += 12; 5639 } else if (matches.h === 12 && matches.a === 0) { 5640 matches.h = 0; 5641 } 5642 } 5643 5644 if (matches.G === 0 && matches.y) { 5645 matches.y = -matches.y; 5646 } 5647 5648 if (!isUndefined(matches.u)) { 5649 matches.S = parseMillis(matches.u); 5650 } 5651
vendor: 1,617 bytes, lines 5652-5722
5652 var vals = Object.keys(matches).reduce(function (r, k) { 5653 var f = toField(k); 5654 5655 if (f) { 5656 r[f] = matches[k]; 5657 } 5658 5659 return r; 5660 }, {}); 5661 return [vals, zone, specificOffset]; 5662 } 5663 5664 var dummyDateTimeCache = null; 5665 5666 function getDummyDateTime() { 5667 if (!dummyDateTimeCache) { 5668 dummyDateTimeCache = DateTime.fromMillis(1555555555555); 5669 } 5670 5671 return dummyDateTimeCache; 5672 } 5673 5674 function maybeExpandMacroToken(token, locale) { 5675 if (token.literal) { 5676 return token; 5677 } 5678 5679 var formatOpts = Formatter.macroTokenToFormatOpts(token.val); 5680 5681 if (!formatOpts) { 5682 return token; 5683 } 5684 5685 var formatter = Formatter.create(locale, formatOpts); 5686 var parts = formatter.formatDateTimeParts(getDummyDateTime()); 5687 var tokens = parts.map(function (p) { 5688 return tokenForPart(p, locale, formatOpts); 5689 }); 5690 5691 if (tokens.includes(undefined)) { 5692 return token; 5693 } 5694 5695 return tokens; 5696 } 5697 5698 function expandMacroTokens(tokens, locale) { 5699 var _Array$prototype; 5700 5701 return (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, tokens.map(function (t) { 5702 return maybeExpandMacroToken(t, locale); 5703 })); 5704 } 5705 /** 5706 * @private 5707 */ 5708 5709 5710 function explainFromTokens(locale, input, format) { 5711 var tokens = expandMacroTokens(Formatter.parseFormat(format), locale), 5712 units = tokens.map(function (t) { 5713 return unitForToken(t, locale); 5714 }), 5715 disqualifyingUnit = units.find(function (t) { 5716 return t.invalidReason; 5717 }); 5718 5719 if (disqualifyingUnit) { 5720 return { 5721 input: input, 5722 tokens: tokens,
vendor: 12,930 bytes, lines 5723-6149
5723 invalidReason: disqualifyingUnit.invalidReason 5724 }; 5725 } else { 5726 var _buildRegex = buildRegex(units), 5727 regexString = _buildRegex[0], 5728 handlers = _buildRegex[1], 5729 regex = RegExp(regexString, "i"), 5730 _match = match(input, regex, handlers), 5731 rawMatches = _match[0], 5732 matches = _match[1], 5733 _ref6 = matches ? dateTimeFromMatches(matches) : [null, null, undefined], 5734 result = _ref6[0], 5735 zone = _ref6[1], 5736 specificOffset = _ref6[2]; 5737 5738 if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) { 5739 throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format"); 5740 } 5741 5742 return { 5743 input: input, 5744 tokens: tokens, 5745 regex: regex, 5746 rawMatches: rawMatches, 5747 matches: matches, 5748 result: result, 5749 zone: zone, 5750 specificOffset: specificOffset 5751 }; 5752 } 5753 } 5754 function parseFromTokens(locale, input, format) { 5755 var _explainFromTokens = explainFromTokens(locale, input, format), 5756 result = _explainFromTokens.result, 5757 zone = _explainFromTokens.zone, 5758 specificOffset = _explainFromTokens.specificOffset, 5759 invalidReason = _explainFromTokens.invalidReason; 5760 5761 return [result, zone, specificOffset, invalidReason]; 5762 } 5763 5764 var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], 5765 leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]; 5766 5767 function unitOutOfRange(unit, value) { 5768 return new Invalid("unit out of range", "you specified " + value + " (of type " + typeof value + ") as a " + unit + ", which is invalid"); 5769 } 5770 5771 function dayOfWeek(year, month, day) { 5772 var d = new Date(Date.UTC(year, month - 1, day)); 5773 5774 if (year < 100 && year >= 0) { 5775 d.setUTCFullYear(d.getUTCFullYear() - 1900); 5776 } 5777 5778 var js = d.getUTCDay(); 5779 return js === 0 ? 7 : js; 5780 } 5781 5782 function computeOrdinal(year, month, day) { 5783 return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1]; 5784 } 5785 5786 function uncomputeOrdinal(year, ordinal) { 5787 var table = isLeapYear(year) ? leapLadder : nonLeapLadder, 5788 month0 = table.findIndex(function (i) { 5789 return i < ordinal; 5790 }), 5791 day = ordinal - table[month0]; 5792 return { 5793 month: month0 + 1, 5794 day: day 5795 }; 5796 } 5797 /** 5798 * @private 5799 */ 5800 5801 5802 function gregorianToWeek(gregObj) { 5803 var year = gregObj.year, 5804 month = gregObj.month, 5805 day = gregObj.day, 5806 ordinal = computeOrdinal(year, month, day), 5807 weekday = dayOfWeek(year, month, day); 5808 var weekNumber = Math.floor((ordinal - weekday + 10) / 7), 5809 weekYear; 5810 5811 if (weekNumber < 1) { 5812 weekYear = year - 1; 5813 weekNumber = weeksInWeekYear(weekYear); 5814 } else if (weekNumber > weeksInWeekYear(year)) { 5815 weekYear = year + 1; 5816 weekNumber = 1; 5817 } else { 5818 weekYear = year; 5819 } 5820 5821 return _extends({ 5822 weekYear: weekYear, 5823 weekNumber: weekNumber, 5824 weekday: weekday 5825 }, timeObject(gregObj)); 5826 } 5827 function weekToGregorian(weekData) { 5828 var weekYear = weekData.weekYear, 5829 weekNumber = weekData.weekNumber, 5830 weekday = weekData.weekday, 5831 weekdayOfJan4 = dayOfWeek(weekYear, 1, 4), 5832 yearInDays = daysInYear(weekYear); 5833 var ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3, 5834 year; 5835 5836 if (ordinal < 1) { 5837 year = weekYear - 1; 5838 ordinal += daysInYear(year); 5839 } else if (ordinal > yearInDays) { 5840 year = weekYear + 1; 5841 ordinal -= daysInYear(weekYear); 5842 } else { 5843 year = weekYear; 5844 } 5845 5846 var _uncomputeOrdinal = uncomputeOrdinal(year, ordinal), 5847 month = _uncomputeOrdinal.month, 5848 day = _uncomputeOrdinal.day; 5849 5850 return _extends({ 5851 year: year, 5852 month: month, 5853 day: day 5854 }, timeObject(weekData)); 5855 } 5856 function gregorianToOrdinal(gregData) { 5857 var year = gregData.year, 5858 month = gregData.month, 5859 day = gregData.day; 5860 var ordinal = computeOrdinal(year, month, day); 5861 return _extends({ 5862 year: year, 5863 ordinal: ordinal 5864 }, timeObject(gregData)); 5865 } 5866 function ordinalToGregorian(ordinalData) { 5867 var year = ordinalData.year, 5868 ordinal = ordinalData.ordinal; 5869 5870 var _uncomputeOrdinal2 = uncomputeOrdinal(year, ordinal), 5871 month = _uncomputeOrdinal2.month, 5872 day = _uncomputeOrdinal2.day; 5873 5874 return _extends({ 5875 year: year, 5876 month: month, 5877 day: day 5878 }, timeObject(ordinalData)); 5879 } 5880 function hasInvalidWeekData(obj) { 5881 var validYear = isInteger(obj.weekYear), 5882 validWeek = integerBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)), 5883 validWeekday = integerBetween(obj.weekday, 1, 7); 5884 5885 if (!validYear) { 5886 return unitOutOfRange("weekYear", obj.weekYear); 5887 } else if (!validWeek) { 5888 return unitOutOfRange("week", obj.week); 5889 } else if (!validWeekday) { 5890 return unitOutOfRange("weekday", obj.weekday); 5891 } else return false; 5892 } 5893 function hasInvalidOrdinalData(obj) { 5894 var validYear = isInteger(obj.year), 5895 validOrdinal = integerBetween(obj.ordinal, 1, daysInYear(obj.year)); 5896 5897 if (!validYear) { 5898 return unitOutOfRange("year", obj.year); 5899 } else if (!validOrdinal) { 5900 return unitOutOfRange("ordinal", obj.ordinal); 5901 } else return false; 5902 } 5903 function hasInvalidGregorianData(obj) { 5904 var validYear = isInteger(obj.year), 5905 validMonth = integerBetween(obj.month, 1, 12), 5906 validDay = integerBetween(obj.day, 1, daysInMonth(obj.year, obj.month)); 5907 5908 if (!validYear) { 5909 return unitOutOfRange("year", obj.year); 5910 } else if (!validMonth) { 5911 return unitOutOfRange("month", obj.month); 5912 } else if (!validDay) { 5913 return unitOutOfRange("day", obj.day); 5914 } else return false; 5915 } 5916 function hasInvalidTimeData(obj) { 5917 var hour = obj.hour, 5918 minute = obj.minute, 5919 second = obj.second, 5920 millisecond = obj.millisecond; 5921 var validHour = integerBetween(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0, 5922 validMinute = integerBetween(minute, 0, 59), 5923 validSecond = integerBetween(second, 0, 59), 5924 validMillisecond = integerBetween(millisecond, 0, 999); 5925 5926 if (!validHour) { 5927 return unitOutOfRange("hour", hour); 5928 } else if (!validMinute) { 5929 return unitOutOfRange("minute", minute); 5930 } else if (!validSecond) { 5931 return unitOutOfRange("second", second); 5932 } else if (!validMillisecond) { 5933 return unitOutOfRange("millisecond", millisecond); 5934 } else return false; 5935 } 5936 5937 var INVALID = "Invalid DateTime"; 5938 var MAX_DATE = 8.64e15; 5939 5940 function unsupportedZone(zone) { 5941 return new Invalid("unsupported zone", "the zone \"" + zone.name + "\" is not supported"); 5942 } // we cache week data on the DT object and this intermediates the cache 5943 5944 5945 function possiblyCachedWeekData(dt) { 5946 if (dt.weekData === null) { 5947 dt.weekData = gregorianToWeek(dt.c); 5948 } 5949 5950 return dt.weekData; 5951 } // clone really means, "make a new object with these modifications". all "setters" really use this 5952 // to create a new object while only changing some of the properties 5953 5954 5955 function clone(inst, alts) { 5956 var current = { 5957 ts: inst.ts, 5958 zone: inst.zone, 5959 c: inst.c, 5960 o: inst.o, 5961 loc: inst.loc, 5962 invalid: inst.invalid 5963 }; 5964 return new DateTime(_extends({}, current, alts, { 5965 old: current 5966 })); 5967 } // find the right offset a given local time. The o input is our guess, which determines which 5968 // offset we'll pick in ambiguous cases (e.g. there are two 3 AMs b/c Fallback DST) 5969 5970 5971 function fixOffset(localTS, o, tz) { 5972 // Our UTC time is just a guess because our offset is just a guess 5973 var utcGuess = localTS - o * 60 * 1000; // Test whether the zone matches the offset for this ts 5974 5975 var o2 = tz.offset(utcGuess); // If so, offset didn't change and we're done 5976 5977 if (o === o2) { 5978 return [utcGuess, o]; 5979 } // If not, change the ts by the difference in the offset 5980 5981 5982 utcGuess -= (o2 - o) * 60 * 1000; // If that gives us the local time we want, we're done 5983 5984 var o3 = tz.offset(utcGuess); 5985 5986 if (o2 === o3) { 5987 return [utcGuess, o2]; 5988 } // If it's different, we're in a hole time. The offset has changed, but the we don't adjust the time 5989 5990 5991 return [localTS - Math.min(o2, o3) * 60 * 1000, Math.max(o2, o3)]; 5992 } // convert an epoch timestamp into a calendar object with the given offset 5993 5994 5995 function tsToObj(ts, offset) { 5996 ts += offset * 60 * 1000; 5997 var d = new Date(ts); 5998 return { 5999 year: d.getUTCFullYear(), 6000 month: d.getUTCMonth() + 1, 6001 day: d.getUTCDate(), 6002 hour: d.getUTCHours(), 6003 minute: d.getUTCMinutes(), 6004 second: d.getUTCSeconds(), 6005 millisecond: d.getUTCMilliseconds() 6006 }; 6007 } // convert a calendar object to a epoch timestamp 6008 6009 6010 function objToTS(obj, offset, zone) { 6011 return fixOffset(objToLocalTS(obj), offset, zone); 6012 } // create a new DT instance by adding a duration, adjusting for DSTs 6013 6014 6015 function adjustTime(inst, dur) { 6016 var oPre = inst.o, 6017 year = inst.c.year + Math.trunc(dur.years), 6018 month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3, 6019 c = _extends({}, inst.c, { 6020 year: year, 6021 month: month, 6022 day: Math.min(inst.c.day, daysInMonth(year, month)) + Math.trunc(dur.days) + Math.trunc(dur.weeks) * 7 6023 }), 6024 millisToAdd = Duration.fromObject({ 6025 years: dur.years - Math.trunc(dur.years), 6026 quarters: dur.quarters - Math.trunc(dur.quarters), 6027 months: dur.months - Math.trunc(dur.months), 6028 weeks: dur.weeks - Math.trunc(dur.weeks), 6029 days: dur.days - Math.trunc(dur.days), 6030 hours: dur.hours, 6031 minutes: dur.minutes, 6032 seconds: dur.seconds, 6033 milliseconds: dur.milliseconds 6034 }).as("milliseconds"), 6035 localTS = objToLocalTS(c); 6036 6037 var _fixOffset = fixOffset(localTS, oPre, inst.zone), 6038 ts = _fixOffset[0], 6039 o = _fixOffset[1]; 6040 6041 if (millisToAdd !== 0) { 6042 ts += millisToAdd; // that could have changed the offset by going over a DST, but we want to keep the ts the same 6043 6044 o = inst.zone.offset(ts); 6045 } 6046 6047 return { 6048 ts: ts, 6049 o: o 6050 }; 6051 } // helper useful in turning the results of parsing into real dates 6052 // by handling the zone options 6053 6054 6055 function parseDataToDateTime(parsed, parsedZone, opts, format, text, specificOffset) { 6056 var setZone = opts.setZone, 6057 zone = opts.zone; 6058 6059 if (parsed && Object.keys(parsed).length !== 0) { 6060 var interpretationZone = parsedZone || zone, 6061 inst = DateTime.fromObject(parsed, _extends({}, opts, { 6062 zone: interpretationZone, 6063 specificOffset: specificOffset 6064 })); 6065 return setZone ? inst : inst.setZone(zone); 6066 } else { 6067 return DateTime.invalid(new Invalid("unparsable", "the input \"" + text + "\" can't be parsed as " + format)); 6068 } 6069 } // if you want to output a technical format (e.g. RFC 2822), this helper 6070 // helps handle the details 6071 6072 6073 function toTechFormat(dt, format, allowZ) { 6074 if (allowZ === void 0) { 6075 allowZ = true; 6076 } 6077 6078 return dt.isValid ? Formatter.create(Locale.create("en-US"), { 6079 allowZ: allowZ, 6080 forceSimple: true 6081 }).formatDateTimeFromString(dt, format) : null; 6082 } 6083 6084 function _toISODate(o, extended) { 6085 var longFormat = o.c.year > 9999 || o.c.year < 0; 6086 var c = ""; 6087 if (longFormat && o.c.year >= 0) c += "+"; 6088 c += padStart(o.c.year, longFormat ? 6 : 4); 6089 6090 if (extended) { 6091 c += "-"; 6092 c += padStart(o.c.month); 6093 c += "-"; 6094 c += padStart(o.c.day); 6095 } else { 6096 c += padStart(o.c.month); 6097 c += padStart(o.c.day); 6098 } 6099 6100 return c; 6101 } 6102 6103 function _toISOTime(o, extended, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone) { 6104 var c = padStart(o.c.hour); 6105 6106 if (extended) { 6107 c += ":"; 6108 c += padStart(o.c.minute); 6109 6110 if (o.c.second !== 0 || !suppressSeconds) { 6111 c += ":"; 6112 } 6113 } else { 6114 c += padStart(o.c.minute); 6115 } 6116 6117 if (o.c.second !== 0 || !suppressSeconds) { 6118 c += padStart(o.c.second); 6119 6120 if (o.c.millisecond !== 0 || !suppressMilliseconds) { 6121 c += "."; 6122 c += padStart(o.c.millisecond, 3); 6123 } 6124 } 6125 6126 if (includeOffset) { 6127 if (o.isOffsetFixed && o.offset === 0 && !extendedZone) { 6128 c += "Z"; 6129 } else if (o.o < 0) { 6130 c += "-"; 6131 c += padStart(Math.trunc(-o.o / 60)); 6132 c += ":"; 6133 c += padStart(Math.trunc(-o.o % 60)); 6134 } else { 6135 c += "+"; 6136 c += padStart(Math.trunc(o.o / 60)); 6137 c += ":"; 6138 c += padStart(Math.trunc(o.o % 60)); 6139 } 6140 } 6141 6142 if (extendedZone) { 6143 c += "[" + o.zone.ianaName + "]"; 6144 } 6145 6146 return c; 6147 } // defaults for unspecified units in the supported calendars 6148 6149
6150 var defaultUnitValues = { 6151 month: 1, 6152 day: 1, 6153 hour: 0, 6154 minute: 0, 6155 second: 0, 6156 millisecond: 0 6157 }, 6158 defaultWeekUnitValues = { 6159 weekNumber: 1, 6160 weekday: 1, 6161 hour: 0, 6162 minute: 0, 6163 second: 0, 6164 millisecond: 0 6165 }, 6166 defaultOrdinalUnitValues = { 6167 ordinal: 1, 6168 hour: 0, 6169 minute: 0, 6170 second: 0, 6171 millisecond: 0 6172 }; // Units in the supported calendars, sorted by bigness 6173 6174 var orderedUnits = ["year", "month", "day", "hour", "minute", "second", "millisecond"], 6175 orderedWeekUnits = ["weekYear", "weekNumber", "weekday", "hour", "minute", "second", "millisecond"], 6176 orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"]; // standardize case and plurality in units 6177 6178 function normalizeUnit(unit) { 6179 var normalized = { 6180 year: "year", 6181 years: "year", 6182 month: "month", 6183 months: "month", 6184 day: "day", 6185 days: "day", 6186 hour: "hour", 6187 hours: "hour", 6188 minute: "minute", 6189 minutes: "minute", 6190 quarter: "quarter", 6191 quarters: "quarter", 6192 second: "second", 6193 seconds: "second", 6194 millisecond: "millisecond", 6195 milliseconds: "millisecond", 6196 weekday: "weekday", 6197 weekdays: "weekday", 6198 weeknumber: "weekNumber", 6199 weeksnumber: "weekNumber", 6200 weeknumbers: "weekNumber", 6201 weekyear: "weekYear", 6202 weekyears: "weekYear", 6203 ordinal: "ordinal" 6204 }[unit.toLowerCase()]; 6205 if (!normalized) throw new InvalidUnitError(unit); 6206 return normalized; 6207 } // this is a dumbed down version of fromObject() that runs about 60% faster 6208 // but doesn't do any validation, makes a bunch of assumptions about what units 6209 // are present, and so on. 6210 6211 6212 function quickDT(obj, opts) { 6213 var zone = normalizeZone(opts.zone, Settings.defaultZone), 6214 loc = Locale.fromObject(opts), 6215 tsNow = Settings.now(); 6216 var ts, o; // assume we have the higher-order units 6217 6218 if (!isUndefined(obj.year)) { 6219 for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits), _step; !(_step = _iterator()).done;) { 6220 var u = _step.value; 6221 6222 if (isUndefined(obj[u])) {
vendor: 9,425 bytes, lines 6223-6453
6223 obj[u] = defaultUnitValues[u]; 6224 } 6225 } 6226 6227 var invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj); 6228 6229 if (invalid) { 6230 return DateTime.invalid(invalid); 6231 } 6232 6233 var offsetProvis = zone.offset(tsNow); 6234 6235 var _objToTS = objToTS(obj, offsetProvis, zone); 6236 6237 ts = _objToTS[0]; 6238 o = _objToTS[1]; 6239 } else { 6240 ts = tsNow; 6241 } 6242 6243 return new DateTime({ 6244 ts: ts, 6245 zone: zone, 6246 loc: loc, 6247 o: o 6248 }); 6249 } 6250 6251 function diffRelative(start, end, opts) { 6252 var round = isUndefined(opts.round) ? true : opts.round, 6253 format = function format(c, unit) { 6254 c = roundTo(c, round || opts.calendary ? 0 : 2, true); 6255 var formatter = end.loc.clone(opts).relFormatter(opts); 6256 return formatter.format(c, unit); 6257 }, 6258 differ = function differ(unit) { 6259 if (opts.calendary) { 6260 if (!end.hasSame(start, unit)) { 6261 return end.startOf(unit).diff(start.startOf(unit), unit).get(unit); 6262 } else return 0; 6263 } else { 6264 return end.diff(start, unit).get(unit); 6265 } 6266 }; 6267 6268 if (opts.unit) { 6269 return format(differ(opts.unit), opts.unit); 6270 } 6271 6272 for (var _iterator2 = _createForOfIteratorHelperLoose(opts.units), _step2; !(_step2 = _iterator2()).done;) { 6273 var unit = _step2.value; 6274 var count = differ(unit); 6275 6276 if (Math.abs(count) >= 1) { 6277 return format(count, unit); 6278 } 6279 } 6280 6281 return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]); 6282 } 6283 6284 function lastOpts(argList) { 6285 var opts = {}, 6286 args; 6287 6288 if (argList.length > 0 && typeof argList[argList.length - 1] === "object") { 6289 opts = argList[argList.length - 1]; 6290 args = Array.from(argList).slice(0, argList.length - 1); 6291 } else { 6292 args = Array.from(argList); 6293 } 6294 6295 return [opts, args]; 6296 } 6297 /** 6298 * A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them. 6299 * 6300 * A DateTime comprises of: 6301 * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch. 6302 * * A time zone. Each instance is considered in the context of a specific zone (by default the local system's zone). 6303 * * Configuration properties that effect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`. 6304 * 6305 * Here is a brief overview of the most commonly used functionality it provides: 6306 * 6307 * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime#local}, {@link DateTime#utc}, and (most flexibly) {@link DateTime#fromObject}. To create one from a standard string format, use {@link DateTime#fromISO}, {@link DateTime#fromHTTP}, and {@link DateTime#fromRFC2822}. To create one from a custom string format, use {@link DateTime#fromFormat}. To create one from a native JS date, use {@link DateTime#fromJSDate}. 6308 * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, {@link DateTime#month}, 6309 * {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors. 6310 * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors. 6311 * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors. 6312 * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale}, {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}. 6313 * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO}, {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat}, {@link DateTime#toMillis} and {@link DateTime#toJSDate}. 6314 * 6315 * There's plenty others documented below. In addition, for more information on subtler topics like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation. 6316 */ 6317 6318 6319 var DateTime = /*#__PURE__*/function () { 6320 /** 6321 * @access private 6322 */ 6323 function DateTime(config) { 6324 var zone = config.zone || Settings.defaultZone; 6325 var invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null); 6326 /** 6327 * @access private 6328 */ 6329 6330 this.ts = isUndefined(config.ts) ? Settings.now() : config.ts; 6331 var c = null, 6332 o = null; 6333 6334 if (!invalid) { 6335 var unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone); 6336 6337 if (unchanged) { 6338 var _ref = [config.old.c, config.old.o]; 6339 c = _ref[0]; 6340 o = _ref[1]; 6341 } else { 6342 var ot = zone.offset(this.ts); 6343 c = tsToObj(this.ts, ot); 6344 invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null; 6345 c = invalid ? null : c; 6346 o = invalid ? null : ot; 6347 } 6348 } 6349 /** 6350 * @access private 6351 */ 6352 6353 6354 this._zone = zone; 6355 /** 6356 * @access private 6357 */ 6358 6359 this.loc = config.loc || Locale.create(); 6360 /** 6361 * @access private 6362 */ 6363 6364 this.invalid = invalid; 6365 /** 6366 * @access private 6367 */ 6368 6369 this.weekData = null; 6370 /** 6371 * @access private 6372 */ 6373 6374 this.c = c; 6375 /** 6376 * @access private 6377 */ 6378 6379 this.o = o; 6380 /** 6381 * @access private 6382 */ 6383 6384 this.isLuxonDateTime = true; 6385 } // CONSTRUCT 6386 6387 /** 6388 * Create a DateTime for the current instant, in the system's time zone. 6389 * 6390 * Use Settings to override these default values if needed. 6391 * @example DateTime.now().toISO() //~> now in the ISO format 6392 * @return {DateTime} 6393 */ 6394 6395 6396 DateTime.now = function now() { 6397 return new DateTime({}); 6398 } 6399 /** 6400 * Create a local DateTime 6401 * @param {number} [year] - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used 6402 * @param {number} [month=1] - The month, 1-indexed 6403 * @param {number} [day=1] - The day of the month, 1-indexed 6404 * @param {number} [hour=0] - The hour of the day, in 24-hour time 6405 * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59 6406 * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59 6407 * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999 6408 * @example DateTime.local() //~> now 6409 * @example DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time 6410 * @example DateTime.local(2017) //~> 2017-01-01T00:00:00 6411 * @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00 6412 * @example DateTime.local(2017, 3, 12, { locale: "fr" }) //~> 2017-03-12T00:00:00, with a French locale 6413 * @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00 6414 * @example DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC 6415 * @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00 6416 * @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10 6417 * @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765 6418 * @return {DateTime} 6419 */ 6420 ; 6421 6422 DateTime.local = function local() { 6423 var _lastOpts = lastOpts(arguments), 6424 opts = _lastOpts[0], 6425 args = _lastOpts[1], 6426 year = args[0], 6427 month = args[1], 6428 day = args[2], 6429 hour = args[3], 6430 minute = args[4], 6431 second = args[5], 6432 millisecond = args[6]; 6433 6434 return quickDT({ 6435 year: year, 6436 month: month, 6437 day: day, 6438 hour: hour, 6439 minute: minute, 6440 second: second, 6441 millisecond: millisecond 6442 }, opts); 6443 } 6444 /** 6445 * Create a DateTime in UTC 6446 * @param {number} [year] - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used 6447 * @param {number} [month=1] - The month, 1-indexed 6448 * @param {number} [day=1] - The day of the month 6449 * @param {number} [hour=0] - The hour of the day, in 24-hour time 6450 * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59 6451 * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59 6452 * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999 6453 * @param {Object} options - configuration options for the DateTime
6454 * @param {string} [options.locale] - a locale to set on the resulting DateTime instance 6455 * @param {string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance 6456 * @param {string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance 6457 * @example DateTime.utc() //~> now 6458 * @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z 6459 * @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z 6460 * @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z 6461 * @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z 6462 * @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z 6463 * @example DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" }) //~> 2017-03-12T05:45:00Z with a French locale 6464 * @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z 6465 * @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr" }) //~> 2017-03-12T05:45:10.765Z with a French locale 6466 * @return {DateTime} 6467 */ 6468 ; 6469 6470 DateTime.utc = function utc() { 6471 var _lastOpts2 = lastOpts(arguments), 6472 opts = _lastOpts2[0], 6473 args = _lastOpts2[1], 6474 year = args[0], 6475 month = args[1], 6476 day = args[2], 6477 hour = args[3], 6478 minute = args[4], 6479 second = args[5], 6480 millisecond = args[6]; 6481 6482 opts.zone = FixedOffsetZone.utcInstance; 6483 return quickDT({ 6484 year: year, 6485 month: month, 6486 day: day, 6487 hour: hour, 6488 minute: minute, 6489 second: second, 6490 millisecond: millisecond 6491 }, opts); 6492 } 6493 /** 6494 * Create a DateTime from a JavaScript Date object. Uses the default zone. 6495 * @param {Date} date - a JavaScript Date object 6496 * @param {Object} options - configuration options for the DateTime 6497 * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into 6498 * @return {DateTime} 6499 */ 6500 ; 6501 6502 DateTime.fromJSDate = function fromJSDate(date, options) { 6503 if (options === void 0) { 6504 options = {}; 6505 } 6506 6507 var ts = isDate(date) ? date.valueOf() : NaN; 6508 6509 if (Number.isNaN(ts)) { 6510 return DateTime.invalid("invalid input"); 6511 } 6512 6513 var zoneToUse = normalizeZone(options.zone, Settings.defaultZone); 6514 6515 if (!zoneToUse.isValid) { 6516 return DateTime.invalid(unsupportedZone(zoneToUse)); 6517 } 6518 6519 return new DateTime({ 6520 ts: ts, 6521 zone: zoneToUse, 6522 loc: Locale.fromObject(options) 6523 }); 6524 } 6525 /** 6526 * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. 6527 * @param {number} milliseconds - a number of milliseconds since 1970 UTC 6528 * @param {Object} options - configuration options for the DateTime 6529 * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into 6530 * @param {string} [options.locale] - a locale to set on the resulting DateTime instance 6531 * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance 6532 * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance 6533 * @return {DateTime} 6534 */ 6535 ; 6536 6537 DateTime.fromMillis = function fromMillis(milliseconds, options) { 6538 if (options === void 0) { 6539 options = {}; 6540 } 6541 6542 if (!isNumber(milliseconds)) { 6543 throw new InvalidArgumentError("fromMillis requires a numerical input, but received a " + typeof milliseconds + " with value " + milliseconds); 6544 } else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) { 6545 // this isn't perfect because because we can still end up out of range because of additional shifting, but it's a start
vendor: 10,797 bytes, lines 6546-6769
6546 return DateTime.invalid("Timestamp out of range"); 6547 } else { 6548 return new DateTime({ 6549 ts: milliseconds, 6550 zone: normalizeZone(options.zone, Settings.defaultZone), 6551 loc: Locale.fromObject(options) 6552 }); 6553 } 6554 } 6555 /** 6556 * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. 6557 * @param {number} seconds - a number of seconds since 1970 UTC 6558 * @param {Object} options - configuration options for the DateTime 6559 * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into 6560 * @param {string} [options.locale] - a locale to set on the resulting DateTime instance 6561 * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance 6562 * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance 6563 * @return {DateTime} 6564 */ 6565 ; 6566 6567 DateTime.fromSeconds = function fromSeconds(seconds, options) { 6568 if (options === void 0) { 6569 options = {}; 6570 } 6571 6572 if (!isNumber(seconds)) { 6573 throw new InvalidArgumentError("fromSeconds requires a numerical input"); 6574 } else { 6575 return new DateTime({ 6576 ts: seconds * 1000, 6577 zone: normalizeZone(options.zone, Settings.defaultZone), 6578 loc: Locale.fromObject(options) 6579 }); 6580 } 6581 } 6582 /** 6583 * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults. 6584 * @param {Object} obj - the object to create the DateTime from 6585 * @param {number} obj.year - a year, such as 1987 6586 * @param {number} obj.month - a month, 1-12 6587 * @param {number} obj.day - a day of the month, 1-31, depending on the month 6588 * @param {number} obj.ordinal - day of the year, 1-365 or 366 6589 * @param {number} obj.weekYear - an ISO week year 6590 * @param {number} obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year 6591 * @param {number} obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday 6592 * @param {number} obj.hour - hour of the day, 0-23 6593 * @param {number} obj.minute - minute of the hour, 0-59 6594 * @param {number} obj.second - second of the minute, 0-59 6595 * @param {number} obj.millisecond - millisecond of the second, 0-999 6596 * @param {Object} opts - options for creating this DateTime 6597 * @param {string|Zone} [opts.zone='local'] - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone() 6598 * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance 6599 * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance 6600 * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance 6601 * @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25' 6602 * @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01' 6603 * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06 6604 * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }), 6605 * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' }) 6606 * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' }) 6607 * @example DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13' 6608 * @return {DateTime} 6609 */ 6610 ; 6611 6612 DateTime.fromObject = function fromObject(obj, opts) { 6613 if (opts === void 0) { 6614 opts = {}; 6615 } 6616 6617 obj = obj || {}; 6618 var zoneToUse = normalizeZone(opts.zone, Settings.defaultZone); 6619 6620 if (!zoneToUse.isValid) { 6621 return DateTime.invalid(unsupportedZone(zoneToUse)); 6622 } 6623 6624 var tsNow = Settings.now(), 6625 offsetProvis = !isUndefined(opts.specificOffset) ? opts.specificOffset : zoneToUse.offset(tsNow), 6626 normalized = normalizeObject(obj, normalizeUnit), 6627 containsOrdinal = !isUndefined(normalized.ordinal), 6628 containsGregorYear = !isUndefined(normalized.year), 6629 containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), 6630 containsGregor = containsGregorYear || containsGregorMD, 6631 definiteWeekDef = normalized.weekYear || normalized.weekNumber, 6632 loc = Locale.fromObject(opts); // cases: 6633 // just a weekday -> this week's instance of that weekday, no worries 6634 // (gregorian data or ordinal) + (weekYear or weekNumber) -> error 6635 // (gregorian month or day) + ordinal -> error 6636 // otherwise just use weeks or ordinals or gregorian, depending on what's specified 6637 6638 if ((containsGregor || containsOrdinal) && definiteWeekDef) { 6639 throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals"); 6640 } 6641 6642 if (containsGregorMD && containsOrdinal) { 6643 throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day"); 6644 } 6645 6646 var useWeekData = definiteWeekDef || normalized.weekday && !containsGregor; // configure ourselves to deal with gregorian dates or week stuff 6647 6648 var units, 6649 defaultValues, 6650 objNow = tsToObj(tsNow, offsetProvis); 6651 6652 if (useWeekData) { 6653 units = orderedWeekUnits; 6654 defaultValues = defaultWeekUnitValues; 6655 objNow = gregorianToWeek(objNow); 6656 } else if (containsOrdinal) { 6657 units = orderedOrdinalUnits; 6658 defaultValues = defaultOrdinalUnitValues; 6659 objNow = gregorianToOrdinal(objNow); 6660 } else { 6661 units = orderedUnits; 6662 defaultValues = defaultUnitValues; 6663 } // set default values for missing stuff 6664 6665 6666 var foundFirst = false; 6667 6668 for (var _iterator3 = _createForOfIteratorHelperLoose(units), _step3; !(_step3 = _iterator3()).done;) { 6669 var u = _step3.value; 6670 var v = normalized[u]; 6671 6672 if (!isUndefined(v)) { 6673 foundFirst = true; 6674 } else if (foundFirst) { 6675 normalized[u] = defaultValues[u]; 6676 } else { 6677 normalized[u] = objNow[u]; 6678 } 6679 } // make sure the values we have are in range 6680 6681 6682 var higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized), 6683 invalid = higherOrderInvalid || hasInvalidTimeData(normalized); 6684 6685 if (invalid) { 6686 return DateTime.invalid(invalid); 6687 } // compute the actual time 6688 6689 6690 var gregorian = useWeekData ? weekToGregorian(normalized) : containsOrdinal ? ordinalToGregorian(normalized) : normalized, 6691 _objToTS2 = objToTS(gregorian, offsetProvis, zoneToUse), 6692 tsFinal = _objToTS2[0], 6693 offsetFinal = _objToTS2[1], 6694 inst = new DateTime({ 6695 ts: tsFinal, 6696 zone: zoneToUse, 6697 o: offsetFinal, 6698 loc: loc 6699 }); // gregorian data + weekday serves only to validate 6700 6701 6702 if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) { 6703 return DateTime.invalid("mismatched weekday", "you can't specify both a weekday of " + normalized.weekday + " and a date of " + inst.toISO()); 6704 } 6705 6706 return inst; 6707 } 6708 /** 6709 * Create a DateTime from an ISO 8601 string 6710 * @param {string} text - the ISO string 6711 * @param {Object} opts - options to affect the creation 6712 * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone 6713 * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one 6714 * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance 6715 * @param {string} [opts.outputCalendar] - the output calendar to set on the resulting DateTime instance 6716 * @param {string} [opts.numberingSystem] - the numbering system to set on the resulting DateTime instance 6717 * @example DateTime.fromISO('2016-05-25T09:08:34.123') 6718 * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00') 6719 * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true}) 6720 * @example DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'}) 6721 * @example DateTime.fromISO('2016-W05-4') 6722 * @return {DateTime} 6723 */ 6724 ; 6725 6726 DateTime.fromISO = function fromISO(text, opts) { 6727 if (opts === void 0) { 6728 opts = {}; 6729 } 6730 6731 var _parseISODate = parseISODate(text), 6732 vals = _parseISODate[0], 6733 parsedZone = _parseISODate[1]; 6734 6735 return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text); 6736 } 6737 /** 6738 * Create a DateTime from an RFC 2822 string 6739 * @param {string} text - the RFC 2822 string 6740 * @param {Object} opts - options to affect the creation 6741 * @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since the offset is always specified in the string itself, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. 6742 * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one 6743 * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance 6744 * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance 6745 * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance 6746 * @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT') 6747 * @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600') 6748 * @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z') 6749 * @return {DateTime} 6750 */ 6751 ; 6752 6753 DateTime.fromRFC2822 = function fromRFC2822(text, opts) { 6754 if (opts === void 0) { 6755 opts = {}; 6756 } 6757 6758 var _parseRFC2822Date = parseRFC2822Date(text), 6759 vals = _parseRFC2822Date[0], 6760 parsedZone = _parseRFC2822Date[1]; 6761 6762 return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text); 6763 } 6764 /** 6765 * Create a DateTime from an HTTP header date 6766 * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 6767 * @param {string} text - the HTTP header date 6768 * @param {Object} opts - options to affect the creation 6769 * @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since HTTP dates are always in UTC, this has no effect on the interpretation of str
6769ing, merely the zone the resulting DateTime is expressed in. 6770 * @param {boolean} [opts.setZone=false] - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods. 6771 * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance 6772 * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance 6773 * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance 6774 * @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT') 6775 * @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT') 6776 * @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994') 6777 * @return {DateTime} 6778 */ 6779 ; 6780 6781 DateTime.fromHTTP = function fromHTTP(text, opts) { 6782 if (opts === void 0) { 6783 opts = {}; 6784 } 6785 6786 var _parseHTTPDate = parseHTTPDate(text), 6787 vals = _parseHTTPDate[0], 6788 parsedZone = _parseHTTPDate[1]; 6789 6790 return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts); 6791 } 6792 /** 6793 * Create a DateTime from an input string and format string. 6794 * Defaults to en-US if no locale has been specified, regardless of the system's locale. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). 6795 * @param {string} text - the string to parse 6796 * @param {string} fmt - the format the string is expected to be in (see the link below for the formats) 6797 * @param {Object} opts - options to affect the creation 6798 * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone 6799 * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one 6800 * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale 6801 * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system 6802 * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance 6803 * @return {DateTime} 6804 */ 6805 ; 6806 6807 DateTime.fromFormat = function fromFormat(text, fmt, opts) { 6808 if (opts === void 0) { 6809 opts = {}; 6810 } 6811 6812 if (isUndefined(text) || isUndefined(fmt)) { 6813 throw new InvalidArgumentError("fromFormat requires an input string and a format"); 6814 } 6815 6816 var _opts = opts, 6817 _opts$locale = _opts.locale, 6818 locale = _opts$locale === void 0 ? null : _opts$locale, 6819 _opts$numberingSystem = _opts.numberingSystem, 6820 numberingSystem = _opts$numberingSystem === void 0 ? null : _opts$numberingSystem, 6821 localeToUse = Locale.fromOpts({ 6822 locale: locale, 6823 numberingSystem: numberingSystem, 6824 defaultToEN: true 6825 }), 6826 _parseFromTokens = parseFromTokens(localeToUse, text, fmt), 6827 vals = _parseFromTokens[0], 6828 parsedZone = _parseFromTokens[1], 6829 specificOffset = _parseFromTokens[2], 6830 invalid = _parseFromTokens[3]; 6831 6832 if (invalid) { 6833 return DateTime.invalid(invalid); 6834 } else { 6835 return parseDataToDateTime(vals, parsedZone, opts, "format " + fmt, text, specificOffset); 6836 } 6837 } 6838 /** 6839 * @deprecated use fromFormat instead 6840 */ 6841 ; 6842 6843 DateTime.fromString = function fromString(text, fmt, opts) { 6844 if (opts === void 0) { 6845 opts = {}; 6846 } 6847 6848 return DateTime.fromFormat(text, fmt, opts); 6849 } 6850 /** 6851 * Create a DateTime from a SQL date, time, or datetime 6852 * Defaults to en-US if no locale has been specified, regardless of the system's locale 6853 * @param {string} text - the string to parse 6854 * @param {Object} opts - options to affect the creation 6855 * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone 6856 * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one 6857 * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale 6858 * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system 6859 * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance 6860 * @example DateTime.fromSQL('2017-05-15') 6861 * @example DateTime.fromSQL('2017-05-15 09:12:34') 6862 * @example DateTime.fromSQL('2017-05-15 09:12:34.342') 6863 * @example DateTime.fromSQL('2017-05-15 09:12:34.342+06:00') 6864 * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles') 6865 * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true }) 6866 * @example DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' }) 6867 * @example DateTime.fromSQL('09:12:34.342') 6868 * @return {DateTime} 6869 */ 6870 ; 6871 6872 DateTime.fromSQL = function fromSQL(text, opts) { 6873 if (opts === void 0) { 6874 opts = {}; 6875 } 6876 6877 var _parseSQL = parseSQL(text), 6878 vals = _parseSQL[0], 6879 parsedZone = _parseSQL[1]; 6880 6881 return parseDataToDateTime(vals, parsedZone, opts, "SQL", text); 6882 } 6883 /**
6884 * Create an invalid DateTime. 6885 * @param {string} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent 6886 * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information 6887 * @return {DateTime} 6888 */ 6889 ; 6890 6891 DateTime.invalid = function invalid(reason, explanation) { 6892 if (explanation === void 0) { 6893 explanation = null; 6894 } 6895 6896 if (!reason) { 6897 throw new InvalidArgumentError("need to specify a reason the DateTime is invalid"); 6898 } 6899 6900 var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation); 6901 6902 if (Settings.throwOnInvalid) { 6903 throw new InvalidDateTimeError(invalid); 6904 } else { 6905 return new DateTime({ 6906 invalid: invalid 6907 }); 6908 } 6909 } 6910 /** 6911 * Check if an object is an instance of DateTime. Works across context boundaries 6912 * @param {object} o 6913 * @return {boolean} 6914 */ 6915 ; 6916 6917 DateTime.isDateTime = function isDateTime(o) { 6918 return o && o.isLuxonDateTime || false; 6919 } // INFO 6920 6921 /** 6922 * Get the value of unit. 6923 * @param {string} unit - a unit such as 'minute' or 'day' 6924 * @example DateTime.local(2017, 7, 4).get('month'); //=> 7 6925 * @example DateTime.local(2017, 7, 4).get('day'); //=> 4 6926 * @return {number} 6927 */ 6928 ; 6929 6930 var _proto = DateTime.prototype; 6931 6932 _proto.get = function get(unit) { 6933 return this[unit]; 6934 } 6935 /** 6936 * Returns whether the DateTime is valid. Invalid DateTimes occur when: 6937 * * The DateTime was created from invalid calendar information, such as the 13th month or February 30 6938 * * The DateTime was created by an operation on another invalid date 6939 * @type {boolean} 6940 */ 6941 ; 6942 6943 /** 6944 * Returns the resolved Intl options for this DateTime. 6945 * This is useful in understanding the behavior of formatting methods 6946 * @param {Object} opts - the same options as toLocaleString 6947 * @return {Object} 6948 */ 6949 _proto.resolvedLocaleOptions = function resolvedLocaleOptions(opts) { 6950 if (opts === void 0) { 6951 opts = {}; 6952 } 6953 6954 var _Formatter$create$res = Formatter.create(this.loc.clone(opts), opts).resolvedOptions(this), 6955 locale = _Formatter$create$res.locale, 6956 numberingSystem = _Formatter$create$res.numberingSystem, 6957 calendar = _Formatter$create$res.calendar; 6958 6959 return { 6960 locale: locale, 6961 numberingSystem: numberingSystem, 6962 outputCalendar: calendar 6963 }; 6964 } // TRANSFORM 6965 6966 /** 6967 * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime. 6968 * 6969 * Equivalent to {@link DateTime#setZone}('utc') 6970 * @param {number} [offset=0] - optionally, an offset from UTC in minutes 6971 * @param {Object} [opts={}] - options to pass to `setZone()` 6972 * @return {DateTime} 6973 */ 6974 ; 6975 6976 _proto.toUTC = function toUTC(offset, opts) { 6977 if (offset === void 0) { 6978 offset = 0; 6979 } 6980 6981 if (opts === void 0) { 6982 opts = {}; 6983 } 6984 6985 return this.setZone(FixedOffsetZone.instance(offset), opts); 6986 } 6987 /** 6988 * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime. 6989 * 6990 * Equivalent to `setZone('local')` 6991 * @return {DateTime} 6992 */ 6993 ; 6994 6995 _proto.toLocal = function toLocal() { 6996 return this.setZone(Settings.defaultZone); 6997 } 6998 /** 6999 * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime. 7000 * 7001 * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with {@link DateTime#plus}. You may wish to use {@link DateTime#toLocal} and {@link DateTime#toUTC} which provide simple convenience wrappers for commonly used zones. 7002 * @param {string|Zone} [zone='local'] - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a {@link DateTime#Zone} class. 7003 * @param {Object} opts - options 7004 * @param {boolean} [opts.keepLocalTime=false] - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this. 7005 * @return {DateTime} 7006 */ 7007 ; 7008 7009 _proto.setZone = function setZone(zone, _temp) { 7010 var _ref2 = _temp === void 0 ? {}
vendor: 4,355 bytes, lines 7010-7131
7010 : _temp, 7011 _ref2$keepLocalTime = _ref2.keepLocalTime, 7012 keepLocalTime = _ref2$keepLocalTime === void 0 ? false : _ref2$keepLocalTime, 7013 _ref2$keepCalendarTim = _ref2.keepCalendarTime, 7014 keepCalendarTime = _ref2$keepCalendarTim === void 0 ? false : _ref2$keepCalendarTim; 7015 7016 zone = normalizeZone(zone, Settings.defaultZone); 7017 7018 if (zone.equals(this.zone)) { 7019 return this; 7020 } else if (!zone.isValid) { 7021 return DateTime.invalid(unsupportedZone(zone)); 7022 } else { 7023 var newTS = this.ts; 7024 7025 if (keepLocalTime || keepCalendarTime) { 7026 var offsetGuess = zone.offset(this.ts); 7027 var asObj = this.toObject(); 7028 7029 var _objToTS3 = objToTS(asObj, offsetGuess, zone); 7030 7031 newTS = _objToTS3[0]; 7032 } 7033 7034 return clone(this, { 7035 ts: newTS, 7036 zone: zone 7037 }); 7038 } 7039 } 7040 /** 7041 * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime. 7042 * @param {Object} properties - the properties to set 7043 * @example DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' }) 7044 * @return {DateTime} 7045 */ 7046 ; 7047 7048 _proto.reconfigure = function reconfigure(_temp2) { 7049 var _ref3 = _temp2 === void 0 ? {} : _temp2, 7050 locale = _ref3.locale, 7051 numberingSystem = _ref3.numberingSystem, 7052 outputCalendar = _ref3.outputCalendar; 7053 7054 var loc = this.loc.clone({ 7055 locale: locale, 7056 numberingSystem: numberingSystem, 7057 outputCalendar: outputCalendar 7058 }); 7059 return clone(this, { 7060 loc: loc 7061 }); 7062 } 7063 /** 7064 * "Set" the locale. Returns a newly-constructed DateTime. 7065 * Just a convenient alias for reconfigure({ locale }) 7066 * @example DateTime.local(2017, 5, 25).setLocale('en-GB') 7067 * @return {DateTime} 7068 */ 7069 ; 7070 7071 _proto.setLocale = function setLocale(locale) { 7072 return this.reconfigure({ 7073 locale: locale 7074 }); 7075 } 7076 /** 7077 * "Set" the values of specified units. Returns a newly-constructed DateTime. 7078 * You can only set units with this method; for "setting" metadata, see {@link DateTime#reconfigure} and {@link DateTime#setZone}. 7079 * @param {Object} values - a mapping of units to numbers 7080 * @example dt.set({ year: 2017 }) 7081 * @example dt.set({ hour: 8, minute: 30 }) 7082 * @example dt.set({ weekday: 5 }) 7083 * @example dt.set({ year: 2005, ordinal: 234 }) 7084 * @return {DateTime} 7085 */ 7086 ; 7087 7088 _proto.set = function set(values) { 7089 if (!this.isValid) return this; 7090 var normalized = normalizeObject(values, normalizeUnit), 7091 settingWeekStuff = !isUndefined(normalized.weekYear) || !isUndefined(normalized.weekNumber) || !isUndefined(normalized.weekday), 7092 containsOrdinal = !isUndefined(normalized.ordinal), 7093 containsGregorYear = !isUndefined(normalized.year), 7094 containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), 7095 containsGregor = containsGregorYear || containsGregorMD, 7096 definiteWeekDef = normalized.weekYear || normalized.weekNumber; 7097 7098 if ((containsGregor || containsOrdinal) && definiteWeekDef) { 7099 throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals"); 7100 } 7101 7102 if (containsGregorMD && containsOrdinal) { 7103 throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day"); 7104 } 7105 7106 var mixed; 7107 7108 if (settingWeekStuff) { 7109 mixed = weekToGregorian(_extends({}, gregorianToWeek(this.c), normalized)); 7110 } else if (!isUndefined(normalized.ordinal)) { 7111 mixed = ordinalToGregorian(_extends({}, gregorianToOrdinal(this.c), normalized)); 7112 } else { 7113 mixed = _extends({}, this.toObject(), normalized); // if we didn't set the day but we ended up on an overflow date, 7114 // use the last day of the right month 7115 7116 if (isUndefined(normalized.day)) { 7117 mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day); 7118 } 7119 } 7120 7121 var _objToTS4 = objToTS(mixed, this.o, this.zone), 7122 ts = _objToTS4[0], 7123 o = _objToTS4[1]; 7124 7125 return clone(this, { 7126 ts: ts, 7127 o: o 7128 }); 7129 } 7130 /** 7131 * Add a period of time to this DateTime and return the resulting DateTime
7132 * 7133 * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between. 7134 * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() 7135 * @example DateTime.now().plus(123) //~> in 123 milliseconds 7136 * @example DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes 7137 * @example DateTime.now().plus({ days: 1 }) //~> this time tomorrow 7138 * @example DateTime.now().plus({ days: -1 }) //~> this time yesterday 7139 * @example DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min 7140 * @example DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min 7141 * @return {DateTime} 7142 */ 7143 ; 7144 7145 _proto.plus = function plus(duration) { 7146 if (!this.isValid) return this; 7147 var dur = Duration.fromDurationLike(duration); 7148 return clone(this, adjustTime(this, dur)); 7149 } 7150 /** 7151 * Subtract a period of time to this DateTime and return the resulting DateTime 7152 * See {@link DateTime#plus} 7153 * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() 7154 @return {DateTime} 7155 */ 7156 ; 7157 7158 _proto.minus = function minus(duration) { 7159 if (!this.isValid) return this; 7160 var dur = Duration.fromDurationLike(duration).negate(); 7161 return clone(this, adjustTime(this, dur)); 7162 } 7163 /** 7164 * "Set" this DateTime to the beginning of a unit of time. 7165 * @param {string} unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. 7166 * @example DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01' 7167 * @example DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01' 7168 * @example DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays 7169 * @example DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00' 7170 * @example DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00' 7171 * @return {DateTime} 7172 */ 7173 ; 7174 7175 _proto.startOf = function startOf(unit) { 7176 if (!this.isValid) return this; 7177 var o = {}, 7178 normalizedUnit = Duration.normalizeUnit(unit); 7179 7180 switch (normalizedUnit) { 7181 case "years": 7182 o.month = 1; 7183 // falls through 7184 7185 case "quarters": 7186 case "months": 7187 o.day = 1; 7188 // falls through 7189 7190 case "weeks": 7191 case "days": 7192 o.hour = 0; 7193 // falls through 7194 7195 case "hours": 7196 o.minute = 0; 7197 // falls through 7198 7199 case "minutes": 7200 o.second = 0; 7201 // falls through 7202 7203 case "seconds": 7204 o.millisecond = 0; 7205 break; 7206 // no default, invalid units throw in normalizeUnit() 7207 } 7208 7209 if (normalizedUnit === "weeks") { 7210 o.weekday = 1; 7211 } 7212 7213 if (normalizedUnit === "quarters") { 7214 var q = Math.ceil(this.month / 3); 7215 o.month = (q - 1) * 3 + 1; 7216 } 7217 7218 return this.set(o); 7219 } 7220 /** 7221 * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time 7222 * @param {string} unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. 7223 * @example DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00' 7224 * @example DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00' 7225 * @example DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays 7226 * @example DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00' 7227 * @example DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00' 7228 * @return {DateTime} 7229 */ 7230 ; 7231 7232 _proto.endOf = function endOf(unit) { 7233 var _this$plus; 7234 7235 return this.isValid ? this.plus((_this$plus = {}, _this$plus[unit] = 1, _this$plus)).startOf(unit).minus(1) : this; 7236 } // OUTPUT 7237 7238 /** 7239 * Returns a string representation of this DateTime formatted according to the specified format str
7239ing. 7240 * **You may not want this.** See {@link DateTime#toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens). 7241 * Defaults to en-US if no locale has been specified, regardless of the system's locale. 7242 * @param {string} fmt - the format string 7243 * @param {Object} opts - opts to override the configuration options on this DateTime 7244 * @example DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22' 7245 * @example DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22' 7246 * @example DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22' 7247 * @example DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes' 7248 * @return {string} 7249 */ 7250 ; 7251 7252 _proto.toFormat = function toFormat(fmt, opts) { 7253 if (opts === void 0) { 7254 opts = {}; 7255 } 7256 7257 return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID; 7258 } 7259 /** 7260 * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE`. 7261 * The exact behavior of this method is browser-specific, but in general it will return an appropriate representation 7262 * of the DateTime in the assigned locale. 7263 * Defaults to the system's locale if no locale has been specified 7264 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat 7265 * @param formatOpts {Object} - Intl.DateTimeFormat constructor options and configuration options 7266 * @param {Object} opts - opts to override the configuration options on this DateTime 7267 * @example DateTime.now().toLocaleString(); //=> 4/20/2017 7268 * @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017' 7269 * @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017' 7270 * @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017' 7271 * @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM' 7272 * @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM' 7273 * @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20' 7274 * @example DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM' 7275 * @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32' 7276 * @return {string} 7277 */ 7278 ; 7279 7280 _proto.toLocaleString = function toLocaleString(formatOpts, opts) { 7281 if (formatOpts === void 0) { 7282 formatOpts = DATE_SHORT; 7283 } 7284 7285 if (opts === void 0) { 7286 opts = {}; 7287 } 7288 7289 return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID; 7290 } 7291 /** 7292 * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output. 7293 * Defaults to the system's locale if no locale has been specified 7294 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts 7295 * @param opts {Object} - Intl.DateTimeFormat constructor options, same as `toLocaleString`. 7296 * @example DateTime.now().toLocaleParts(); //=> [ 7297 * //=> { type: 'day', value: '25' }, 7298 * //=> { type: 'literal', value: '/' }, 7299 * //=> { type: 'month', value: '05' }, 7300 * //=> { type: 'literal', value: '/' }, 7301 * //=> { type: 'year', value: '1982' } 7302 * //=> ] 7303 */ 7304 ; 7305 7306 _proto.toLocaleParts = function toLocaleParts(opts) { 7307 if (opts === void 0) { 7308 opts = {}; 7309 } 7310 7311 return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : []; 7312 } 7313 /** 7314 * Returns an ISO 8601-compliant string representation of this DateTime
7315 * @param {Object} opts - options 7316 * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0 7317 * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0 7318 * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00' 7319 * @param {boolean} [opts.extendedZone=true] - add the time zone format extension 7320 * @param {string} [opts.format='extended'] - choose between the basic and extended format 7321 * @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z' 7322 * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00' 7323 * @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335' 7324 * @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400' 7325 * @return {string} 7326 */ 7327 ; 7328 7329 _proto.toISO = function toISO(_temp3) { 7330 var _ref4 = _temp3 === void 0 ? {} : _temp3, 7331 _ref4$format = _ref4.format, 7332 format = _ref4$format === void 0 ? "extended" : _ref4$format, 7333 _ref4$suppressSeconds = _ref4.suppressSeconds, 7334 suppressSeconds = _ref4$suppressSeconds === void 0 ? false : _ref4$suppressSeconds, 7335 _ref4$suppressMillise = _ref4.suppressMilliseconds, 7336 suppressMilliseconds = _ref4$suppressMillise === void 0 ? false : _ref4$suppressMillise, 7337 _ref4$includeOffset = _ref4.includeOffset, 7338 includeOffset = _ref4$includeOffset === void 0 ? true : _ref4$includeOffset, 7339 _ref4$extendedZone = _ref4.extendedZone, 7340 extendedZone = _ref4$extendedZone === void 0 ? false : _ref4$extendedZone; 7341 7342 if (!this.isValid) { 7343 return null; 7344 } 7345 7346 var ext = format === "extended"; 7347 7348 var c = _toISODate(this, ext); 7349 7350 c += "T"; 7351 c += _toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone); 7352 return c; 7353 } 7354 /** 7355 * Returns an ISO 8601-compliant string representation of this DateTime's date component 7356 * @param {Object} opts - options 7357 * @param {string} [opts.format='extended'] - choose between the basic and extended format 7358 * @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25' 7359 * @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525' 7360 * @return {string} 7361 */ 7362 ; 7363 7364 _proto.toISODate = function toISODate(_temp4) { 7365 var _ref5 = _temp4 === void 0 ? {} : _temp4, 7366 _ref5$format = _ref5.format, 7367 format = _ref5$format === void 0 ? "extended" : _ref5$format; 7368 7369 if (!this.isValid) { 7370 return null; 7371 } 7372 7373 return _toISODate(this, format === "extended"); 7374 } 7375 /** 7376 * Returns an ISO 8601-compliant string representation of this DateTime's week date 7377 * @example DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2' 7378 * @return {string} 7379 */ 7380 ; 7381 7382 _proto.toISOWeekDate = function toISOWeekDate() { 7383 return toTechFormat(this, "kkkk-'W'WW-c"); 7384 } 7385 /** 7386 * Returns an ISO 8601-compliant string representation of this DateTime's time component 7387 * @param {Object} opts - options 7388 * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0 7389 * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0 7390 * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00' 7391 * @param {boolean} [opts.extendedZone=true] - add the time zone format extension 7392 * @param {boolean} [opts.includePrefix=false] - include the `T` prefix 7393 * @param {string} [opts.format='extended'] - choose between the basic and extended format 7394 * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z' 7395 * @example DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z' 7396 * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z' 7397 * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z' 7398 * @return {string} 7399 */ 7400 ; 7401 7402 _proto.toISOTime = function toISOTime(_temp5) { 7403 var _ref6 = _temp5 === void 0 ? {}
vendor: 4,267 bytes, lines 7403-7502
7403 : _temp5, 7404 _ref6$suppressMillise = _ref6.suppressMilliseconds, 7405 suppressMilliseconds = _ref6$suppressMillise === void 0 ? false : _ref6$suppressMillise, 7406 _ref6$suppressSeconds = _ref6.suppressSeconds, 7407 suppressSeconds = _ref6$suppressSeconds === void 0 ? false : _ref6$suppressSeconds, 7408 _ref6$includeOffset = _ref6.includeOffset, 7409 includeOffset = _ref6$includeOffset === void 0 ? true : _ref6$includeOffset, 7410 _ref6$includePrefix = _ref6.includePrefix, 7411 includePrefix = _ref6$includePrefix === void 0 ? false : _ref6$includePrefix, 7412 _ref6$extendedZone = _ref6.extendedZone, 7413 extendedZone = _ref6$extendedZone === void 0 ? false : _ref6$extendedZone, 7414 _ref6$format = _ref6.format, 7415 format = _ref6$format === void 0 ? "extended" : _ref6$format; 7416 7417 if (!this.isValid) { 7418 return null; 7419 } 7420 7421 var c = includePrefix ? "T" : ""; 7422 return c + _toISOTime(this, format === "extended", suppressSeconds, suppressMilliseconds, includeOffset, extendedZone); 7423 } 7424 /** 7425 * Returns an RFC 2822-compatible string representation of this DateTime 7426 * @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000' 7427 * @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400' 7428 * @return {string} 7429 */ 7430 ; 7431 7432 _proto.toRFC2822 = function toRFC2822() { 7433 return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false); 7434 } 7435 /** 7436 * Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT. 7437 * Specifically, the string conforms to RFC 1123. 7438 * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 7439 * @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT' 7440 * @example DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT' 7441 * @return {string} 7442 */ 7443 ; 7444 7445 _proto.toHTTP = function toHTTP() { 7446 return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'"); 7447 } 7448 /** 7449 * Returns a string representation of this DateTime appropriate for use in SQL Date 7450 * @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13' 7451 * @return {string} 7452 */ 7453 ; 7454 7455 _proto.toSQLDate = function toSQLDate() { 7456 if (!this.isValid) { 7457 return null; 7458 } 7459 7460 return _toISODate(this, true); 7461 } 7462 /** 7463 * Returns a string representation of this DateTime appropriate for use in SQL Time 7464 * @param {Object} opts - options 7465 * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset. 7466 * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00' 7467 * @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00' 7468 * @example DateTime.utc().toSQL() //=> '05:15:16.345' 7469 * @example DateTime.now().toSQL() //=> '05:15:16.345 -04:00' 7470 * @example DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345' 7471 * @example DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York' 7472 * @return {string} 7473 */ 7474 ; 7475 7476 _proto.toSQLTime = function toSQLTime(_temp6) { 7477 var _ref7 = _temp6 === void 0 ? {} : _temp6, 7478 _ref7$includeOffset = _ref7.includeOffset, 7479 includeOffset = _ref7$includeOffset === void 0 ? true : _ref7$includeOffset, 7480 _ref7$includeZone = _ref7.includeZone, 7481 includeZone = _ref7$includeZone === void 0 ? false : _ref7$includeZone, 7482 _ref7$includeOffsetSp = _ref7.includeOffsetSpace, 7483 includeOffsetSpace = _ref7$includeOffsetSp === void 0 ? true : _ref7$includeOffsetSp; 7484 7485 var fmt = "HH:mm:ss.SSS"; 7486 7487 if (includeZone || includeOffset) { 7488 if (includeOffsetSpace) { 7489 fmt += " "; 7490 } 7491 7492 if (includeZone) { 7493 fmt += "z"; 7494 } else if (includeOffset) { 7495 fmt += "ZZ"; 7496 } 7497 } 7498 7499 return toTechFormat(this, fmt, true); 7500 } 7501 /** 7502 * Returns a string representation of this DateTime appropriate for use in SQL DateTime
7503 * @param {Object} opts - options 7504 * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset. 7505 * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00' 7506 * @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00' 7507 * @example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z' 7508 * @example DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00' 7509 * @example DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000' 7510 * @example DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York' 7511 * @return {string} 7512 */ 7513 ; 7514 7515 _proto.toSQL = function toSQL(opts) { 7516 if (opts === void 0) { 7517 opts = {}; 7518 } 7519 7520 if (!this.isValid) { 7521 return null; 7522 } 7523 7524 return this.toSQLDate() + " " + this.toSQLTime(opts); 7525 } 7526 /** 7527 * Returns a string representation of this DateTime appropriate for debugging 7528 * @return {string} 7529 */ 7530 ; 7531 7532 _proto.toString = function toString() { 7533 return this.isValid ? this.toISO() : INVALID; 7534 } 7535 /** 7536 * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime#toMillis} 7537 * @return {number} 7538 */ 7539 ; 7540 7541 _proto.valueOf = function valueOf() { 7542 return this.toMillis(); 7543 } 7544 /** 7545 * Returns the epoch milliseconds of this DateTime. 7546 * @return {number} 7547 */ 7548 ; 7549 7550 _proto.toMillis = function toMillis() { 7551 return this.isValid ? this.ts : NaN; 7552 } 7553 /** 7554 * Returns the epoch seconds of this DateTime. 7555 * @return {number} 7556 */ 7557 ; 7558 7559 _proto.toSeconds = function toSeconds() { 7560 return this.isValid ? this.ts / 1000 : NaN; 7561 } 7562 /** 7563 * Returns the epoch seconds (as a whole number) of this DateTime. 7564 * @return {number} 7565 */ 7566 ; 7567 7568 _proto.toUnixInteger = function toUnixInteger() { 7569 return this.isValid ? Math.floor(this.ts / 1000) : NaN; 7570 } 7571 /** 7572 * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON. 7573 * @return {string} 7574 */ 7575 ; 7576 7577 _proto.toJSON = function toJSON() { 7578 return this.toISO(); 7579 } 7580 /** 7581 * Returns a BSON serializable equivalent to this DateTime. 7582 * @return {Date} 7583 */ 7584 ; 7585 7586 _proto.toBSON = function toBSON() { 7587 return this.toJSDate(); 7588 } 7589 /** 7590 * Returns a JavaScript object with this DateTime's year, month, day, and so on. 7591 * @param opts - options for generating the object 7592 * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output 7593 * @example DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 } 7594 * @return {Object} 7595 */ 7596 ; 7597 7598 _proto.toObject = function toObject(opts) { 7599 if (opts === void 0) { 7600 opts = {}; 7601 } 7602 7603 if (!this.isValid) return {}; 7604 7605 var base = _extends({}, this.c); 7606 7607 if (opts.includeConfig) { 7608 base.outputCalendar = this.outputCalendar; 7609 base.numberingSystem = this.loc.numberingSystem; 7610 base.locale = this.loc.locale; 7611 } 7612 7613 return base; 7614 } 7615 /** 7616 * Returns a JavaScript Date equivalent to this DateTime. 7617 * @return {Date} 7618 */ 7619 ; 7620 7621 _proto.toJSDate = function toJSDate() { 7622 return new Date(this.isValid ? this.ts : NaN); 7623 } // COMPARE 7624 7625 /** 7626 * Return the difference between two DateTimes as a Duration. 7627 * @param {DateTime} otherDateTime - the DateTime to compare this one to 7628 * @param {string|string[]} [unit=['milliseconds']] - the unit or array of units (such as 'hours' or 'days') to include in the duration. 7629 * @param {Object} opts - options that affect the creation of the Duration 7630 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 7631 * @example 7632 * var i1 = DateTime.fromISO('1982-05-25T09:45'), 7633 * i2 = DateTime.fromISO('1983-10-14T10:30'); 7634 * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 } 7635 * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 } 7636 * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 } 7637 * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 } 7638 * @return {Duration} 7639 */ 7640 ; 7641 7642 _proto.diff = function diff(otherDateTime, unit, opts) { 7643 if (unit === void 0) { 7644 unit = "milliseconds"; 7645 } 7646 7647 if (opts === void 0) { 7648 opts = {}; 7649 } 7650 7651 if (!this.isValid || !otherDateTime.isValid) {
vendor: 4,267 bytes, lines 7652-7739
7652 return Duration.invalid("created by diffing an invalid DateTime"); 7653 } 7654 7655 var durOpts = _extends({ 7656 locale: this.locale, 7657 numberingSystem: this.numberingSystem 7658 }, opts); 7659 7660 var units = maybeArray(unit).map(Duration.normalizeUnit), 7661 otherIsLater = otherDateTime.valueOf() > this.valueOf(), 7662 earlier = otherIsLater ? this : otherDateTime, 7663 later = otherIsLater ? otherDateTime : this, 7664 diffed = _diff(earlier, later, units, durOpts); 7665 7666 return otherIsLater ? diffed.negate() : diffed; 7667 } 7668 /** 7669 * Return the difference between this DateTime and right now. 7670 * See {@link DateTime#diff} 7671 * @param {string|string[]} [unit=['milliseconds']] - the unit or units units (such as 'hours' or 'days') to include in the duration 7672 * @param {Object} opts - options that affect the creation of the Duration 7673 * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use 7674 * @return {Duration} 7675 */ 7676 ; 7677 7678 _proto.diffNow = function diffNow(unit, opts) { 7679 if (unit === void 0) { 7680 unit = "milliseconds"; 7681 } 7682 7683 if (opts === void 0) { 7684 opts = {}; 7685 } 7686 7687 return this.diff(DateTime.now(), unit, opts); 7688 } 7689 /** 7690 * Return an Interval spanning between this DateTime and another DateTime 7691 * @param {DateTime} otherDateTime - the other end point of the Interval 7692 * @return {Interval} 7693 */ 7694 ; 7695 7696 _proto.until = function until(otherDateTime) { 7697 return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this; 7698 } 7699 /** 7700 * Return whether this DateTime is in the same unit of time as another DateTime. 7701 * Higher-order units must also be identical for this function to return `true`. 7702 * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime#setZone} to convert one of the dates if needed. 7703 * @param {DateTime} otherDateTime - the other DateTime 7704 * @param {string} unit - the unit of time to check sameness on 7705 * @example DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day 7706 * @return {boolean} 7707 */ 7708 ; 7709 7710 _proto.hasSame = function hasSame(otherDateTime, unit) { 7711 if (!this.isValid) return false; 7712 var inputMs = otherDateTime.valueOf(); 7713 var adjustedToZone = this.setZone(otherDateTime.zone, { 7714 keepLocalTime: true 7715 }); 7716 return adjustedToZone.startOf(unit) <= inputMs && inputMs <= adjustedToZone.endOf(unit); 7717 } 7718 /** 7719 * Equality check 7720 * Two DateTimes are equal iff they represent the same millisecond, have the same zone and location, and are both valid. 7721 * To compare just the millisecond values, use `+dt1 === +dt2`. 7722 * @param {DateTime} other - the other DateTime 7723 * @return {boolean} 7724 */ 7725 ; 7726 7727 _proto.equals = function equals(other) { 7728 return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc); 7729 } 7730 /** 7731 * Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your 7732 * platform supports Intl.RelativeTimeFormat. Rounds down by default. 7733 * @param {Object} options - options that affect the output 7734 * @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now. 7735 * @param {string} [options.style="long"] - the style of units, must be "long", "short", or "narrow" 7736 * @param {string|string[]} options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds" 7737 * @param {boolean} [options.round=true] - whether to round the numbers in the output. 7738 * @param {number} [options.padding=0] - padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding. 7739 * @param {string} options.locale - override the locale of this DateTime
7740 * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this 7741 * @example DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day" 7742 * @example DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 dÃa" 7743 * @example DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures" 7744 * @example DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago" 7745 * @example DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago" 7746 * @example DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago" 7747 */ 7748 ; 7749 7750 _proto.toRelative = function toRelative(options) { 7751 if (options === void 0) { 7752 options = {}; 7753 } 7754 7755 if (!this.isValid) return null; 7756 var base = options.base || DateTime.fromObject({}, { 7757 zone: this.zone 7758 }), 7759 padding = options.padding ? this < base ? -options.padding : options.padding : 0; 7760 var units = ["years", "months", "days", "hours", "minutes", "seconds"]; 7761 var unit = options.unit; 7762 7763 if (Array.isArray(options.unit)) { 7764 units = options.unit; 7765 unit = undefined; 7766 } 7767 7768 return diffRelative(base, this.plus(padding), _extends({}, options, { 7769 numeric: "always", 7770 units: units, 7771 unit: unit 7772 })); 7773 } 7774 /** 7775 * Returns a string representation of this date relative to today, such as "yesterday" or "next month". 7776 * Only internationalizes on platforms that supports Intl.RelativeTimeFormat. 7777 * @param {Object} options - options that affect the output 7778 * @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now. 7779 * @param {string} options.locale - override the locale of this DateTime 7780 * @param {string} options.unit - use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days" 7781 * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this 7782 * @example DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow" 7783 * @example DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana" 7784 * @example DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain" 7785 * @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago" 7786 */ 7787 ; 7788 7789 _proto.toRelativeCalendar = function toRelativeCalendar(options) { 7790 if (options === void 0) { 7791 options = {}; 7792 } 7793 7794 if (!this.isValid) return null; 7795 return diffRelative(options.base || DateTime.fromObject({}, { 7796 zone: this.zone 7797 }), this, _extends({}, options, { 7798 numeric: "auto", 7799 units: ["years", "months", "days"], 7800 calendary: true 7801 })); 7802 } 7803 /** 7804 * Return the min of several date times 7805 * @param {...DateTime} dateTimes - the DateTimes from which to choose the minimum 7806 * @return {DateTime} the min DateTime, or undefined if called with no argument 7807 */ 7808 ; 7809 7810 DateTime.min = function min() { 7811 for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) { 7812 dateTimes[_key] = arguments[_key]; 7813 } 7814 7815 if (!dateTimes.every(DateTime.isDateTime)) { 7816 throw new InvalidArgumentError("min requires all arguments be DateTimes"); 7817 } 7818 7819 return bestBy(dateTimes, function (i) { 7820 return i.valueOf(); 7821 }, Math.min); 7822 } 7823 /** 7824 * Return the max of several date times 7825 * @param {...DateTime} dateTimes - the DateTimes from which to choose the maximum 7826 * @return {DateTime} the max DateTime, or undefined if called with no argument 7827 */ 7828 ; 7829 7830 DateTime.max = function max() { 7831 for (var _len2 = arguments.length, dateTimes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 7832 dateTimes[_key2] = arguments[_key2]; 7833 } 7834 7835 if (!dateTimes.every(DateTime.isDateTime)) { 7836 throw new InvalidArgumentError("max requires all arguments be DateTimes"); 7837 } 7838 7839 return bestBy(dateTimes, function (i) { 7840 return i.valueOf(); 7841 }, Math.max); 7842 } // MISC 7843 7844 /** 7845 * Explain how a string would be parsed by fromFormat() 7846 * @param {string} text - the string to parse 7847 * @param {string} fmt - the format the string is expected to be in (see description) 7848 * @param {Object} options - options taken by fromFormat() 7849 * @return {Object} 7850 */ 7851 ; 7852 7853 DateTime.fromFormatExplain = function fromFormatExplain(text, fmt, options) { 7854 if (options === void 0) { 7855 options = {}; 7856 } 7857 7858 var _options = options, 7859 _options$locale = _options.locale, 7860 locale = _options$locale === void 0 ? null : _options$locale, 7861 _options$numberingSys = _options.numberingSystem, 7862 numberingSystem = _options$numberingSys === void 0 ? null : _options$numberingSys, 7863 localeToUse = Locale.fromOpts({ 7864 locale: locale, 7865 numberingSystem: numberingSystem, 7866 defaultToEN: true 7867 }); 7868 return explainFromTokens(localeToUse, text, fmt); 7869 } 7870 /** 7871 * @deprecated use fromFormatExplain instead 7872 */ 7873 ; 7874 7875 DateTime.fromStringExplain = function fromStringExplain(text, fmt, options) { 7876 if (options === void 0) { 7877 options = {}; 7878 } 7879 7880 return DateTime.fromFormatExplain(text, fmt, options); 7881 } // FORMAT PRESETS 7882 7883 /**
7884 * {@link DateTime#toLocaleString} format like 10/14/1983 7885 * @type {Object} 7886 */ 7887 ; 7888 7889 _createClass(DateTime, [{ 7890 key: "isValid", 7891 get: function get() { 7892 return this.invalid === null; 7893 } 7894 /** 7895 * Returns an error code if this DateTime is invalid, or null if the DateTime is valid 7896 * @type {string} 7897 */ 7898 7899 }, { 7900 key: "invalidReason", 7901 get: function get() { 7902 return this.invalid ? this.invalid.reason : null; 7903 } 7904 /** 7905 * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid 7906 * @type {string} 7907 */ 7908 7909 }, { 7910 key: "invalidExplanation", 7911 get: function get() { 7912 return this.invalid ? this.invalid.explanation : null; 7913 } 7914 /** 7915 * Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime 7916 * 7917 * @type {string} 7918 */ 7919 7920 }, { 7921 key: "locale", 7922 get: function get() { 7923 return this.isValid ? this.loc.locale : null; 7924 } 7925 /** 7926 * Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime 7927 * 7928 * @type {string} 7929 */ 7930 7931 }, { 7932 key: "numberingSystem", 7933 get: function get() { 7934 return this.isValid ? this.loc.numberingSystem : null; 7935 } 7936 /** 7937 * Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime 7938 * 7939 * @type {string} 7940 */ 7941 7942 }, { 7943 key: "outputCalendar", 7944 get: function get() { 7945 return this.isValid ? this.loc.outputCalendar : null; 7946 } 7947 /** 7948 * Get the time zone associated with this DateTime. 7949 * @type {Zone} 7950 */ 7951 7952 }, { 7953 key: "zone", 7954 get: function get() { 7955 return this._zone; 7956 } 7957 /** 7958 * Get the name of the time zone. 7959 * @type {string} 7960 */ 7961 7962 }, { 7963 key: "zoneName", 7964 get: function get() { 7965 return this.isValid ? this.zone.name : null; 7966 } 7967 /** 7968 * Get the year 7969 * @example DateTime.local(2017, 5, 25).year //=> 2017 7970 * @type {number} 7971 */ 7972 7973 }, { 7974 key: "year", 7975 get: function get() { 7976 return this.isValid ? this.c.year : NaN; 7977 } 7978 /** 7979 * Get the quarter 7980 * @example DateTime.local(2017, 5, 25).quarter //=> 2 7981 * @type {number} 7982 */ 7983 7984 }, { 7985 key: "quarter", 7986 get: function get() { 7987 return this.isValid ? Math.ceil(this.c.month / 3) : NaN; 7988 } 7989 /** 7990 * Get the month (1-12). 7991 * @example DateTime.local(2017, 5, 25).month //=> 5 7992 * @type {number} 7993 */ 7994 7995 }, { 7996 key: "month", 7997 get: function get() { 7998 return this.isValid ? this.c.month : NaN; 7999 } 8000 /** 8001 * Get the day of the month (1-30ish). 8002 * @example DateTime.local(2017, 5, 25).day //=> 25 8003 * @type {number} 8004 */ 8005 8006 }, { 8007 key: "day", 8008 get: function get() { 8009 return this.isValid ? this.c.day : NaN; 8010 } 8011 /** 8012 * Get the hour of the day (0-23). 8013 * @example DateTime.local(2017, 5, 25, 9).hour //=> 9 8014 * @type {number} 8015 */ 8016 8017 }, { 8018 key: "hour", 8019 get: function get() { 8020 return this.isValid ? this.c.hour : NaN; 8021 } 8022 /** 8023 * Get the minute of the hour (0-59). 8024 * @example DateTime.local(2017, 5, 25, 9, 30).minute //=> 30 8025 * @type {number} 8026 */ 8027 8028 }, { 8029 key: "minute", 8030 get: function get() { 8031 return this.isValid ? this.c.minute : NaN; 8032 } 8033 /** 8034 * Get the second of the minute (0-59). 8035 * @example DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52 8036 * @type {number} 8037 */ 8038 8039 }, { 8040 key: "second", 8041 get: function get() { 8042 return this.isValid ? this.c.second : NaN; 8043 } 8044 /** 8045 * Get the millisecond of the second (0-999). 8046 * @example DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654 8047 * @type {number} 8048 */ 8049 8050 }, { 8051 key: "millisecond", 8052 get: function get() { 8053 return this.isValid ? this.c.millisecond : NaN; 8054 } 8055 /** 8056 * Get the week year 8057 * @see https://en.wikipedia.org/wiki/ISO_week_date 8058 * @example DateTime.local(2014, 12, 31).weekYear //=> 2015 8059 * @type {number} 8060 */ 8061 8062 }, {
vendor: 4,390 bytes, lines 8063-8212
8063 key: "weekYear", 8064 get: function get() { 8065 return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN; 8066 } 8067 /** 8068 * Get the week number of the week year (1-52ish). 8069 * @see https://en.wikipedia.org/wiki/ISO_week_date 8070 * @example DateTime.local(2017, 5, 25).weekNumber //=> 21 8071 * @type {number} 8072 */ 8073 8074 }, { 8075 key: "weekNumber", 8076 get: function get() { 8077 return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN; 8078 } 8079 /** 8080 * Get the day of the week. 8081 * 1 is Monday and 7 is Sunday 8082 * @see https://en.wikipedia.org/wiki/ISO_week_date 8083 * @example DateTime.local(2014, 11, 31).weekday //=> 4 8084 * @type {number} 8085 */ 8086 8087 }, { 8088 key: "weekday", 8089 get: function get() { 8090 return this.isValid ? possiblyCachedWeekData(this).weekday : NaN; 8091 } 8092 /** 8093 * Get the ordinal (meaning the day of the year) 8094 * @example DateTime.local(2017, 5, 25).ordinal //=> 145 8095 * @type {number|DateTime} 8096 */ 8097 8098 }, { 8099 key: "ordinal", 8100 get: function get() { 8101 return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN; 8102 } 8103 /** 8104 * Get the human readable short month name, such as 'Oct'. 8105 * Defaults to the system's locale if no locale has been specified 8106 * @example DateTime.local(2017, 10, 30).monthShort //=> Oct 8107 * @type {string} 8108 */ 8109 8110 }, { 8111 key: "monthShort", 8112 get: function get() { 8113 return this.isValid ? Info.months("short", { 8114 locObj: this.loc 8115 })[this.month - 1] : null; 8116 } 8117 /** 8118 * Get the human readable long month name, such as 'October'. 8119 * Defaults to the system's locale if no locale has been specified 8120 * @example DateTime.local(2017, 10, 30).monthLong //=> October 8121 * @type {string} 8122 */ 8123 8124 }, { 8125 key: "monthLong", 8126 get: function get() { 8127 return this.isValid ? Info.months("long", { 8128 locObj: this.loc 8129 })[this.month - 1] : null; 8130 } 8131 /** 8132 * Get the human readable short weekday, such as 'Mon'. 8133 * Defaults to the system's locale if no locale has been specified 8134 * @example DateTime.local(2017, 10, 30).weekdayShort //=> Mon 8135 * @type {string} 8136 */ 8137 8138 }, { 8139 key: "weekdayShort", 8140 get: function get() { 8141 return this.isValid ? Info.weekdays("short", { 8142 locObj: this.loc 8143 })[this.weekday - 1] : null; 8144 } 8145 /** 8146 * Get the human readable long weekday, such as 'Monday'. 8147 * Defaults to the system's locale if no locale has been specified 8148 * @example DateTime.local(2017, 10, 30).weekdayLong //=> Monday 8149 * @type {string} 8150 */ 8151 8152 }, { 8153 key: "weekdayLong", 8154 get: function get() { 8155 return this.isValid ? Info.weekdays("long", { 8156 locObj: this.loc 8157 })[this.weekday - 1] : null; 8158 } 8159 /** 8160 * Get the UTC offset of this DateTime in minutes 8161 * @example DateTime.now().offset //=> -240 8162 * @example DateTime.utc().offset //=> 0 8163 * @type {number} 8164 */ 8165 8166 }, { 8167 key: "offset", 8168 get: function get() { 8169 return this.isValid ? +this.o : NaN; 8170 } 8171 /** 8172 * Get the short human name for the zone's current offset, for example "EST" or "EDT". 8173 * Defaults to the system's locale if no locale has been specified 8174 * @type {string} 8175 */ 8176 8177 }, { 8178 key: "offsetNameShort", 8179 get: function get() { 8180 if (this.isValid) { 8181 return this.zone.offsetName(this.ts, { 8182 format: "short", 8183 locale: this.locale 8184 }); 8185 } else { 8186 return null; 8187 } 8188 } 8189 /** 8190 * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time". 8191 * Defaults to the system's locale if no locale has been specified 8192 * @type {string} 8193 */ 8194 8195 }, { 8196 key: "offsetNameLong", 8197 get: function get() { 8198 if (this.isValid) { 8199 return this.zone.offsetName(this.ts, { 8200 format: "long", 8201 locale: this.locale 8202 }); 8203 } else { 8204 return null; 8205 } 8206 } 8207 /** 8208 * Get whether this zone's offset ever changes, as in a DST. 8209 * @type {boolean} 8210 */ 8211 8212 }, {
vendor: 4,068 bytes, lines 8213-8370
8213 key: "isOffsetFixed", 8214 get: function get() { 8215 return this.isValid ? this.zone.isUniversal : null; 8216 } 8217 /** 8218 * Get whether the DateTime is in a DST. 8219 * @type {boolean} 8220 */ 8221 8222 }, { 8223 key: "isInDST", 8224 get: function get() { 8225 if (this.isOffsetFixed) { 8226 return false; 8227 } else { 8228 return this.offset > this.set({ 8229 month: 1, 8230 day: 1 8231 }).offset || this.offset > this.set({ 8232 month: 5 8233 }).offset; 8234 } 8235 } 8236 /** 8237 * Returns true if this DateTime is in a leap year, false otherwise 8238 * @example DateTime.local(2016).isInLeapYear //=> true 8239 * @example DateTime.local(2013).isInLeapYear //=> false 8240 * @type {boolean} 8241 */ 8242 8243 }, { 8244 key: "isInLeapYear", 8245 get: function get() { 8246 return isLeapYear(this.year); 8247 } 8248 /** 8249 * Returns the number of days in this DateTime's month 8250 * @example DateTime.local(2016, 2).daysInMonth //=> 29 8251 * @example DateTime.local(2016, 3).daysInMonth //=> 31 8252 * @type {number} 8253 */ 8254 8255 }, { 8256 key: "daysInMonth", 8257 get: function get() { 8258 return daysInMonth(this.year, this.month); 8259 } 8260 /** 8261 * Returns the number of days in this DateTime's year 8262 * @example DateTime.local(2016).daysInYear //=> 366 8263 * @example DateTime.local(2013).daysInYear //=> 365 8264 * @type {number} 8265 */ 8266 8267 }, { 8268 key: "daysInYear", 8269 get: function get() { 8270 return this.isValid ? daysInYear(this.year) : NaN; 8271 } 8272 /** 8273 * Returns the number of weeks in this DateTime's year 8274 * @see https://en.wikipedia.org/wiki/ISO_week_date 8275 * @example DateTime.local(2004).weeksInWeekYear //=> 53 8276 * @example DateTime.local(2013).weeksInWeekYear //=> 52 8277 * @type {number} 8278 */ 8279 8280 }, { 8281 key: "weeksInWeekYear", 8282 get: function get() { 8283 return this.isValid ? weeksInWeekYear(this.weekYear) : NaN; 8284 } 8285 }], [{ 8286 key: "DATE_SHORT", 8287 get: function get() { 8288 return DATE_SHORT; 8289 } 8290 /** 8291 * {@link DateTime#toLocaleString} format like 'Oct 14, 1983' 8292 * @type {Object} 8293 */ 8294 8295 }, { 8296 key: "DATE_MED", 8297 get: function get() { 8298 return DATE_MED; 8299 } 8300 /** 8301 * {@link DateTime#toLocaleString} format like 'Fri, Oct 14, 1983' 8302 * @type {Object} 8303 */ 8304 8305 }, { 8306 key: "DATE_MED_WITH_WEEKDAY", 8307 get: function get() { 8308 return DATE_MED_WITH_WEEKDAY; 8309 } 8310 /** 8311 * {@link DateTime#toLocaleString} format like 'October 14, 1983' 8312 * @type {Object} 8313 */ 8314 8315 }, { 8316 key: "DATE_FULL", 8317 get: function get() { 8318 return DATE_FULL; 8319 } 8320 /** 8321 * {@link DateTime#toLocaleString} format like 'Tuesday, October 14, 1983' 8322 * @type {Object} 8323 */ 8324 8325 }, { 8326 key: "DATE_HUGE", 8327 get: function get() { 8328 return DATE_HUGE; 8329 } 8330 /** 8331 * {@link DateTime#toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is. 8332 * @type {Object} 8333 */ 8334 8335 }, { 8336 key: "TIME_SIMPLE", 8337 get: function get() { 8338 return TIME_SIMPLE; 8339 } 8340 /** 8341 * {@link DateTime#toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is. 8342 * @type {Object} 8343 */ 8344 8345 }, { 8346 key: "TIME_WITH_SECONDS", 8347 get: function get() { 8348 return TIME_WITH_SECONDS; 8349 } 8350 /** 8351 * {@link DateTime#toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is. 8352 * @type {Object} 8353 */ 8354 8355 }, { 8356 key: "TIME_WITH_SHORT_OFFSET", 8357 get: function get() { 8358 return TIME_WITH_SHORT_OFFSET; 8359 } 8360 /** 8361 * {@link DateTime#toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is. 8362 * @type {Object} 8363 */ 8364 8365 }, { 8366 key: "TIME_WITH_LONG_OFFSET", 8367 get: function get() { 8368 return TIME_WITH_LONG_OFFSET; 8369 } 8370 /**
8371 * {@link DateTime#toLocaleString} format like '09:30', always 24-hour. 8372 * @type {Object} 8373 */ 8374 8375 }, { 8376 key: "TIME_24_SIMPLE", 8377 get: function get() { 8378 return TIME_24_SIMPLE; 8379 } 8380 /** 8381 * {@link DateTime#toLocaleString} format like '09:30:23', always 24-hour. 8382 * @type {Object} 8383 */ 8384 8385 }, { 8386 key: "TIME_24_WITH_SECONDS", 8387 get: function get() { 8388 return TIME_24_WITH_SECONDS; 8389 } 8390 /** 8391 * {@link DateTime#toLocaleString} format like '09:30:23 EDT', always 24-hour. 8392 * @type {Object} 8393 */ 8394 8395 }, { 8396 key: "TIME_24_WITH_SHORT_OFFSET", 8397 get: function get() { 8398 return TIME_24_WITH_SHORT_OFFSET; 8399 } 8400 /** 8401 * {@link DateTime#toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour. 8402 * @type {Object} 8403 */ 8404 8405 }, { 8406 key: "TIME_24_WITH_LONG_OFFSET", 8407 get: function get() { 8408 return TIME_24_WITH_LONG_OFFSET; 8409 } 8410 /** 8411 * {@link DateTime#toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is. 8412 * @type {Object} 8413 */ 8414 8415 }, { 8416 key: "DATETIME_SHORT", 8417 get: function get() { 8418 return DATETIME_SHORT; 8419 } 8420 /** 8421 * {@link DateTime#toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is. 8422 * @type {Object} 8423 */ 8424 8425 }, { 8426 key: "DATETIME_SHORT_WITH_SECONDS", 8427 get: function get() { 8428 return DATETIME_SHORT_WITH_SECONDS; 8429 } 8430 /** 8431 * {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is. 8432 * @type {Object} 8433 */ 8434 8435 }, { 8436 key: "DATETIME_MED", 8437 get: function get() { 8438 return DATETIME_MED; 8439 } 8440 /** 8441 * {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is. 8442 * @type {Object} 8443 */ 8444 8445 }, { 8446 key: "DATETIME_MED_WITH_SECONDS", 8447 get: function get() { 8448 return DATETIME_MED_WITH_SECONDS; 8449 } 8450 /** 8451 * {@link DateTime#toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is. 8452 * @type {Object} 8453 */ 8454 8455 }, { 8456 key: "DATETIME_MED_WITH_WEEKDAY", 8457 get: function get() { 8458 return DATETIME_MED_WITH_WEEKDAY; 8459 } 8460 /** 8461 * {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is. 8462 * @type {Object} 8463 */ 8464 8465 }, { 8466 key: "DATETIME_FULL", 8467 get: function get() { 8468 return DATETIME_FULL; 8469 } 8470 /** 8471 * {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is. 8472 * @type {Object} 8473 */ 8474 8475 }, { 8476 key: "DATETIME_FULL_WITH_SECONDS", 8477 get: function get() { 8478 return DATETIME_FULL_WITH_SECONDS; 8479 } 8480 /** 8481 * {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is. 8482 * @type {Object} 8483 */ 8484 8485 }, { 8486 key: "DATETIME_HUGE", 8487 get: function get() { 8488 return DATETIME_HUGE; 8489 } 8490 /** 8491 * {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is. 8492 * @type {Object} 8493 */ 8494 8495 }, { 8496 key: "DATETIME_HUGE_WITH_SECONDS", 8497 get: function get() { 8498 return DATETIME_HUGE_WITH_SECONDS; 8499 } 8500 }]); 8501 8502 return DateTime; 8503 }(); 8504 function friendlyDateTime(dateTimeish) { 8505 if (DateTime.isDateTime(dateTimeish)) { 8506 return dateTimeish; 8507 } else if (dateTimeish && dateTimeish.valueOf && isNumber(dateTimeish.valueOf())) { 8508 return DateTime.fromJSDate(dateTimeish); 8509 } else if (dateTimeish && typeof dateTimeish === "object") { 8510 return DateTime.fromObject(dateTimeish); 8511 } else { 8512 throw new InvalidArgumentError("Unknown datetime argument: " + dateTimeish + ", of type " + typeof dateTimeish); 8513 } 8514 } 8515 8516 var VERSION = "2.4.0"; 8517 8518 exports.DateTime = DateTime; 8519 exports.Duration = Duration; 8520 exports.FixedOffsetZone = FixedOffsetZone; 8521 exports.IANAZone = IANAZone; 8522 exports.Info = Info; 8523 exports.Interval = Interval; 8524 exports.InvalidZone = InvalidZone; 8525 exports.Settings = Settings; 8526 exports.SystemZone = SystemZone; 8527 exports.VERSION = VERSION; 8528 exports.Zone = Zone; 8529 8530 Object.defineProperty(exports, '__esModule', { value: true }); 8531 8532 return exports; 8533 8534})({}); 8535//# sourceMappingURL=luxon.js.map
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.