@punks/backend-core 0.0.66 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -28410,6 +28410,2426 @@ exports.build = build;
28410
28410
  exports.default = { parse: exports.parse, parseMetadata: exports.parseMetadata, build: exports.build };
28411
28411
  }(lib));
28412
28412
 
28413
+ function toInteger(dirtyNumber) {
28414
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
28415
+ return NaN;
28416
+ }
28417
+
28418
+ var number = Number(dirtyNumber);
28419
+
28420
+ if (isNaN(number)) {
28421
+ return number;
28422
+ }
28423
+
28424
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
28425
+ }
28426
+
28427
+ function requiredArgs(required, args) {
28428
+ if (args.length < required) {
28429
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
28430
+ }
28431
+ }
28432
+
28433
+ /**
28434
+ * @name toDate
28435
+ * @category Common Helpers
28436
+ * @summary Convert the given argument to an instance of Date.
28437
+ *
28438
+ * @description
28439
+ * Convert the given argument to an instance of Date.
28440
+ *
28441
+ * If the argument is an instance of Date, the function returns its clone.
28442
+ *
28443
+ * If the argument is a number, it is treated as a timestamp.
28444
+ *
28445
+ * If the argument is none of the above, the function returns Invalid Date.
28446
+ *
28447
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
28448
+ *
28449
+ * @param {Date|Number} argument - the value to convert
28450
+ * @returns {Date} the parsed date in the local time zone
28451
+ * @throws {TypeError} 1 argument required
28452
+ *
28453
+ * @example
28454
+ * // Clone the date:
28455
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
28456
+ * //=> Tue Feb 11 2014 11:30:30
28457
+ *
28458
+ * @example
28459
+ * // Convert the timestamp to date:
28460
+ * const result = toDate(1392098430000)
28461
+ * //=> Tue Feb 11 2014 11:30:30
28462
+ */
28463
+
28464
+ function toDate(argument) {
28465
+ requiredArgs(1, arguments);
28466
+ var argStr = Object.prototype.toString.call(argument); // Clone the date
28467
+
28468
+ if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
28469
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
28470
+ return new Date(argument.getTime());
28471
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
28472
+ return new Date(argument);
28473
+ } else {
28474
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
28475
+ // eslint-disable-next-line no-console
28476
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
28477
+
28478
+ console.warn(new Error().stack);
28479
+ }
28480
+
28481
+ return new Date(NaN);
28482
+ }
28483
+ }
28484
+
28485
+ /**
28486
+ * @name addDays
28487
+ * @category Day Helpers
28488
+ * @summary Add the specified number of days to the given date.
28489
+ *
28490
+ * @description
28491
+ * Add the specified number of days to the given date.
28492
+ *
28493
+ * ### v2.0.0 breaking changes:
28494
+ *
28495
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
28496
+ *
28497
+ * @param {Date|Number} date - the date to be changed
28498
+ * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
28499
+ * @returns {Date} the new date with the days added
28500
+ * @throws {TypeError} 2 arguments required
28501
+ *
28502
+ * @example
28503
+ * // Add 10 days to 1 September 2014:
28504
+ * var result = addDays(new Date(2014, 8, 1), 10)
28505
+ * //=> Thu Sep 11 2014 00:00:00
28506
+ */
28507
+
28508
+ function addDays(dirtyDate, dirtyAmount) {
28509
+ requiredArgs(2, arguments);
28510
+ var date = toDate(dirtyDate);
28511
+ var amount = toInteger(dirtyAmount);
28512
+
28513
+ if (isNaN(amount)) {
28514
+ return new Date(NaN);
28515
+ }
28516
+
28517
+ if (!amount) {
28518
+ // If 0 days, no-op to avoid changing times in the hour before end of DST
28519
+ return date;
28520
+ }
28521
+
28522
+ date.setDate(date.getDate() + amount);
28523
+ return date;
28524
+ }
28525
+
28526
+ /**
28527
+ * @name addMilliseconds
28528
+ * @category Millisecond Helpers
28529
+ * @summary Add the specified number of milliseconds to the given date.
28530
+ *
28531
+ * @description
28532
+ * Add the specified number of milliseconds to the given date.
28533
+ *
28534
+ * ### v2.0.0 breaking changes:
28535
+ *
28536
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
28537
+ *
28538
+ * @param {Date|Number} date - the date to be changed
28539
+ * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
28540
+ * @returns {Date} the new date with the milliseconds added
28541
+ * @throws {TypeError} 2 arguments required
28542
+ *
28543
+ * @example
28544
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
28545
+ * var result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
28546
+ * //=> Thu Jul 10 2014 12:45:30.750
28547
+ */
28548
+
28549
+ function addMilliseconds(dirtyDate, dirtyAmount) {
28550
+ requiredArgs(2, arguments);
28551
+ var timestamp = toDate(dirtyDate).getTime();
28552
+ var amount = toInteger(dirtyAmount);
28553
+ return new Date(timestamp + amount);
28554
+ }
28555
+
28556
+ var MILLISECONDS_IN_MINUTE = 60000;
28557
+
28558
+ function getDateMillisecondsPart(date) {
28559
+ return date.getTime() % MILLISECONDS_IN_MINUTE;
28560
+ }
28561
+ /**
28562
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
28563
+ * They usually appear for dates that denote time before the timezones were introduced
28564
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
28565
+ * and GMT+01:00:00 after that date)
28566
+ *
28567
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
28568
+ * which would lead to incorrect calculations.
28569
+ *
28570
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
28571
+ */
28572
+
28573
+
28574
+ function getTimezoneOffsetInMilliseconds(dirtyDate) {
28575
+ var date = new Date(dirtyDate.getTime());
28576
+ var baseTimezoneOffset = Math.ceil(date.getTimezoneOffset());
28577
+ date.setSeconds(0, 0);
28578
+ var hasNegativeUTCOffset = baseTimezoneOffset > 0;
28579
+ var millisecondsPartOfTimezoneOffset = hasNegativeUTCOffset ? (MILLISECONDS_IN_MINUTE + getDateMillisecondsPart(date)) % MILLISECONDS_IN_MINUTE : getDateMillisecondsPart(date);
28580
+ return baseTimezoneOffset * MILLISECONDS_IN_MINUTE + millisecondsPartOfTimezoneOffset;
28581
+ }
28582
+
28583
+ /**
28584
+ * @name isValid
28585
+ * @category Common Helpers
28586
+ * @summary Is the given date valid?
28587
+ *
28588
+ * @description
28589
+ * Returns false if argument is Invalid Date and true otherwise.
28590
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
28591
+ * Invalid Date is a Date, whose time value is NaN.
28592
+ *
28593
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
28594
+ *
28595
+ * ### v2.0.0 breaking changes:
28596
+ *
28597
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
28598
+ *
28599
+ * - Now `isValid` doesn't throw an exception
28600
+ * if the first argument is not an instance of Date.
28601
+ * Instead, argument is converted beforehand using `toDate`.
28602
+ *
28603
+ * Examples:
28604
+ *
28605
+ * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
28606
+ * |---------------------------|---------------|---------------|
28607
+ * | `new Date()` | `true` | `true` |
28608
+ * | `new Date('2016-01-01')` | `true` | `true` |
28609
+ * | `new Date('')` | `false` | `false` |
28610
+ * | `new Date(1488370835081)` | `true` | `true` |
28611
+ * | `new Date(NaN)` | `false` | `false` |
28612
+ * | `'2016-01-01'` | `TypeError` | `false` |
28613
+ * | `''` | `TypeError` | `false` |
28614
+ * | `1488370835081` | `TypeError` | `true` |
28615
+ * | `NaN` | `TypeError` | `false` |
28616
+ *
28617
+ * We introduce this change to make *date-fns* consistent with ECMAScript behavior
28618
+ * that try to coerce arguments to the expected type
28619
+ * (which is also the case with other *date-fns* functions).
28620
+ *
28621
+ * @param {*} date - the date to check
28622
+ * @returns {Boolean} the date is valid
28623
+ * @throws {TypeError} 1 argument required
28624
+ *
28625
+ * @example
28626
+ * // For the valid date:
28627
+ * var result = isValid(new Date(2014, 1, 31))
28628
+ * //=> true
28629
+ *
28630
+ * @example
28631
+ * // For the value, convertable into a date:
28632
+ * var result = isValid(1393804800000)
28633
+ * //=> true
28634
+ *
28635
+ * @example
28636
+ * // For the invalid date:
28637
+ * var result = isValid(new Date(''))
28638
+ * //=> false
28639
+ */
28640
+
28641
+ function isValid(dirtyDate) {
28642
+ requiredArgs(1, arguments);
28643
+ var date = toDate(dirtyDate);
28644
+ return !isNaN(date);
28645
+ }
28646
+
28647
+ var formatDistanceLocale = {
28648
+ lessThanXSeconds: {
28649
+ one: 'less than a second',
28650
+ other: 'less than {{count}} seconds'
28651
+ },
28652
+ xSeconds: {
28653
+ one: '1 second',
28654
+ other: '{{count}} seconds'
28655
+ },
28656
+ halfAMinute: 'half a minute',
28657
+ lessThanXMinutes: {
28658
+ one: 'less than a minute',
28659
+ other: 'less than {{count}} minutes'
28660
+ },
28661
+ xMinutes: {
28662
+ one: '1 minute',
28663
+ other: '{{count}} minutes'
28664
+ },
28665
+ aboutXHours: {
28666
+ one: 'about 1 hour',
28667
+ other: 'about {{count}} hours'
28668
+ },
28669
+ xHours: {
28670
+ one: '1 hour',
28671
+ other: '{{count}} hours'
28672
+ },
28673
+ xDays: {
28674
+ one: '1 day',
28675
+ other: '{{count}} days'
28676
+ },
28677
+ aboutXWeeks: {
28678
+ one: 'about 1 week',
28679
+ other: 'about {{count}} weeks'
28680
+ },
28681
+ xWeeks: {
28682
+ one: '1 week',
28683
+ other: '{{count}} weeks'
28684
+ },
28685
+ aboutXMonths: {
28686
+ one: 'about 1 month',
28687
+ other: 'about {{count}} months'
28688
+ },
28689
+ xMonths: {
28690
+ one: '1 month',
28691
+ other: '{{count}} months'
28692
+ },
28693
+ aboutXYears: {
28694
+ one: 'about 1 year',
28695
+ other: 'about {{count}} years'
28696
+ },
28697
+ xYears: {
28698
+ one: '1 year',
28699
+ other: '{{count}} years'
28700
+ },
28701
+ overXYears: {
28702
+ one: 'over 1 year',
28703
+ other: 'over {{count}} years'
28704
+ },
28705
+ almostXYears: {
28706
+ one: 'almost 1 year',
28707
+ other: 'almost {{count}} years'
28708
+ }
28709
+ };
28710
+ function formatDistance(token, count, options) {
28711
+ options = options || {};
28712
+ var result;
28713
+
28714
+ if (typeof formatDistanceLocale[token] === 'string') {
28715
+ result = formatDistanceLocale[token];
28716
+ } else if (count === 1) {
28717
+ result = formatDistanceLocale[token].one;
28718
+ } else {
28719
+ result = formatDistanceLocale[token].other.replace('{{count}}', count);
28720
+ }
28721
+
28722
+ if (options.addSuffix) {
28723
+ if (options.comparison > 0) {
28724
+ return 'in ' + result;
28725
+ } else {
28726
+ return result + ' ago';
28727
+ }
28728
+ }
28729
+
28730
+ return result;
28731
+ }
28732
+
28733
+ function buildFormatLongFn(args) {
28734
+ return function (dirtyOptions) {
28735
+ var options = dirtyOptions || {};
28736
+ var width = options.width ? String(options.width) : args.defaultWidth;
28737
+ var format = args.formats[width] || args.formats[args.defaultWidth];
28738
+ return format;
28739
+ };
28740
+ }
28741
+
28742
+ var dateFormats = {
28743
+ full: 'EEEE, MMMM do, y',
28744
+ long: 'MMMM do, y',
28745
+ medium: 'MMM d, y',
28746
+ short: 'MM/dd/yyyy'
28747
+ };
28748
+ var timeFormats = {
28749
+ full: 'h:mm:ss a zzzz',
28750
+ long: 'h:mm:ss a z',
28751
+ medium: 'h:mm:ss a',
28752
+ short: 'h:mm a'
28753
+ };
28754
+ var dateTimeFormats = {
28755
+ full: "{{date}} 'at' {{time}}",
28756
+ long: "{{date}} 'at' {{time}}",
28757
+ medium: '{{date}}, {{time}}',
28758
+ short: '{{date}}, {{time}}'
28759
+ };
28760
+ var formatLong = {
28761
+ date: buildFormatLongFn({
28762
+ formats: dateFormats,
28763
+ defaultWidth: 'full'
28764
+ }),
28765
+ time: buildFormatLongFn({
28766
+ formats: timeFormats,
28767
+ defaultWidth: 'full'
28768
+ }),
28769
+ dateTime: buildFormatLongFn({
28770
+ formats: dateTimeFormats,
28771
+ defaultWidth: 'full'
28772
+ })
28773
+ };
28774
+ var formatLong$1 = formatLong;
28775
+
28776
+ var formatRelativeLocale = {
28777
+ lastWeek: "'last' eeee 'at' p",
28778
+ yesterday: "'yesterday at' p",
28779
+ today: "'today at' p",
28780
+ tomorrow: "'tomorrow at' p",
28781
+ nextWeek: "eeee 'at' p",
28782
+ other: 'P'
28783
+ };
28784
+ function formatRelative(token, _date, _baseDate, _options) {
28785
+ return formatRelativeLocale[token];
28786
+ }
28787
+
28788
+ function buildLocalizeFn(args) {
28789
+ return function (dirtyIndex, dirtyOptions) {
28790
+ var options = dirtyOptions || {};
28791
+ var context = options.context ? String(options.context) : 'standalone';
28792
+ var valuesArray;
28793
+
28794
+ if (context === 'formatting' && args.formattingValues) {
28795
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
28796
+ var width = options.width ? String(options.width) : defaultWidth;
28797
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
28798
+ } else {
28799
+ var _defaultWidth = args.defaultWidth;
28800
+
28801
+ var _width = options.width ? String(options.width) : args.defaultWidth;
28802
+
28803
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
28804
+ }
28805
+
28806
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
28807
+ return valuesArray[index];
28808
+ };
28809
+ }
28810
+
28811
+ var eraValues = {
28812
+ narrow: ['B', 'A'],
28813
+ abbreviated: ['BC', 'AD'],
28814
+ wide: ['Before Christ', 'Anno Domini']
28815
+ };
28816
+ var quarterValues = {
28817
+ narrow: ['1', '2', '3', '4'],
28818
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
28819
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter'] // Note: in English, the names of days of the week and months are capitalized.
28820
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
28821
+ // Generally, formatted dates should look like they are in the middle of a sentence,
28822
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
28823
+
28824
+ };
28825
+ var monthValues = {
28826
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
28827
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
28828
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
28829
+ };
28830
+ var dayValues = {
28831
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
28832
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
28833
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
28834
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
28835
+ };
28836
+ var dayPeriodValues = {
28837
+ narrow: {
28838
+ am: 'a',
28839
+ pm: 'p',
28840
+ midnight: 'mi',
28841
+ noon: 'n',
28842
+ morning: 'morning',
28843
+ afternoon: 'afternoon',
28844
+ evening: 'evening',
28845
+ night: 'night'
28846
+ },
28847
+ abbreviated: {
28848
+ am: 'AM',
28849
+ pm: 'PM',
28850
+ midnight: 'midnight',
28851
+ noon: 'noon',
28852
+ morning: 'morning',
28853
+ afternoon: 'afternoon',
28854
+ evening: 'evening',
28855
+ night: 'night'
28856
+ },
28857
+ wide: {
28858
+ am: 'a.m.',
28859
+ pm: 'p.m.',
28860
+ midnight: 'midnight',
28861
+ noon: 'noon',
28862
+ morning: 'morning',
28863
+ afternoon: 'afternoon',
28864
+ evening: 'evening',
28865
+ night: 'night'
28866
+ }
28867
+ };
28868
+ var formattingDayPeriodValues = {
28869
+ narrow: {
28870
+ am: 'a',
28871
+ pm: 'p',
28872
+ midnight: 'mi',
28873
+ noon: 'n',
28874
+ morning: 'in the morning',
28875
+ afternoon: 'in the afternoon',
28876
+ evening: 'in the evening',
28877
+ night: 'at night'
28878
+ },
28879
+ abbreviated: {
28880
+ am: 'AM',
28881
+ pm: 'PM',
28882
+ midnight: 'midnight',
28883
+ noon: 'noon',
28884
+ morning: 'in the morning',
28885
+ afternoon: 'in the afternoon',
28886
+ evening: 'in the evening',
28887
+ night: 'at night'
28888
+ },
28889
+ wide: {
28890
+ am: 'a.m.',
28891
+ pm: 'p.m.',
28892
+ midnight: 'midnight',
28893
+ noon: 'noon',
28894
+ morning: 'in the morning',
28895
+ afternoon: 'in the afternoon',
28896
+ evening: 'in the evening',
28897
+ night: 'at night'
28898
+ }
28899
+ };
28900
+
28901
+ function ordinalNumber(dirtyNumber, _dirtyOptions) {
28902
+ var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
28903
+ // if they are different for different grammatical genders,
28904
+ // use `options.unit`:
28905
+ //
28906
+ // var options = dirtyOptions || {}
28907
+ // var unit = String(options.unit)
28908
+ //
28909
+ // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
28910
+ // 'day', 'hour', 'minute', 'second'
28911
+
28912
+ var rem100 = number % 100;
28913
+
28914
+ if (rem100 > 20 || rem100 < 10) {
28915
+ switch (rem100 % 10) {
28916
+ case 1:
28917
+ return number + 'st';
28918
+
28919
+ case 2:
28920
+ return number + 'nd';
28921
+
28922
+ case 3:
28923
+ return number + 'rd';
28924
+ }
28925
+ }
28926
+
28927
+ return number + 'th';
28928
+ }
28929
+
28930
+ var localize = {
28931
+ ordinalNumber: ordinalNumber,
28932
+ era: buildLocalizeFn({
28933
+ values: eraValues,
28934
+ defaultWidth: 'wide'
28935
+ }),
28936
+ quarter: buildLocalizeFn({
28937
+ values: quarterValues,
28938
+ defaultWidth: 'wide',
28939
+ argumentCallback: function (quarter) {
28940
+ return Number(quarter) - 1;
28941
+ }
28942
+ }),
28943
+ month: buildLocalizeFn({
28944
+ values: monthValues,
28945
+ defaultWidth: 'wide'
28946
+ }),
28947
+ day: buildLocalizeFn({
28948
+ values: dayValues,
28949
+ defaultWidth: 'wide'
28950
+ }),
28951
+ dayPeriod: buildLocalizeFn({
28952
+ values: dayPeriodValues,
28953
+ defaultWidth: 'wide',
28954
+ formattingValues: formattingDayPeriodValues,
28955
+ defaultFormattingWidth: 'wide'
28956
+ })
28957
+ };
28958
+ var localize$1 = localize;
28959
+
28960
+ function buildMatchPatternFn(args) {
28961
+ return function (dirtyString, dirtyOptions) {
28962
+ var string = String(dirtyString);
28963
+ var options = dirtyOptions || {};
28964
+ var matchResult = string.match(args.matchPattern);
28965
+
28966
+ if (!matchResult) {
28967
+ return null;
28968
+ }
28969
+
28970
+ var matchedString = matchResult[0];
28971
+ var parseResult = string.match(args.parsePattern);
28972
+
28973
+ if (!parseResult) {
28974
+ return null;
28975
+ }
28976
+
28977
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
28978
+ value = options.valueCallback ? options.valueCallback(value) : value;
28979
+ return {
28980
+ value: value,
28981
+ rest: string.slice(matchedString.length)
28982
+ };
28983
+ };
28984
+ }
28985
+
28986
+ function buildMatchFn(args) {
28987
+ return function (dirtyString, dirtyOptions) {
28988
+ var string = String(dirtyString);
28989
+ var options = dirtyOptions || {};
28990
+ var width = options.width;
28991
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
28992
+ var matchResult = string.match(matchPattern);
28993
+
28994
+ if (!matchResult) {
28995
+ return null;
28996
+ }
28997
+
28998
+ var matchedString = matchResult[0];
28999
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
29000
+ var value;
29001
+
29002
+ if (Object.prototype.toString.call(parsePatterns) === '[object Array]') {
29003
+ value = findIndex(parsePatterns, function (pattern) {
29004
+ return pattern.test(matchedString);
29005
+ });
29006
+ } else {
29007
+ value = findKey(parsePatterns, function (pattern) {
29008
+ return pattern.test(matchedString);
29009
+ });
29010
+ }
29011
+
29012
+ value = args.valueCallback ? args.valueCallback(value) : value;
29013
+ value = options.valueCallback ? options.valueCallback(value) : value;
29014
+ return {
29015
+ value: value,
29016
+ rest: string.slice(matchedString.length)
29017
+ };
29018
+ };
29019
+ }
29020
+
29021
+ function findKey(object, predicate) {
29022
+ for (var key in object) {
29023
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
29024
+ return key;
29025
+ }
29026
+ }
29027
+ }
29028
+
29029
+ function findIndex(array, predicate) {
29030
+ for (var key = 0; key < array.length; key++) {
29031
+ if (predicate(array[key])) {
29032
+ return key;
29033
+ }
29034
+ }
29035
+ }
29036
+
29037
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
29038
+ var parseOrdinalNumberPattern = /\d+/i;
29039
+ var matchEraPatterns = {
29040
+ narrow: /^(b|a)/i,
29041
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
29042
+ wide: /^(before christ|before common era|anno domini|common era)/i
29043
+ };
29044
+ var parseEraPatterns = {
29045
+ any: [/^b/i, /^(a|c)/i]
29046
+ };
29047
+ var matchQuarterPatterns = {
29048
+ narrow: /^[1234]/i,
29049
+ abbreviated: /^q[1234]/i,
29050
+ wide: /^[1234](th|st|nd|rd)? quarter/i
29051
+ };
29052
+ var parseQuarterPatterns = {
29053
+ any: [/1/i, /2/i, /3/i, /4/i]
29054
+ };
29055
+ var matchMonthPatterns = {
29056
+ narrow: /^[jfmasond]/i,
29057
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
29058
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
29059
+ };
29060
+ var parseMonthPatterns = {
29061
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
29062
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
29063
+ };
29064
+ var matchDayPatterns = {
29065
+ narrow: /^[smtwf]/i,
29066
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
29067
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
29068
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
29069
+ };
29070
+ var parseDayPatterns = {
29071
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
29072
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
29073
+ };
29074
+ var matchDayPeriodPatterns = {
29075
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
29076
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
29077
+ };
29078
+ var parseDayPeriodPatterns = {
29079
+ any: {
29080
+ am: /^a/i,
29081
+ pm: /^p/i,
29082
+ midnight: /^mi/i,
29083
+ noon: /^no/i,
29084
+ morning: /morning/i,
29085
+ afternoon: /afternoon/i,
29086
+ evening: /evening/i,
29087
+ night: /night/i
29088
+ }
29089
+ };
29090
+ var match = {
29091
+ ordinalNumber: buildMatchPatternFn({
29092
+ matchPattern: matchOrdinalNumberPattern,
29093
+ parsePattern: parseOrdinalNumberPattern,
29094
+ valueCallback: function (value) {
29095
+ return parseInt(value, 10);
29096
+ }
29097
+ }),
29098
+ era: buildMatchFn({
29099
+ matchPatterns: matchEraPatterns,
29100
+ defaultMatchWidth: 'wide',
29101
+ parsePatterns: parseEraPatterns,
29102
+ defaultParseWidth: 'any'
29103
+ }),
29104
+ quarter: buildMatchFn({
29105
+ matchPatterns: matchQuarterPatterns,
29106
+ defaultMatchWidth: 'wide',
29107
+ parsePatterns: parseQuarterPatterns,
29108
+ defaultParseWidth: 'any',
29109
+ valueCallback: function (index) {
29110
+ return index + 1;
29111
+ }
29112
+ }),
29113
+ month: buildMatchFn({
29114
+ matchPatterns: matchMonthPatterns,
29115
+ defaultMatchWidth: 'wide',
29116
+ parsePatterns: parseMonthPatterns,
29117
+ defaultParseWidth: 'any'
29118
+ }),
29119
+ day: buildMatchFn({
29120
+ matchPatterns: matchDayPatterns,
29121
+ defaultMatchWidth: 'wide',
29122
+ parsePatterns: parseDayPatterns,
29123
+ defaultParseWidth: 'any'
29124
+ }),
29125
+ dayPeriod: buildMatchFn({
29126
+ matchPatterns: matchDayPeriodPatterns,
29127
+ defaultMatchWidth: 'any',
29128
+ parsePatterns: parseDayPeriodPatterns,
29129
+ defaultParseWidth: 'any'
29130
+ })
29131
+ };
29132
+ var match$1 = match;
29133
+
29134
+ /**
29135
+ * @type {Locale}
29136
+ * @category Locales
29137
+ * @summary English locale (United States).
29138
+ * @language English
29139
+ * @iso-639-2 eng
29140
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
29141
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
29142
+ */
29143
+
29144
+ var locale = {
29145
+ code: 'en-US',
29146
+ formatDistance: formatDistance,
29147
+ formatLong: formatLong$1,
29148
+ formatRelative: formatRelative,
29149
+ localize: localize$1,
29150
+ match: match$1,
29151
+ options: {
29152
+ weekStartsOn: 0
29153
+ /* Sunday */
29154
+ ,
29155
+ firstWeekContainsDate: 1
29156
+ }
29157
+ };
29158
+ var defaultLocale = locale;
29159
+
29160
+ /**
29161
+ * @name subMilliseconds
29162
+ * @category Millisecond Helpers
29163
+ * @summary Subtract the specified number of milliseconds from the given date.
29164
+ *
29165
+ * @description
29166
+ * Subtract the specified number of milliseconds from the given date.
29167
+ *
29168
+ * ### v2.0.0 breaking changes:
29169
+ *
29170
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
29171
+ *
29172
+ * @param {Date|Number} date - the date to be changed
29173
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
29174
+ * @returns {Date} the new date with the milliseconds subtracted
29175
+ * @throws {TypeError} 2 arguments required
29176
+ *
29177
+ * @example
29178
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
29179
+ * var result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
29180
+ * //=> Thu Jul 10 2014 12:45:29.250
29181
+ */
29182
+
29183
+ function subMilliseconds(dirtyDate, dirtyAmount) {
29184
+ requiredArgs(2, arguments);
29185
+ var amount = toInteger(dirtyAmount);
29186
+ return addMilliseconds(dirtyDate, -amount);
29187
+ }
29188
+
29189
+ function addLeadingZeros(number, targetLength) {
29190
+ var sign = number < 0 ? '-' : '';
29191
+ var output = Math.abs(number).toString();
29192
+
29193
+ while (output.length < targetLength) {
29194
+ output = '0' + output;
29195
+ }
29196
+
29197
+ return sign + output;
29198
+ }
29199
+
29200
+ /*
29201
+ * | | Unit | | Unit |
29202
+ * |-----|--------------------------------|-----|--------------------------------|
29203
+ * | a | AM, PM | A* | |
29204
+ * | d | Day of month | D | |
29205
+ * | h | Hour [1-12] | H | Hour [0-23] |
29206
+ * | m | Minute | M | Month |
29207
+ * | s | Second | S | Fraction of second |
29208
+ * | y | Year (abs) | Y | |
29209
+ *
29210
+ * Letters marked by * are not implemented but reserved by Unicode standard.
29211
+ */
29212
+
29213
+ var formatters$2 = {
29214
+ // Year
29215
+ y: function (date, token) {
29216
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
29217
+ // | Year | y | yy | yyy | yyyy | yyyyy |
29218
+ // |----------|-------|----|-------|-------|-------|
29219
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
29220
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
29221
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
29222
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
29223
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
29224
+ var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
29225
+
29226
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
29227
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
29228
+ },
29229
+ // Month
29230
+ M: function (date, token) {
29231
+ var month = date.getUTCMonth();
29232
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
29233
+ },
29234
+ // Day of the month
29235
+ d: function (date, token) {
29236
+ return addLeadingZeros(date.getUTCDate(), token.length);
29237
+ },
29238
+ // AM or PM
29239
+ a: function (date, token) {
29240
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
29241
+
29242
+ switch (token) {
29243
+ case 'a':
29244
+ case 'aa':
29245
+ case 'aaa':
29246
+ return dayPeriodEnumValue.toUpperCase();
29247
+
29248
+ case 'aaaaa':
29249
+ return dayPeriodEnumValue[0];
29250
+
29251
+ case 'aaaa':
29252
+ default:
29253
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
29254
+ }
29255
+ },
29256
+ // Hour [1-12]
29257
+ h: function (date, token) {
29258
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
29259
+ },
29260
+ // Hour [0-23]
29261
+ H: function (date, token) {
29262
+ return addLeadingZeros(date.getUTCHours(), token.length);
29263
+ },
29264
+ // Minute
29265
+ m: function (date, token) {
29266
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
29267
+ },
29268
+ // Second
29269
+ s: function (date, token) {
29270
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
29271
+ },
29272
+ // Fraction of second
29273
+ S: function (date, token) {
29274
+ var numberOfDigits = token.length;
29275
+ var milliseconds = date.getUTCMilliseconds();
29276
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
29277
+ return addLeadingZeros(fractionalSeconds, token.length);
29278
+ }
29279
+ };
29280
+ var formatters$3 = formatters$2;
29281
+
29282
+ var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
29283
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29284
+
29285
+ function getUTCDayOfYear(dirtyDate) {
29286
+ requiredArgs(1, arguments);
29287
+ var date = toDate(dirtyDate);
29288
+ var timestamp = date.getTime();
29289
+ date.setUTCMonth(0, 1);
29290
+ date.setUTCHours(0, 0, 0, 0);
29291
+ var startOfYearTimestamp = date.getTime();
29292
+ var difference = timestamp - startOfYearTimestamp;
29293
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
29294
+ }
29295
+
29296
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29297
+
29298
+ function startOfUTCISOWeek(dirtyDate) {
29299
+ requiredArgs(1, arguments);
29300
+ var weekStartsOn = 1;
29301
+ var date = toDate(dirtyDate);
29302
+ var day = date.getUTCDay();
29303
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
29304
+ date.setUTCDate(date.getUTCDate() - diff);
29305
+ date.setUTCHours(0, 0, 0, 0);
29306
+ return date;
29307
+ }
29308
+
29309
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29310
+
29311
+ function getUTCISOWeekYear(dirtyDate) {
29312
+ requiredArgs(1, arguments);
29313
+ var date = toDate(dirtyDate);
29314
+ var year = date.getUTCFullYear();
29315
+ var fourthOfJanuaryOfNextYear = new Date(0);
29316
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
29317
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
29318
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
29319
+ var fourthOfJanuaryOfThisYear = new Date(0);
29320
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
29321
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
29322
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
29323
+
29324
+ if (date.getTime() >= startOfNextYear.getTime()) {
29325
+ return year + 1;
29326
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
29327
+ return year;
29328
+ } else {
29329
+ return year - 1;
29330
+ }
29331
+ }
29332
+
29333
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29334
+
29335
+ function startOfUTCISOWeekYear(dirtyDate) {
29336
+ requiredArgs(1, arguments);
29337
+ var year = getUTCISOWeekYear(dirtyDate);
29338
+ var fourthOfJanuary = new Date(0);
29339
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
29340
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
29341
+ var date = startOfUTCISOWeek(fourthOfJanuary);
29342
+ return date;
29343
+ }
29344
+
29345
+ var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
29346
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29347
+
29348
+ function getUTCISOWeek(dirtyDate) {
29349
+ requiredArgs(1, arguments);
29350
+ var date = toDate(dirtyDate);
29351
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
29352
+ // because the number of milliseconds in a week is not constant
29353
+ // (e.g. it's different in the week of the daylight saving time clock shift)
29354
+
29355
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
29356
+ }
29357
+
29358
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29359
+
29360
+ function startOfUTCWeek(dirtyDate, dirtyOptions) {
29361
+ requiredArgs(1, arguments);
29362
+ var options = dirtyOptions || {};
29363
+ var locale = options.locale;
29364
+ var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
29365
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
29366
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
29367
+
29368
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
29369
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
29370
+ }
29371
+
29372
+ var date = toDate(dirtyDate);
29373
+ var day = date.getUTCDay();
29374
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
29375
+ date.setUTCDate(date.getUTCDate() - diff);
29376
+ date.setUTCHours(0, 0, 0, 0);
29377
+ return date;
29378
+ }
29379
+
29380
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29381
+
29382
+ function getUTCWeekYear(dirtyDate, dirtyOptions) {
29383
+ requiredArgs(1, arguments);
29384
+ var date = toDate(dirtyDate, dirtyOptions);
29385
+ var year = date.getUTCFullYear();
29386
+ var options = dirtyOptions || {};
29387
+ var locale = options.locale;
29388
+ var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
29389
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
29390
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
29391
+
29392
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
29393
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
29394
+ }
29395
+
29396
+ var firstWeekOfNextYear = new Date(0);
29397
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
29398
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
29399
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, dirtyOptions);
29400
+ var firstWeekOfThisYear = new Date(0);
29401
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
29402
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
29403
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, dirtyOptions);
29404
+
29405
+ if (date.getTime() >= startOfNextYear.getTime()) {
29406
+ return year + 1;
29407
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
29408
+ return year;
29409
+ } else {
29410
+ return year - 1;
29411
+ }
29412
+ }
29413
+
29414
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29415
+
29416
+ function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
29417
+ requiredArgs(1, arguments);
29418
+ var options = dirtyOptions || {};
29419
+ var locale = options.locale;
29420
+ var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
29421
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
29422
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
29423
+ var year = getUTCWeekYear(dirtyDate, dirtyOptions);
29424
+ var firstWeek = new Date(0);
29425
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
29426
+ firstWeek.setUTCHours(0, 0, 0, 0);
29427
+ var date = startOfUTCWeek(firstWeek, dirtyOptions);
29428
+ return date;
29429
+ }
29430
+
29431
+ var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented.
29432
+ // See issue: https://github.com/date-fns/date-fns/issues/376
29433
+
29434
+ function getUTCWeek(dirtyDate, options) {
29435
+ requiredArgs(1, arguments);
29436
+ var date = toDate(dirtyDate);
29437
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
29438
+ // because the number of milliseconds in a week is not constant
29439
+ // (e.g. it's different in the week of the daylight saving time clock shift)
29440
+
29441
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
29442
+ }
29443
+
29444
+ var dayPeriodEnum = {
29445
+ am: 'am',
29446
+ pm: 'pm',
29447
+ midnight: 'midnight',
29448
+ noon: 'noon',
29449
+ morning: 'morning',
29450
+ afternoon: 'afternoon',
29451
+ evening: 'evening',
29452
+ night: 'night'
29453
+ /*
29454
+ * | | Unit | | Unit |
29455
+ * |-----|--------------------------------|-----|--------------------------------|
29456
+ * | a | AM, PM | A* | Milliseconds in day |
29457
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
29458
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
29459
+ * | d | Day of month | D | Day of year |
29460
+ * | e | Local day of week | E | Day of week |
29461
+ * | f | | F* | Day of week in month |
29462
+ * | g* | Modified Julian day | G | Era |
29463
+ * | h | Hour [1-12] | H | Hour [0-23] |
29464
+ * | i! | ISO day of week | I! | ISO week of year |
29465
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
29466
+ * | k | Hour [1-24] | K | Hour [0-11] |
29467
+ * | l* | (deprecated) | L | Stand-alone month |
29468
+ * | m | Minute | M | Month |
29469
+ * | n | | N | |
29470
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
29471
+ * | p! | Long localized time | P! | Long localized date |
29472
+ * | q | Stand-alone quarter | Q | Quarter |
29473
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
29474
+ * | s | Second | S | Fraction of second |
29475
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
29476
+ * | u | Extended year | U* | Cyclic year |
29477
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
29478
+ * | w | Local week of year | W* | Week of month |
29479
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
29480
+ * | y | Year (abs) | Y | Local week-numbering year |
29481
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
29482
+ *
29483
+ * Letters marked by * are not implemented but reserved by Unicode standard.
29484
+ *
29485
+ * Letters marked by ! are non-standard, but implemented by date-fns:
29486
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
29487
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
29488
+ * i.e. 7 for Sunday, 1 for Monday, etc.
29489
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
29490
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
29491
+ * `R` is supposed to be used in conjunction with `I` and `i`
29492
+ * for universal ISO week-numbering date, whereas
29493
+ * `Y` is supposed to be used in conjunction with `w` and `e`
29494
+ * for week-numbering date specific to the locale.
29495
+ * - `P` is long localized date format
29496
+ * - `p` is long localized time format
29497
+ */
29498
+
29499
+ };
29500
+ var formatters = {
29501
+ // Era
29502
+ G: function (date, token, localize) {
29503
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
29504
+
29505
+ switch (token) {
29506
+ // AD, BC
29507
+ case 'G':
29508
+ case 'GG':
29509
+ case 'GGG':
29510
+ return localize.era(era, {
29511
+ width: 'abbreviated'
29512
+ });
29513
+ // A, B
29514
+
29515
+ case 'GGGGG':
29516
+ return localize.era(era, {
29517
+ width: 'narrow'
29518
+ });
29519
+ // Anno Domini, Before Christ
29520
+
29521
+ case 'GGGG':
29522
+ default:
29523
+ return localize.era(era, {
29524
+ width: 'wide'
29525
+ });
29526
+ }
29527
+ },
29528
+ // Year
29529
+ y: function (date, token, localize) {
29530
+ // Ordinal number
29531
+ if (token === 'yo') {
29532
+ var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
29533
+
29534
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
29535
+ return localize.ordinalNumber(year, {
29536
+ unit: 'year'
29537
+ });
29538
+ }
29539
+
29540
+ return formatters$3.y(date, token);
29541
+ },
29542
+ // Local week-numbering year
29543
+ Y: function (date, token, localize, options) {
29544
+ var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
29545
+
29546
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
29547
+
29548
+ if (token === 'YY') {
29549
+ var twoDigitYear = weekYear % 100;
29550
+ return addLeadingZeros(twoDigitYear, 2);
29551
+ } // Ordinal number
29552
+
29553
+
29554
+ if (token === 'Yo') {
29555
+ return localize.ordinalNumber(weekYear, {
29556
+ unit: 'year'
29557
+ });
29558
+ } // Padding
29559
+
29560
+
29561
+ return addLeadingZeros(weekYear, token.length);
29562
+ },
29563
+ // ISO week-numbering year
29564
+ R: function (date, token) {
29565
+ var isoWeekYear = getUTCISOWeekYear(date); // Padding
29566
+
29567
+ return addLeadingZeros(isoWeekYear, token.length);
29568
+ },
29569
+ // Extended year. This is a single number designating the year of this calendar system.
29570
+ // The main difference between `y` and `u` localizers are B.C. years:
29571
+ // | Year | `y` | `u` |
29572
+ // |------|-----|-----|
29573
+ // | AC 1 | 1 | 1 |
29574
+ // | BC 1 | 1 | 0 |
29575
+ // | BC 2 | 2 | -1 |
29576
+ // Also `yy` always returns the last two digits of a year,
29577
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
29578
+ u: function (date, token) {
29579
+ var year = date.getUTCFullYear();
29580
+ return addLeadingZeros(year, token.length);
29581
+ },
29582
+ // Quarter
29583
+ Q: function (date, token, localize) {
29584
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
29585
+
29586
+ switch (token) {
29587
+ // 1, 2, 3, 4
29588
+ case 'Q':
29589
+ return String(quarter);
29590
+ // 01, 02, 03, 04
29591
+
29592
+ case 'QQ':
29593
+ return addLeadingZeros(quarter, 2);
29594
+ // 1st, 2nd, 3rd, 4th
29595
+
29596
+ case 'Qo':
29597
+ return localize.ordinalNumber(quarter, {
29598
+ unit: 'quarter'
29599
+ });
29600
+ // Q1, Q2, Q3, Q4
29601
+
29602
+ case 'QQQ':
29603
+ return localize.quarter(quarter, {
29604
+ width: 'abbreviated',
29605
+ context: 'formatting'
29606
+ });
29607
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
29608
+
29609
+ case 'QQQQQ':
29610
+ return localize.quarter(quarter, {
29611
+ width: 'narrow',
29612
+ context: 'formatting'
29613
+ });
29614
+ // 1st quarter, 2nd quarter, ...
29615
+
29616
+ case 'QQQQ':
29617
+ default:
29618
+ return localize.quarter(quarter, {
29619
+ width: 'wide',
29620
+ context: 'formatting'
29621
+ });
29622
+ }
29623
+ },
29624
+ // Stand-alone quarter
29625
+ q: function (date, token, localize) {
29626
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
29627
+
29628
+ switch (token) {
29629
+ // 1, 2, 3, 4
29630
+ case 'q':
29631
+ return String(quarter);
29632
+ // 01, 02, 03, 04
29633
+
29634
+ case 'qq':
29635
+ return addLeadingZeros(quarter, 2);
29636
+ // 1st, 2nd, 3rd, 4th
29637
+
29638
+ case 'qo':
29639
+ return localize.ordinalNumber(quarter, {
29640
+ unit: 'quarter'
29641
+ });
29642
+ // Q1, Q2, Q3, Q4
29643
+
29644
+ case 'qqq':
29645
+ return localize.quarter(quarter, {
29646
+ width: 'abbreviated',
29647
+ context: 'standalone'
29648
+ });
29649
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
29650
+
29651
+ case 'qqqqq':
29652
+ return localize.quarter(quarter, {
29653
+ width: 'narrow',
29654
+ context: 'standalone'
29655
+ });
29656
+ // 1st quarter, 2nd quarter, ...
29657
+
29658
+ case 'qqqq':
29659
+ default:
29660
+ return localize.quarter(quarter, {
29661
+ width: 'wide',
29662
+ context: 'standalone'
29663
+ });
29664
+ }
29665
+ },
29666
+ // Month
29667
+ M: function (date, token, localize) {
29668
+ var month = date.getUTCMonth();
29669
+
29670
+ switch (token) {
29671
+ case 'M':
29672
+ case 'MM':
29673
+ return formatters$3.M(date, token);
29674
+ // 1st, 2nd, ..., 12th
29675
+
29676
+ case 'Mo':
29677
+ return localize.ordinalNumber(month + 1, {
29678
+ unit: 'month'
29679
+ });
29680
+ // Jan, Feb, ..., Dec
29681
+
29682
+ case 'MMM':
29683
+ return localize.month(month, {
29684
+ width: 'abbreviated',
29685
+ context: 'formatting'
29686
+ });
29687
+ // J, F, ..., D
29688
+
29689
+ case 'MMMMM':
29690
+ return localize.month(month, {
29691
+ width: 'narrow',
29692
+ context: 'formatting'
29693
+ });
29694
+ // January, February, ..., December
29695
+
29696
+ case 'MMMM':
29697
+ default:
29698
+ return localize.month(month, {
29699
+ width: 'wide',
29700
+ context: 'formatting'
29701
+ });
29702
+ }
29703
+ },
29704
+ // Stand-alone month
29705
+ L: function (date, token, localize) {
29706
+ var month = date.getUTCMonth();
29707
+
29708
+ switch (token) {
29709
+ // 1, 2, ..., 12
29710
+ case 'L':
29711
+ return String(month + 1);
29712
+ // 01, 02, ..., 12
29713
+
29714
+ case 'LL':
29715
+ return addLeadingZeros(month + 1, 2);
29716
+ // 1st, 2nd, ..., 12th
29717
+
29718
+ case 'Lo':
29719
+ return localize.ordinalNumber(month + 1, {
29720
+ unit: 'month'
29721
+ });
29722
+ // Jan, Feb, ..., Dec
29723
+
29724
+ case 'LLL':
29725
+ return localize.month(month, {
29726
+ width: 'abbreviated',
29727
+ context: 'standalone'
29728
+ });
29729
+ // J, F, ..., D
29730
+
29731
+ case 'LLLLL':
29732
+ return localize.month(month, {
29733
+ width: 'narrow',
29734
+ context: 'standalone'
29735
+ });
29736
+ // January, February, ..., December
29737
+
29738
+ case 'LLLL':
29739
+ default:
29740
+ return localize.month(month, {
29741
+ width: 'wide',
29742
+ context: 'standalone'
29743
+ });
29744
+ }
29745
+ },
29746
+ // Local week of year
29747
+ w: function (date, token, localize, options) {
29748
+ var week = getUTCWeek(date, options);
29749
+
29750
+ if (token === 'wo') {
29751
+ return localize.ordinalNumber(week, {
29752
+ unit: 'week'
29753
+ });
29754
+ }
29755
+
29756
+ return addLeadingZeros(week, token.length);
29757
+ },
29758
+ // ISO week of year
29759
+ I: function (date, token, localize) {
29760
+ var isoWeek = getUTCISOWeek(date);
29761
+
29762
+ if (token === 'Io') {
29763
+ return localize.ordinalNumber(isoWeek, {
29764
+ unit: 'week'
29765
+ });
29766
+ }
29767
+
29768
+ return addLeadingZeros(isoWeek, token.length);
29769
+ },
29770
+ // Day of the month
29771
+ d: function (date, token, localize) {
29772
+ if (token === 'do') {
29773
+ return localize.ordinalNumber(date.getUTCDate(), {
29774
+ unit: 'date'
29775
+ });
29776
+ }
29777
+
29778
+ return formatters$3.d(date, token);
29779
+ },
29780
+ // Day of year
29781
+ D: function (date, token, localize) {
29782
+ var dayOfYear = getUTCDayOfYear(date);
29783
+
29784
+ if (token === 'Do') {
29785
+ return localize.ordinalNumber(dayOfYear, {
29786
+ unit: 'dayOfYear'
29787
+ });
29788
+ }
29789
+
29790
+ return addLeadingZeros(dayOfYear, token.length);
29791
+ },
29792
+ // Day of week
29793
+ E: function (date, token, localize) {
29794
+ var dayOfWeek = date.getUTCDay();
29795
+
29796
+ switch (token) {
29797
+ // Tue
29798
+ case 'E':
29799
+ case 'EE':
29800
+ case 'EEE':
29801
+ return localize.day(dayOfWeek, {
29802
+ width: 'abbreviated',
29803
+ context: 'formatting'
29804
+ });
29805
+ // T
29806
+
29807
+ case 'EEEEE':
29808
+ return localize.day(dayOfWeek, {
29809
+ width: 'narrow',
29810
+ context: 'formatting'
29811
+ });
29812
+ // Tu
29813
+
29814
+ case 'EEEEEE':
29815
+ return localize.day(dayOfWeek, {
29816
+ width: 'short',
29817
+ context: 'formatting'
29818
+ });
29819
+ // Tuesday
29820
+
29821
+ case 'EEEE':
29822
+ default:
29823
+ return localize.day(dayOfWeek, {
29824
+ width: 'wide',
29825
+ context: 'formatting'
29826
+ });
29827
+ }
29828
+ },
29829
+ // Local day of week
29830
+ e: function (date, token, localize, options) {
29831
+ var dayOfWeek = date.getUTCDay();
29832
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
29833
+
29834
+ switch (token) {
29835
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
29836
+ case 'e':
29837
+ return String(localDayOfWeek);
29838
+ // Padded numerical value
29839
+
29840
+ case 'ee':
29841
+ return addLeadingZeros(localDayOfWeek, 2);
29842
+ // 1st, 2nd, ..., 7th
29843
+
29844
+ case 'eo':
29845
+ return localize.ordinalNumber(localDayOfWeek, {
29846
+ unit: 'day'
29847
+ });
29848
+
29849
+ case 'eee':
29850
+ return localize.day(dayOfWeek, {
29851
+ width: 'abbreviated',
29852
+ context: 'formatting'
29853
+ });
29854
+ // T
29855
+
29856
+ case 'eeeee':
29857
+ return localize.day(dayOfWeek, {
29858
+ width: 'narrow',
29859
+ context: 'formatting'
29860
+ });
29861
+ // Tu
29862
+
29863
+ case 'eeeeee':
29864
+ return localize.day(dayOfWeek, {
29865
+ width: 'short',
29866
+ context: 'formatting'
29867
+ });
29868
+ // Tuesday
29869
+
29870
+ case 'eeee':
29871
+ default:
29872
+ return localize.day(dayOfWeek, {
29873
+ width: 'wide',
29874
+ context: 'formatting'
29875
+ });
29876
+ }
29877
+ },
29878
+ // Stand-alone local day of week
29879
+ c: function (date, token, localize, options) {
29880
+ var dayOfWeek = date.getUTCDay();
29881
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
29882
+
29883
+ switch (token) {
29884
+ // Numerical value (same as in `e`)
29885
+ case 'c':
29886
+ return String(localDayOfWeek);
29887
+ // Padded numerical value
29888
+
29889
+ case 'cc':
29890
+ return addLeadingZeros(localDayOfWeek, token.length);
29891
+ // 1st, 2nd, ..., 7th
29892
+
29893
+ case 'co':
29894
+ return localize.ordinalNumber(localDayOfWeek, {
29895
+ unit: 'day'
29896
+ });
29897
+
29898
+ case 'ccc':
29899
+ return localize.day(dayOfWeek, {
29900
+ width: 'abbreviated',
29901
+ context: 'standalone'
29902
+ });
29903
+ // T
29904
+
29905
+ case 'ccccc':
29906
+ return localize.day(dayOfWeek, {
29907
+ width: 'narrow',
29908
+ context: 'standalone'
29909
+ });
29910
+ // Tu
29911
+
29912
+ case 'cccccc':
29913
+ return localize.day(dayOfWeek, {
29914
+ width: 'short',
29915
+ context: 'standalone'
29916
+ });
29917
+ // Tuesday
29918
+
29919
+ case 'cccc':
29920
+ default:
29921
+ return localize.day(dayOfWeek, {
29922
+ width: 'wide',
29923
+ context: 'standalone'
29924
+ });
29925
+ }
29926
+ },
29927
+ // ISO day of week
29928
+ i: function (date, token, localize) {
29929
+ var dayOfWeek = date.getUTCDay();
29930
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
29931
+
29932
+ switch (token) {
29933
+ // 2
29934
+ case 'i':
29935
+ return String(isoDayOfWeek);
29936
+ // 02
29937
+
29938
+ case 'ii':
29939
+ return addLeadingZeros(isoDayOfWeek, token.length);
29940
+ // 2nd
29941
+
29942
+ case 'io':
29943
+ return localize.ordinalNumber(isoDayOfWeek, {
29944
+ unit: 'day'
29945
+ });
29946
+ // Tue
29947
+
29948
+ case 'iii':
29949
+ return localize.day(dayOfWeek, {
29950
+ width: 'abbreviated',
29951
+ context: 'formatting'
29952
+ });
29953
+ // T
29954
+
29955
+ case 'iiiii':
29956
+ return localize.day(dayOfWeek, {
29957
+ width: 'narrow',
29958
+ context: 'formatting'
29959
+ });
29960
+ // Tu
29961
+
29962
+ case 'iiiiii':
29963
+ return localize.day(dayOfWeek, {
29964
+ width: 'short',
29965
+ context: 'formatting'
29966
+ });
29967
+ // Tuesday
29968
+
29969
+ case 'iiii':
29970
+ default:
29971
+ return localize.day(dayOfWeek, {
29972
+ width: 'wide',
29973
+ context: 'formatting'
29974
+ });
29975
+ }
29976
+ },
29977
+ // AM or PM
29978
+ a: function (date, token, localize) {
29979
+ var hours = date.getUTCHours();
29980
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
29981
+
29982
+ switch (token) {
29983
+ case 'a':
29984
+ case 'aa':
29985
+ case 'aaa':
29986
+ return localize.dayPeriod(dayPeriodEnumValue, {
29987
+ width: 'abbreviated',
29988
+ context: 'formatting'
29989
+ });
29990
+
29991
+ case 'aaaaa':
29992
+ return localize.dayPeriod(dayPeriodEnumValue, {
29993
+ width: 'narrow',
29994
+ context: 'formatting'
29995
+ });
29996
+
29997
+ case 'aaaa':
29998
+ default:
29999
+ return localize.dayPeriod(dayPeriodEnumValue, {
30000
+ width: 'wide',
30001
+ context: 'formatting'
30002
+ });
30003
+ }
30004
+ },
30005
+ // AM, PM, midnight, noon
30006
+ b: function (date, token, localize) {
30007
+ var hours = date.getUTCHours();
30008
+ var dayPeriodEnumValue;
30009
+
30010
+ if (hours === 12) {
30011
+ dayPeriodEnumValue = dayPeriodEnum.noon;
30012
+ } else if (hours === 0) {
30013
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
30014
+ } else {
30015
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
30016
+ }
30017
+
30018
+ switch (token) {
30019
+ case 'b':
30020
+ case 'bb':
30021
+ case 'bbb':
30022
+ return localize.dayPeriod(dayPeriodEnumValue, {
30023
+ width: 'abbreviated',
30024
+ context: 'formatting'
30025
+ });
30026
+
30027
+ case 'bbbbb':
30028
+ return localize.dayPeriod(dayPeriodEnumValue, {
30029
+ width: 'narrow',
30030
+ context: 'formatting'
30031
+ });
30032
+
30033
+ case 'bbbb':
30034
+ default:
30035
+ return localize.dayPeriod(dayPeriodEnumValue, {
30036
+ width: 'wide',
30037
+ context: 'formatting'
30038
+ });
30039
+ }
30040
+ },
30041
+ // in the morning, in the afternoon, in the evening, at night
30042
+ B: function (date, token, localize) {
30043
+ var hours = date.getUTCHours();
30044
+ var dayPeriodEnumValue;
30045
+
30046
+ if (hours >= 17) {
30047
+ dayPeriodEnumValue = dayPeriodEnum.evening;
30048
+ } else if (hours >= 12) {
30049
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
30050
+ } else if (hours >= 4) {
30051
+ dayPeriodEnumValue = dayPeriodEnum.morning;
30052
+ } else {
30053
+ dayPeriodEnumValue = dayPeriodEnum.night;
30054
+ }
30055
+
30056
+ switch (token) {
30057
+ case 'B':
30058
+ case 'BB':
30059
+ case 'BBB':
30060
+ return localize.dayPeriod(dayPeriodEnumValue, {
30061
+ width: 'abbreviated',
30062
+ context: 'formatting'
30063
+ });
30064
+
30065
+ case 'BBBBB':
30066
+ return localize.dayPeriod(dayPeriodEnumValue, {
30067
+ width: 'narrow',
30068
+ context: 'formatting'
30069
+ });
30070
+
30071
+ case 'BBBB':
30072
+ default:
30073
+ return localize.dayPeriod(dayPeriodEnumValue, {
30074
+ width: 'wide',
30075
+ context: 'formatting'
30076
+ });
30077
+ }
30078
+ },
30079
+ // Hour [1-12]
30080
+ h: function (date, token, localize) {
30081
+ if (token === 'ho') {
30082
+ var hours = date.getUTCHours() % 12;
30083
+ if (hours === 0) hours = 12;
30084
+ return localize.ordinalNumber(hours, {
30085
+ unit: 'hour'
30086
+ });
30087
+ }
30088
+
30089
+ return formatters$3.h(date, token);
30090
+ },
30091
+ // Hour [0-23]
30092
+ H: function (date, token, localize) {
30093
+ if (token === 'Ho') {
30094
+ return localize.ordinalNumber(date.getUTCHours(), {
30095
+ unit: 'hour'
30096
+ });
30097
+ }
30098
+
30099
+ return formatters$3.H(date, token);
30100
+ },
30101
+ // Hour [0-11]
30102
+ K: function (date, token, localize) {
30103
+ var hours = date.getUTCHours() % 12;
30104
+
30105
+ if (token === 'Ko') {
30106
+ return localize.ordinalNumber(hours, {
30107
+ unit: 'hour'
30108
+ });
30109
+ }
30110
+
30111
+ return addLeadingZeros(hours, token.length);
30112
+ },
30113
+ // Hour [1-24]
30114
+ k: function (date, token, localize) {
30115
+ var hours = date.getUTCHours();
30116
+ if (hours === 0) hours = 24;
30117
+
30118
+ if (token === 'ko') {
30119
+ return localize.ordinalNumber(hours, {
30120
+ unit: 'hour'
30121
+ });
30122
+ }
30123
+
30124
+ return addLeadingZeros(hours, token.length);
30125
+ },
30126
+ // Minute
30127
+ m: function (date, token, localize) {
30128
+ if (token === 'mo') {
30129
+ return localize.ordinalNumber(date.getUTCMinutes(), {
30130
+ unit: 'minute'
30131
+ });
30132
+ }
30133
+
30134
+ return formatters$3.m(date, token);
30135
+ },
30136
+ // Second
30137
+ s: function (date, token, localize) {
30138
+ if (token === 'so') {
30139
+ return localize.ordinalNumber(date.getUTCSeconds(), {
30140
+ unit: 'second'
30141
+ });
30142
+ }
30143
+
30144
+ return formatters$3.s(date, token);
30145
+ },
30146
+ // Fraction of second
30147
+ S: function (date, token) {
30148
+ return formatters$3.S(date, token);
30149
+ },
30150
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
30151
+ X: function (date, token, _localize, options) {
30152
+ var originalDate = options._originalDate || date;
30153
+ var timezoneOffset = originalDate.getTimezoneOffset();
30154
+
30155
+ if (timezoneOffset === 0) {
30156
+ return 'Z';
30157
+ }
30158
+
30159
+ switch (token) {
30160
+ // Hours and optional minutes
30161
+ case 'X':
30162
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
30163
+ // Hours, minutes and optional seconds without `:` delimiter
30164
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
30165
+ // so this token always has the same output as `XX`
30166
+
30167
+ case 'XXXX':
30168
+ case 'XX':
30169
+ // Hours and minutes without `:` delimiter
30170
+ return formatTimezone(timezoneOffset);
30171
+ // Hours, minutes and optional seconds with `:` delimiter
30172
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
30173
+ // so this token always has the same output as `XXX`
30174
+
30175
+ case 'XXXXX':
30176
+ case 'XXX': // Hours and minutes with `:` delimiter
30177
+
30178
+ default:
30179
+ return formatTimezone(timezoneOffset, ':');
30180
+ }
30181
+ },
30182
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
30183
+ x: function (date, token, _localize, options) {
30184
+ var originalDate = options._originalDate || date;
30185
+ var timezoneOffset = originalDate.getTimezoneOffset();
30186
+
30187
+ switch (token) {
30188
+ // Hours and optional minutes
30189
+ case 'x':
30190
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
30191
+ // Hours, minutes and optional seconds without `:` delimiter
30192
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
30193
+ // so this token always has the same output as `xx`
30194
+
30195
+ case 'xxxx':
30196
+ case 'xx':
30197
+ // Hours and minutes without `:` delimiter
30198
+ return formatTimezone(timezoneOffset);
30199
+ // Hours, minutes and optional seconds with `:` delimiter
30200
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
30201
+ // so this token always has the same output as `xxx`
30202
+
30203
+ case 'xxxxx':
30204
+ case 'xxx': // Hours and minutes with `:` delimiter
30205
+
30206
+ default:
30207
+ return formatTimezone(timezoneOffset, ':');
30208
+ }
30209
+ },
30210
+ // Timezone (GMT)
30211
+ O: function (date, token, _localize, options) {
30212
+ var originalDate = options._originalDate || date;
30213
+ var timezoneOffset = originalDate.getTimezoneOffset();
30214
+
30215
+ switch (token) {
30216
+ // Short
30217
+ case 'O':
30218
+ case 'OO':
30219
+ case 'OOO':
30220
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
30221
+ // Long
30222
+
30223
+ case 'OOOO':
30224
+ default:
30225
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
30226
+ }
30227
+ },
30228
+ // Timezone (specific non-location)
30229
+ z: function (date, token, _localize, options) {
30230
+ var originalDate = options._originalDate || date;
30231
+ var timezoneOffset = originalDate.getTimezoneOffset();
30232
+
30233
+ switch (token) {
30234
+ // Short
30235
+ case 'z':
30236
+ case 'zz':
30237
+ case 'zzz':
30238
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
30239
+ // Long
30240
+
30241
+ case 'zzzz':
30242
+ default:
30243
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
30244
+ }
30245
+ },
30246
+ // Seconds timestamp
30247
+ t: function (date, token, _localize, options) {
30248
+ var originalDate = options._originalDate || date;
30249
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
30250
+ return addLeadingZeros(timestamp, token.length);
30251
+ },
30252
+ // Milliseconds timestamp
30253
+ T: function (date, token, _localize, options) {
30254
+ var originalDate = options._originalDate || date;
30255
+ var timestamp = originalDate.getTime();
30256
+ return addLeadingZeros(timestamp, token.length);
30257
+ }
30258
+ };
30259
+
30260
+ function formatTimezoneShort(offset, dirtyDelimiter) {
30261
+ var sign = offset > 0 ? '-' : '+';
30262
+ var absOffset = Math.abs(offset);
30263
+ var hours = Math.floor(absOffset / 60);
30264
+ var minutes = absOffset % 60;
30265
+
30266
+ if (minutes === 0) {
30267
+ return sign + String(hours);
30268
+ }
30269
+
30270
+ var delimiter = dirtyDelimiter || '';
30271
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
30272
+ }
30273
+
30274
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
30275
+ if (offset % 60 === 0) {
30276
+ var sign = offset > 0 ? '-' : '+';
30277
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
30278
+ }
30279
+
30280
+ return formatTimezone(offset, dirtyDelimiter);
30281
+ }
30282
+
30283
+ function formatTimezone(offset, dirtyDelimiter) {
30284
+ var delimiter = dirtyDelimiter || '';
30285
+ var sign = offset > 0 ? '-' : '+';
30286
+ var absOffset = Math.abs(offset);
30287
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
30288
+ var minutes = addLeadingZeros(absOffset % 60, 2);
30289
+ return sign + hours + delimiter + minutes;
30290
+ }
30291
+
30292
+ var formatters$1 = formatters;
30293
+
30294
+ function dateLongFormatter(pattern, formatLong) {
30295
+ switch (pattern) {
30296
+ case 'P':
30297
+ return formatLong.date({
30298
+ width: 'short'
30299
+ });
30300
+
30301
+ case 'PP':
30302
+ return formatLong.date({
30303
+ width: 'medium'
30304
+ });
30305
+
30306
+ case 'PPP':
30307
+ return formatLong.date({
30308
+ width: 'long'
30309
+ });
30310
+
30311
+ case 'PPPP':
30312
+ default:
30313
+ return formatLong.date({
30314
+ width: 'full'
30315
+ });
30316
+ }
30317
+ }
30318
+
30319
+ function timeLongFormatter(pattern, formatLong) {
30320
+ switch (pattern) {
30321
+ case 'p':
30322
+ return formatLong.time({
30323
+ width: 'short'
30324
+ });
30325
+
30326
+ case 'pp':
30327
+ return formatLong.time({
30328
+ width: 'medium'
30329
+ });
30330
+
30331
+ case 'ppp':
30332
+ return formatLong.time({
30333
+ width: 'long'
30334
+ });
30335
+
30336
+ case 'pppp':
30337
+ default:
30338
+ return formatLong.time({
30339
+ width: 'full'
30340
+ });
30341
+ }
30342
+ }
30343
+
30344
+ function dateTimeLongFormatter(pattern, formatLong) {
30345
+ var matchResult = pattern.match(/(P+)(p+)?/);
30346
+ var datePattern = matchResult[1];
30347
+ var timePattern = matchResult[2];
30348
+
30349
+ if (!timePattern) {
30350
+ return dateLongFormatter(pattern, formatLong);
30351
+ }
30352
+
30353
+ var dateTimeFormat;
30354
+
30355
+ switch (datePattern) {
30356
+ case 'P':
30357
+ dateTimeFormat = formatLong.dateTime({
30358
+ width: 'short'
30359
+ });
30360
+ break;
30361
+
30362
+ case 'PP':
30363
+ dateTimeFormat = formatLong.dateTime({
30364
+ width: 'medium'
30365
+ });
30366
+ break;
30367
+
30368
+ case 'PPP':
30369
+ dateTimeFormat = formatLong.dateTime({
30370
+ width: 'long'
30371
+ });
30372
+ break;
30373
+
30374
+ case 'PPPP':
30375
+ default:
30376
+ dateTimeFormat = formatLong.dateTime({
30377
+ width: 'full'
30378
+ });
30379
+ break;
30380
+ }
30381
+
30382
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
30383
+ }
30384
+
30385
+ var longFormatters = {
30386
+ p: timeLongFormatter,
30387
+ P: dateTimeLongFormatter
30388
+ };
30389
+ var longFormatters$1 = longFormatters;
30390
+
30391
+ var protectedDayOfYearTokens = ['D', 'DD'];
30392
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
30393
+ function isProtectedDayOfYearToken(token) {
30394
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
30395
+ }
30396
+ function isProtectedWeekYearToken(token) {
30397
+ return protectedWeekYearTokens.indexOf(token) !== -1;
30398
+ }
30399
+ function throwProtectedError(token, format, input) {
30400
+ if (token === 'YYYY') {
30401
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
30402
+ } else if (token === 'YY') {
30403
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
30404
+ } else if (token === 'D') {
30405
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
30406
+ } else if (token === 'DD') {
30407
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
30408
+ }
30409
+ }
30410
+
30411
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
30412
+ // (one of the certain letters followed by `o`)
30413
+ // - (\w)\1* matches any sequences of the same letter
30414
+ // - '' matches two quote characters in a row
30415
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
30416
+ // except a single quote symbol, which ends the sequence.
30417
+ // Two quote characters do not end the sequence.
30418
+ // If there is no matching single quote
30419
+ // then the sequence will continue until the end of the string.
30420
+ // - . matches any single character unmatched by previous parts of the RegExps
30421
+
30422
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also
30423
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
30424
+
30425
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
30426
+ var escapedStringRegExp = /^'([^]*?)'?$/;
30427
+ var doubleQuoteRegExp = /''/g;
30428
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
30429
+ /**
30430
+ * @name format
30431
+ * @category Common Helpers
30432
+ * @summary Format the date.
30433
+ *
30434
+ * @description
30435
+ * Return the formatted date string in the given format. The result may vary by locale.
30436
+ *
30437
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
30438
+ * > See: https://git.io/fxCyr
30439
+ *
30440
+ * The characters wrapped between two single quotes characters (') are escaped.
30441
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
30442
+ * (see the last example)
30443
+ *
30444
+ * Format of the string is based on Unicode Technical Standard #35:
30445
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
30446
+ * with a few additions (see note 7 below the table).
30447
+ *
30448
+ * Accepted patterns:
30449
+ * | Unit | Pattern | Result examples | Notes |
30450
+ * |---------------------------------|---------|-----------------------------------|-------|
30451
+ * | Era | G..GGG | AD, BC | |
30452
+ * | | GGGG | Anno Domini, Before Christ | 2 |
30453
+ * | | GGGGG | A, B | |
30454
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
30455
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
30456
+ * | | yy | 44, 01, 00, 17 | 5 |
30457
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
30458
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
30459
+ * | | yyyyy | ... | 3,5 |
30460
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
30461
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
30462
+ * | | YY | 44, 01, 00, 17 | 5,8 |
30463
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
30464
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
30465
+ * | | YYYYY | ... | 3,5 |
30466
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
30467
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
30468
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
30469
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
30470
+ * | | RRRRR | ... | 3,5,7 |
30471
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
30472
+ * | | uu | -43, 01, 1900, 2017 | 5 |
30473
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
30474
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
30475
+ * | | uuuuu | ... | 3,5 |
30476
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
30477
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
30478
+ * | | QQ | 01, 02, 03, 04 | |
30479
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
30480
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
30481
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
30482
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
30483
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
30484
+ * | | qq | 01, 02, 03, 04 | |
30485
+ * | | qqq | Q1, Q2, Q3, Q4 | |
30486
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
30487
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
30488
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
30489
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
30490
+ * | | MM | 01, 02, ..., 12 | |
30491
+ * | | MMM | Jan, Feb, ..., Dec | |
30492
+ * | | MMMM | January, February, ..., December | 2 |
30493
+ * | | MMMMM | J, F, ..., D | |
30494
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
30495
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
30496
+ * | | LL | 01, 02, ..., 12 | |
30497
+ * | | LLL | Jan, Feb, ..., Dec | |
30498
+ * | | LLLL | January, February, ..., December | 2 |
30499
+ * | | LLLLL | J, F, ..., D | |
30500
+ * | Local week of year | w | 1, 2, ..., 53 | |
30501
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
30502
+ * | | ww | 01, 02, ..., 53 | |
30503
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
30504
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
30505
+ * | | II | 01, 02, ..., 53 | 7 |
30506
+ * | Day of month | d | 1, 2, ..., 31 | |
30507
+ * | | do | 1st, 2nd, ..., 31st | 7 |
30508
+ * | | dd | 01, 02, ..., 31 | |
30509
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
30510
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
30511
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
30512
+ * | | DDD | 001, 002, ..., 365, 366 | |
30513
+ * | | DDDD | ... | 3 |
30514
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
30515
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
30516
+ * | | EEEEE | M, T, W, T, F, S, S | |
30517
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Su, Sa | |
30518
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
30519
+ * | | io | 1st, 2nd, ..., 7th | 7 |
30520
+ * | | ii | 01, 02, ..., 07 | 7 |
30521
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
30522
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
30523
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
30524
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Su, Sa | 7 |
30525
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
30526
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
30527
+ * | | ee | 02, 03, ..., 01 | |
30528
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
30529
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
30530
+ * | | eeeee | M, T, W, T, F, S, S | |
30531
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Su, Sa | |
30532
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
30533
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
30534
+ * | | cc | 02, 03, ..., 01 | |
30535
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
30536
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
30537
+ * | | ccccc | M, T, W, T, F, S, S | |
30538
+ * | | cccccc | Mo, Tu, We, Th, Fr, Su, Sa | |
30539
+ * | AM, PM | a..aaa | AM, PM | |
30540
+ * | | aaaa | a.m., p.m. | 2 |
30541
+ * | | aaaaa | a, p | |
30542
+ * | AM, PM, noon, midnight | b..bbb | AM, PM, noon, midnight | |
30543
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
30544
+ * | | bbbbb | a, p, n, mi | |
30545
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
30546
+ * | | BBBB | at night, in the morning, ... | 2 |
30547
+ * | | BBBBB | at night, in the morning, ... | |
30548
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
30549
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
30550
+ * | | hh | 01, 02, ..., 11, 12 | |
30551
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
30552
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
30553
+ * | | HH | 00, 01, 02, ..., 23 | |
30554
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
30555
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
30556
+ * | | KK | 01, 02, ..., 11, 00 | |
30557
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
30558
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
30559
+ * | | kk | 24, 01, 02, ..., 23 | |
30560
+ * | Minute | m | 0, 1, ..., 59 | |
30561
+ * | | mo | 0th, 1st, ..., 59th | 7 |
30562
+ * | | mm | 00, 01, ..., 59 | |
30563
+ * | Second | s | 0, 1, ..., 59 | |
30564
+ * | | so | 0th, 1st, ..., 59th | 7 |
30565
+ * | | ss | 00, 01, ..., 59 | |
30566
+ * | Fraction of second | S | 0, 1, ..., 9 | |
30567
+ * | | SS | 00, 01, ..., 99 | |
30568
+ * | | SSS | 000, 0001, ..., 999 | |
30569
+ * | | SSSS | ... | 3 |
30570
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
30571
+ * | | XX | -0800, +0530, Z | |
30572
+ * | | XXX | -08:00, +05:30, Z | |
30573
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
30574
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
30575
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
30576
+ * | | xx | -0800, +0530, +0000 | |
30577
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
30578
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
30579
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
30580
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
30581
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
30582
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
30583
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
30584
+ * | Seconds timestamp | t | 512969520 | 7 |
30585
+ * | | tt | ... | 3,7 |
30586
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
30587
+ * | | TT | ... | 3,7 |
30588
+ * | Long localized date | P | 05/29/1453 | 7 |
30589
+ * | | PP | May 29, 1453 | 7 |
30590
+ * | | PPP | May 29th, 1453 | 7 |
30591
+ * | | PPPP | Sunday, May 29th, 1453 | 2,7 |
30592
+ * | Long localized time | p | 12:00 AM | 7 |
30593
+ * | | pp | 12:00:00 AM | 7 |
30594
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
30595
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
30596
+ * | Combination of date and time | Pp | 05/29/1453, 12:00 AM | 7 |
30597
+ * | | PPpp | May 29, 1453, 12:00:00 AM | 7 |
30598
+ * | | PPPppp | May 29th, 1453 at ... | 7 |
30599
+ * | | PPPPpppp| Sunday, May 29th, 1453 at ... | 2,7 |
30600
+ * Notes:
30601
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
30602
+ * are the same as "stand-alone" units, but are different in some languages.
30603
+ * "Formatting" units are declined according to the rules of the language
30604
+ * in the context of a date. "Stand-alone" units are always nominative singular:
30605
+ *
30606
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
30607
+ *
30608
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
30609
+ *
30610
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
30611
+ * the single quote characters (see below).
30612
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
30613
+ * the output will be the same as default pattern for this unit, usually
30614
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
30615
+ * are marked with "2" in the last column of the table.
30616
+ *
30617
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
30618
+ *
30619
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
30620
+ *
30621
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
30622
+ *
30623
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
30624
+ *
30625
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
30626
+ *
30627
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
30628
+ * The output will be padded with zeros to match the length of the pattern.
30629
+ *
30630
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
30631
+ *
30632
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
30633
+ * These tokens represent the shortest form of the quarter.
30634
+ *
30635
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
30636
+ *
30637
+ * | Year | `y` | `u` |
30638
+ * |------|-----|-----|
30639
+ * | AC 1 | 1 | 1 |
30640
+ * | BC 1 | 1 | 0 |
30641
+ * | BC 2 | 2 | -1 |
30642
+ *
30643
+ * Also `yy` always returns the last two digits of a year,
30644
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
30645
+ *
30646
+ * | Year | `yy` | `uu` |
30647
+ * |------|------|------|
30648
+ * | 1 | 01 | 01 |
30649
+ * | 14 | 14 | 14 |
30650
+ * | 376 | 76 | 376 |
30651
+ * | 1453 | 53 | 1453 |
30652
+ *
30653
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
30654
+ * except local week-numbering years are dependent on `options.weekStartsOn`
30655
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
30656
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
30657
+ *
30658
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
30659
+ * so right now these tokens fall back to GMT timezones.
30660
+ *
30661
+ * 7. These patterns are not in the Unicode Technical Standard #35:
30662
+ * - `i`: ISO day of week
30663
+ * - `I`: ISO week of year
30664
+ * - `R`: ISO week-numbering year
30665
+ * - `t`: seconds timestamp
30666
+ * - `T`: milliseconds timestamp
30667
+ * - `o`: ordinal number modifier
30668
+ * - `P`: long localized date
30669
+ * - `p`: long localized time
30670
+ *
30671
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
30672
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr
30673
+ *
30674
+ * 9. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.
30675
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr
30676
+ *
30677
+ * ### v2.0.0 breaking changes:
30678
+ *
30679
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
30680
+ *
30681
+ * - The second argument is now required for the sake of explicitness.
30682
+ *
30683
+ * ```javascript
30684
+ * // Before v2.0.0
30685
+ * format(new Date(2016, 0, 1))
30686
+ *
30687
+ * // v2.0.0 onward
30688
+ * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
30689
+ * ```
30690
+ *
30691
+ * - New format string API for `format` function
30692
+ * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
30693
+ * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
30694
+ *
30695
+ * - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
30696
+ *
30697
+ * @param {Date|Number} date - the original date
30698
+ * @param {String} format - the string of tokens
30699
+ * @param {Object} [options] - an object with options.
30700
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
30701
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
30702
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
30703
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
30704
+ * see: https://git.io/fxCyr
30705
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
30706
+ * see: https://git.io/fxCyr
30707
+ * @returns {String} the formatted date string
30708
+ * @throws {TypeError} 2 arguments required
30709
+ * @throws {RangeError} `date` must not be Invalid Date
30710
+ * @throws {RangeError} `options.locale` must contain `localize` property
30711
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
30712
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
30713
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
30714
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
30715
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
30716
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
30717
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
30718
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
30719
+ *
30720
+ * @example
30721
+ * // Represent 11 February 2014 in middle-endian format:
30722
+ * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
30723
+ * //=> '02/11/2014'
30724
+ *
30725
+ * @example
30726
+ * // Represent 2 July 2014 in Esperanto:
30727
+ * import { eoLocale } from 'date-fns/locale/eo'
30728
+ * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
30729
+ * locale: eoLocale
30730
+ * })
30731
+ * //=> '2-a de julio 2014'
30732
+ *
30733
+ * @example
30734
+ * // Escape string by single quote characters:
30735
+ * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
30736
+ * //=> "3 o'clock"
30737
+ */
30738
+
30739
+ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
30740
+ requiredArgs(2, arguments);
30741
+ var formatStr = String(dirtyFormatStr);
30742
+ var options = dirtyOptions || {};
30743
+ var locale = options.locale || defaultLocale;
30744
+ var localeFirstWeekContainsDate = locale.options && locale.options.firstWeekContainsDate;
30745
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
30746
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
30747
+
30748
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
30749
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
30750
+ }
30751
+
30752
+ var localeWeekStartsOn = locale.options && locale.options.weekStartsOn;
30753
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
30754
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
30755
+
30756
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
30757
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
30758
+ }
30759
+
30760
+ if (!locale.localize) {
30761
+ throw new RangeError('locale must contain localize property');
30762
+ }
30763
+
30764
+ if (!locale.formatLong) {
30765
+ throw new RangeError('locale must contain formatLong property');
30766
+ }
30767
+
30768
+ var originalDate = toDate(dirtyDate);
30769
+
30770
+ if (!isValid(originalDate)) {
30771
+ throw new RangeError('Invalid time value');
30772
+ } // Convert the date in system timezone to the same date in UTC+00:00 timezone.
30773
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
30774
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
30775
+
30776
+
30777
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
30778
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
30779
+ var formatterOptions = {
30780
+ firstWeekContainsDate: firstWeekContainsDate,
30781
+ weekStartsOn: weekStartsOn,
30782
+ locale: locale,
30783
+ _originalDate: originalDate
30784
+ };
30785
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
30786
+ var firstCharacter = substring[0];
30787
+
30788
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
30789
+ var longFormatter = longFormatters$1[firstCharacter];
30790
+ return longFormatter(substring, locale.formatLong, formatterOptions);
30791
+ }
30792
+
30793
+ return substring;
30794
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
30795
+ // Replace two single quote characters with one single quote character
30796
+ if (substring === "''") {
30797
+ return "'";
30798
+ }
30799
+
30800
+ var firstCharacter = substring[0];
30801
+
30802
+ if (firstCharacter === "'") {
30803
+ return cleanEscapedString(substring);
30804
+ }
30805
+
30806
+ var formatter = formatters$1[firstCharacter];
30807
+
30808
+ if (formatter) {
30809
+ if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
30810
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
30811
+ }
30812
+
30813
+ if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
30814
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
30815
+ }
30816
+
30817
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
30818
+ }
30819
+
30820
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
30821
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
30822
+ }
30823
+
30824
+ return substring;
30825
+ }).join('');
30826
+ return result;
30827
+ }
30828
+
30829
+ function cleanEscapedString(input) {
30830
+ return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
30831
+ }
30832
+
28413
30833
  const buildRow = (record, sheet) => {
28414
30834
  return sheet.columns.map((x) => x.value(record));
28415
30835
  };
@@ -28460,11 +30880,24 @@ const normalizeKey = (colName, colIndex, keysTransform) => {
28460
30880
  }
28461
30881
  return colName;
28462
30882
  };
30883
+ const excelSerialToDate = (serial) => {
30884
+ const excelStartDate = new Date(1900, 0, 1);
30885
+ const daysSinceStart = serial - 2;
30886
+ const date = addDays(excelStartDate, daysSinceStart);
30887
+ return format(date, "yyyy-MM-dd");
30888
+ };
28463
30889
  const aggregateRow = (header, row, options) => {
28464
30890
  const record = {};
28465
30891
  row.forEach((value, index) => {
28466
30892
  const key = normalizeKey(header[index], index, options?.keysTransform);
28467
- record[key] = value;
30893
+ if (options?.dateColumns?.includes(key) &&
30894
+ typeof value === "number" &&
30895
+ value > 59) {
30896
+ record[key] = excelSerialToDate(value);
30897
+ }
30898
+ else {
30899
+ record[key] = value;
30900
+ }
28468
30901
  });
28469
30902
  return record;
28470
30903
  };