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