@dartcom/ui-kit 10.4.0 → 10.4.1

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/index.cjs CHANGED
@@ -7562,6 +7562,2837 @@ class LocalStateService {
7562
7562
  }
7563
7563
  const localStateService = new LocalStateService();
7564
7564
 
7565
+ /**
7566
+ * @module constants
7567
+ * @summary Useful constants
7568
+ * @description
7569
+ * Collection of useful date constants.
7570
+ *
7571
+ * The constants could be imported from `date-fns/constants`:
7572
+ *
7573
+ * ```ts
7574
+ * import { maxTime, minTime } from "./constants/date-fns/constants";
7575
+ *
7576
+ * function isAllowedTime(time) {
7577
+ * return time <= maxTime && time >= minTime;
7578
+ * }
7579
+ * ```
7580
+ */
7581
+
7582
+
7583
+ /**
7584
+ * @constant
7585
+ * @name millisecondsInWeek
7586
+ * @summary Milliseconds in 1 week.
7587
+ */
7588
+ const millisecondsInWeek = 604800000;
7589
+
7590
+ /**
7591
+ * @constant
7592
+ * @name millisecondsInDay
7593
+ * @summary Milliseconds in 1 day.
7594
+ */
7595
+ const millisecondsInDay = 86400000;
7596
+
7597
+ /**
7598
+ * @constant
7599
+ * @name constructFromSymbol
7600
+ * @summary Symbol enabling Date extensions to inherit properties from the reference date.
7601
+ *
7602
+ * The symbol is used to enable the `constructFrom` function to construct a date
7603
+ * using a reference date and a value. It allows to transfer extra properties
7604
+ * from the reference date to the new date. It's useful for extensions like
7605
+ * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as
7606
+ * a constructor argument.
7607
+ */
7608
+ const constructFromSymbol = Symbol.for("constructDateFrom");
7609
+
7610
+ /**
7611
+ * @name constructFrom
7612
+ * @category Generic Helpers
7613
+ * @summary Constructs a date using the reference date and the value
7614
+ *
7615
+ * @description
7616
+ * The function constructs a new date using the constructor from the reference
7617
+ * date and the given value. It helps to build generic functions that accept
7618
+ * date extensions.
7619
+ *
7620
+ * It defaults to `Date` if the passed reference date is a number or a string.
7621
+ *
7622
+ * Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]`
7623
+ * enabling to transfer extra properties from the reference date to the new date.
7624
+ * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
7625
+ * that accept a time zone as a constructor argument.
7626
+ *
7627
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
7628
+ *
7629
+ * @param date - The reference date to take constructor from
7630
+ * @param value - The value to create the date
7631
+ *
7632
+ * @returns Date initialized using the given date and value
7633
+ *
7634
+ * @example
7635
+ * import { constructFrom } from "./constructFrom/date-fns";
7636
+ *
7637
+ * // A function that clones a date preserving the original type
7638
+ * function cloneDate<DateType extends Date>(date: DateType): DateType {
7639
+ * return constructFrom(
7640
+ * date, // Use constructor from the given date
7641
+ * date.getTime() // Use the date value to create a new date
7642
+ * );
7643
+ * }
7644
+ */
7645
+ function constructFrom(date, value) {
7646
+ if (typeof date === "function") return date(value);
7647
+
7648
+ if (date && typeof date === "object" && constructFromSymbol in date)
7649
+ return date[constructFromSymbol](value);
7650
+
7651
+ if (date instanceof Date) return new date.constructor(value);
7652
+
7653
+ return new Date(value);
7654
+ }
7655
+
7656
+ /**
7657
+ * @name toDate
7658
+ * @category Common Helpers
7659
+ * @summary Convert the given argument to an instance of Date.
7660
+ *
7661
+ * @description
7662
+ * Convert the given argument to an instance of Date.
7663
+ *
7664
+ * If the argument is an instance of Date, the function returns its clone.
7665
+ *
7666
+ * If the argument is a number, it is treated as a timestamp.
7667
+ *
7668
+ * If the argument is none of the above, the function returns Invalid Date.
7669
+ *
7670
+ * Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]`
7671
+ * enabling to transfer extra properties from the reference date to the new date.
7672
+ * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
7673
+ * that accept a time zone as a constructor argument.
7674
+ *
7675
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
7676
+ *
7677
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
7678
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
7679
+ *
7680
+ * @param argument - The value to convert
7681
+ *
7682
+ * @returns The parsed date in the local time zone
7683
+ *
7684
+ * @example
7685
+ * // Clone the date:
7686
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
7687
+ * //=> Tue Feb 11 2014 11:30:30
7688
+ *
7689
+ * @example
7690
+ * // Convert the timestamp to date:
7691
+ * const result = toDate(1392098430000)
7692
+ * //=> Tue Feb 11 2014 11:30:30
7693
+ */
7694
+ function toDate(argument, context) {
7695
+ // [TODO] Get rid of `toDate` or `constructFrom`?
7696
+ return constructFrom(context || argument, argument);
7697
+ }
7698
+
7699
+ let defaultOptions$2 = {};
7700
+
7701
+ function getDefaultOptions() {
7702
+ return defaultOptions$2;
7703
+ }
7704
+
7705
+ /**
7706
+ * The {@link startOfWeek} function options.
7707
+ */
7708
+
7709
+ /**
7710
+ * @name startOfWeek
7711
+ * @category Week Helpers
7712
+ * @summary Return the start of a week for the given date.
7713
+ *
7714
+ * @description
7715
+ * Return the start of a week for the given date.
7716
+ * The result will be in the local timezone.
7717
+ *
7718
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
7719
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
7720
+ *
7721
+ * @param date - The original date
7722
+ * @param options - An object with options
7723
+ *
7724
+ * @returns The start of a week
7725
+ *
7726
+ * @example
7727
+ * // The start of a week for 2 September 2014 11:55:00:
7728
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
7729
+ * //=> Sun Aug 31 2014 00:00:00
7730
+ *
7731
+ * @example
7732
+ * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
7733
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
7734
+ * //=> Mon Sep 01 2014 00:00:00
7735
+ */
7736
+ function startOfWeek(date, options) {
7737
+ const defaultOptions = getDefaultOptions();
7738
+ const weekStartsOn =
7739
+ options?.weekStartsOn ??
7740
+ options?.locale?.options?.weekStartsOn ??
7741
+ defaultOptions.weekStartsOn ??
7742
+ defaultOptions.locale?.options?.weekStartsOn ??
7743
+ 0;
7744
+
7745
+ const _date = toDate(date, options?.in);
7746
+ const day = _date.getDay();
7747
+ const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
7748
+
7749
+ _date.setDate(_date.getDate() - diff);
7750
+ _date.setHours(0, 0, 0, 0);
7751
+ return _date;
7752
+ }
7753
+
7754
+ /**
7755
+ * The {@link startOfISOWeek} function options.
7756
+ */
7757
+
7758
+ /**
7759
+ * @name startOfISOWeek
7760
+ * @category ISO Week Helpers
7761
+ * @summary Return the start of an ISO week for the given date.
7762
+ *
7763
+ * @description
7764
+ * Return the start of an ISO week for the given date.
7765
+ * The result will be in the local timezone.
7766
+ *
7767
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
7768
+ *
7769
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
7770
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
7771
+ *
7772
+ * @param date - The original date
7773
+ * @param options - An object with options
7774
+ *
7775
+ * @returns The start of an ISO week
7776
+ *
7777
+ * @example
7778
+ * // The start of an ISO week for 2 September 2014 11:55:00:
7779
+ * const result = startOfISOWeek(new Date(2014, 8, 2, 11, 55, 0))
7780
+ * //=> Mon Sep 01 2014 00:00:00
7781
+ */
7782
+ function startOfISOWeek(date, options) {
7783
+ return startOfWeek(date, { ...options, weekStartsOn: 1 });
7784
+ }
7785
+
7786
+ /**
7787
+ * The {@link getISOWeekYear} function options.
7788
+ */
7789
+
7790
+ /**
7791
+ * @name getISOWeekYear
7792
+ * @category ISO Week-Numbering Year Helpers
7793
+ * @summary Get the ISO week-numbering year of the given date.
7794
+ *
7795
+ * @description
7796
+ * Get the ISO week-numbering year of the given date,
7797
+ * which always starts 3 days before the year's first Thursday.
7798
+ *
7799
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
7800
+ *
7801
+ * @param date - The given date
7802
+ *
7803
+ * @returns The ISO week-numbering year
7804
+ *
7805
+ * @example
7806
+ * // Which ISO-week numbering year is 2 January 2005?
7807
+ * const result = getISOWeekYear(new Date(2005, 0, 2))
7808
+ * //=> 2004
7809
+ */
7810
+ function getISOWeekYear(date, options) {
7811
+ const _date = toDate(date, options?.in);
7812
+ const year = _date.getFullYear();
7813
+
7814
+ const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
7815
+ fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
7816
+ fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
7817
+ const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
7818
+
7819
+ const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
7820
+ fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
7821
+ fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
7822
+ const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
7823
+
7824
+ if (_date.getTime() >= startOfNextYear.getTime()) {
7825
+ return year + 1;
7826
+ } else if (_date.getTime() >= startOfThisYear.getTime()) {
7827
+ return year;
7828
+ } else {
7829
+ return year - 1;
7830
+ }
7831
+ }
7832
+
7833
+ /**
7834
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
7835
+ * They usually appear for dates that denote time before the timezones were introduced
7836
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
7837
+ * and GMT+01:00:00 after that date)
7838
+ *
7839
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
7840
+ * which would lead to incorrect calculations.
7841
+ *
7842
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
7843
+ */
7844
+ function getTimezoneOffsetInMilliseconds(date) {
7845
+ const _date = toDate(date);
7846
+ const utcDate = new Date(
7847
+ Date.UTC(
7848
+ _date.getFullYear(),
7849
+ _date.getMonth(),
7850
+ _date.getDate(),
7851
+ _date.getHours(),
7852
+ _date.getMinutes(),
7853
+ _date.getSeconds(),
7854
+ _date.getMilliseconds(),
7855
+ ),
7856
+ );
7857
+ utcDate.setUTCFullYear(_date.getFullYear());
7858
+ return +date - +utcDate;
7859
+ }
7860
+
7861
+ function normalizeDates(context, ...dates) {
7862
+ const normalize = constructFrom.bind(
7863
+ null,
7864
+ context || dates.find((date) => typeof date === "object"),
7865
+ );
7866
+ return dates.map(normalize);
7867
+ }
7868
+
7869
+ /**
7870
+ * The {@link startOfDay} function options.
7871
+ */
7872
+
7873
+ /**
7874
+ * @name startOfDay
7875
+ * @category Day Helpers
7876
+ * @summary Return the start of a day for the given date.
7877
+ *
7878
+ * @description
7879
+ * Return the start of a day for the given date.
7880
+ * The result will be in the local timezone.
7881
+ *
7882
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
7883
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
7884
+ *
7885
+ * @param date - The original date
7886
+ * @param options - The options
7887
+ *
7888
+ * @returns The start of a day
7889
+ *
7890
+ * @example
7891
+ * // The start of a day for 2 September 2014 11:55:00:
7892
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
7893
+ * //=> Tue Sep 02 2014 00:00:00
7894
+ */
7895
+ function startOfDay(date, options) {
7896
+ const _date = toDate(date, options?.in);
7897
+ _date.setHours(0, 0, 0, 0);
7898
+ return _date;
7899
+ }
7900
+
7901
+ /**
7902
+ * The {@link differenceInCalendarDays} function options.
7903
+ */
7904
+
7905
+ /**
7906
+ * @name differenceInCalendarDays
7907
+ * @category Day Helpers
7908
+ * @summary Get the number of calendar days between the given dates.
7909
+ *
7910
+ * @description
7911
+ * Get the number of calendar days between the given dates. This means that the times are removed
7912
+ * from the dates and then the difference in days is calculated.
7913
+ *
7914
+ * @param laterDate - The later date
7915
+ * @param earlierDate - The earlier date
7916
+ * @param options - The options object
7917
+ *
7918
+ * @returns The number of calendar days
7919
+ *
7920
+ * @example
7921
+ * // How many calendar days are between
7922
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
7923
+ * const result = differenceInCalendarDays(
7924
+ * new Date(2012, 6, 2, 0, 0),
7925
+ * new Date(2011, 6, 2, 23, 0)
7926
+ * )
7927
+ * //=> 366
7928
+ * // How many calendar days are between
7929
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
7930
+ * const result = differenceInCalendarDays(
7931
+ * new Date(2011, 6, 3, 0, 1),
7932
+ * new Date(2011, 6, 2, 23, 59)
7933
+ * )
7934
+ * //=> 1
7935
+ */
7936
+ function differenceInCalendarDays(laterDate, earlierDate, options) {
7937
+ const [laterDate_, earlierDate_] = normalizeDates(
7938
+ options?.in,
7939
+ laterDate,
7940
+ earlierDate,
7941
+ );
7942
+
7943
+ const laterStartOfDay = startOfDay(laterDate_);
7944
+ const earlierStartOfDay = startOfDay(earlierDate_);
7945
+
7946
+ const laterTimestamp =
7947
+ +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
7948
+ const earlierTimestamp =
7949
+ +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
7950
+
7951
+ // Round the number of days to the nearest integer because the number of
7952
+ // milliseconds in a day is not constant (e.g. it's different in the week of
7953
+ // the daylight saving time clock shift).
7954
+ return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
7955
+ }
7956
+
7957
+ /**
7958
+ * The {@link startOfISOWeekYear} function options.
7959
+ */
7960
+
7961
+ /**
7962
+ * @name startOfISOWeekYear
7963
+ * @category ISO Week-Numbering Year Helpers
7964
+ * @summary Return the start of an ISO week-numbering year for the given date.
7965
+ *
7966
+ * @description
7967
+ * Return the start of an ISO week-numbering year,
7968
+ * which always starts 3 days before the year's first Thursday.
7969
+ * The result will be in the local timezone.
7970
+ *
7971
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
7972
+ *
7973
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
7974
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
7975
+ *
7976
+ * @param date - The original date
7977
+ * @param options - An object with options
7978
+ *
7979
+ * @returns The start of an ISO week-numbering year
7980
+ *
7981
+ * @example
7982
+ * // The start of an ISO week-numbering year for 2 July 2005:
7983
+ * const result = startOfISOWeekYear(new Date(2005, 6, 2))
7984
+ * //=> Mon Jan 03 2005 00:00:00
7985
+ */
7986
+ function startOfISOWeekYear(date, options) {
7987
+ const year = getISOWeekYear(date, options);
7988
+ const fourthOfJanuary = constructFrom(date, 0);
7989
+ fourthOfJanuary.setFullYear(year, 0, 4);
7990
+ fourthOfJanuary.setHours(0, 0, 0, 0);
7991
+ return startOfISOWeek(fourthOfJanuary);
7992
+ }
7993
+
7994
+ /**
7995
+ * @name isDate
7996
+ * @category Common Helpers
7997
+ * @summary Is the given value a date?
7998
+ *
7999
+ * @description
8000
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
8001
+ *
8002
+ * @param value - The value to check
8003
+ *
8004
+ * @returns True if the given value is a date
8005
+ *
8006
+ * @example
8007
+ * // For a valid date:
8008
+ * const result = isDate(new Date())
8009
+ * //=> true
8010
+ *
8011
+ * @example
8012
+ * // For an invalid date:
8013
+ * const result = isDate(new Date(NaN))
8014
+ * //=> true
8015
+ *
8016
+ * @example
8017
+ * // For some value:
8018
+ * const result = isDate('2014-02-31')
8019
+ * //=> false
8020
+ *
8021
+ * @example
8022
+ * // For an object:
8023
+ * const result = isDate({})
8024
+ * //=> false
8025
+ */
8026
+ function isDate$1(value) {
8027
+ return (
8028
+ value instanceof Date ||
8029
+ (typeof value === "object" &&
8030
+ Object.prototype.toString.call(value) === "[object Date]")
8031
+ );
8032
+ }
8033
+
8034
+ /**
8035
+ * @name isValid
8036
+ * @category Common Helpers
8037
+ * @summary Is the given date valid?
8038
+ *
8039
+ * @description
8040
+ * Returns false if argument is Invalid Date and true otherwise.
8041
+ * Argument is converted to Date using `toDate`. See [toDate](https://date-fns.org/docs/toDate)
8042
+ * Invalid Date is a Date, whose time value is NaN.
8043
+ *
8044
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
8045
+ *
8046
+ * @param date - The date to check
8047
+ *
8048
+ * @returns The date is valid
8049
+ *
8050
+ * @example
8051
+ * // For the valid date:
8052
+ * const result = isValid(new Date(2014, 1, 31))
8053
+ * //=> true
8054
+ *
8055
+ * @example
8056
+ * // For the value, convertible into a date:
8057
+ * const result = isValid(1393804800000)
8058
+ * //=> true
8059
+ *
8060
+ * @example
8061
+ * // For the invalid date:
8062
+ * const result = isValid(new Date(''))
8063
+ * //=> false
8064
+ */
8065
+ function isValid(date) {
8066
+ return !((!isDate$1(date) && typeof date !== "number") || isNaN(+toDate(date)));
8067
+ }
8068
+
8069
+ /**
8070
+ * The {@link startOfYear} function options.
8071
+ */
8072
+
8073
+ /**
8074
+ * @name startOfYear
8075
+ * @category Year Helpers
8076
+ * @summary Return the start of a year for the given date.
8077
+ *
8078
+ * @description
8079
+ * Return the start of a year for the given date.
8080
+ * The result will be in the local timezone.
8081
+ *
8082
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
8083
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
8084
+ *
8085
+ * @param date - The original date
8086
+ * @param options - The options
8087
+ *
8088
+ * @returns The start of a year
8089
+ *
8090
+ * @example
8091
+ * // The start of a year for 2 September 2014 11:55:00:
8092
+ * const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00))
8093
+ * //=> Wed Jan 01 2014 00:00:00
8094
+ */
8095
+ function startOfYear(date, options) {
8096
+ const date_ = toDate(date, options?.in);
8097
+ date_.setFullYear(date_.getFullYear(), 0, 1);
8098
+ date_.setHours(0, 0, 0, 0);
8099
+ return date_;
8100
+ }
8101
+
8102
+ const formatDistanceLocale$1 = {
8103
+ lessThanXSeconds: {
8104
+ one: "less than a second",
8105
+ other: "less than {{count}} seconds",
8106
+ },
8107
+
8108
+ xSeconds: {
8109
+ one: "1 second",
8110
+ other: "{{count}} seconds",
8111
+ },
8112
+
8113
+ halfAMinute: "half a minute",
8114
+
8115
+ lessThanXMinutes: {
8116
+ one: "less than a minute",
8117
+ other: "less than {{count}} minutes",
8118
+ },
8119
+
8120
+ xMinutes: {
8121
+ one: "1 minute",
8122
+ other: "{{count}} minutes",
8123
+ },
8124
+
8125
+ aboutXHours: {
8126
+ one: "about 1 hour",
8127
+ other: "about {{count}} hours",
8128
+ },
8129
+
8130
+ xHours: {
8131
+ one: "1 hour",
8132
+ other: "{{count}} hours",
8133
+ },
8134
+
8135
+ xDays: {
8136
+ one: "1 day",
8137
+ other: "{{count}} days",
8138
+ },
8139
+
8140
+ aboutXWeeks: {
8141
+ one: "about 1 week",
8142
+ other: "about {{count}} weeks",
8143
+ },
8144
+
8145
+ xWeeks: {
8146
+ one: "1 week",
8147
+ other: "{{count}} weeks",
8148
+ },
8149
+
8150
+ aboutXMonths: {
8151
+ one: "about 1 month",
8152
+ other: "about {{count}} months",
8153
+ },
8154
+
8155
+ xMonths: {
8156
+ one: "1 month",
8157
+ other: "{{count}} months",
8158
+ },
8159
+
8160
+ aboutXYears: {
8161
+ one: "about 1 year",
8162
+ other: "about {{count}} years",
8163
+ },
8164
+
8165
+ xYears: {
8166
+ one: "1 year",
8167
+ other: "{{count}} years",
8168
+ },
8169
+
8170
+ overXYears: {
8171
+ one: "over 1 year",
8172
+ other: "over {{count}} years",
8173
+ },
8174
+
8175
+ almostXYears: {
8176
+ one: "almost 1 year",
8177
+ other: "almost {{count}} years",
8178
+ },
8179
+ };
8180
+
8181
+ const formatDistance$1 = (token, count, options) => {
8182
+ let result;
8183
+
8184
+ const tokenValue = formatDistanceLocale$1[token];
8185
+ if (typeof tokenValue === "string") {
8186
+ result = tokenValue;
8187
+ } else if (count === 1) {
8188
+ result = tokenValue.one;
8189
+ } else {
8190
+ result = tokenValue.other.replace("{{count}}", count.toString());
8191
+ }
8192
+
8193
+ if (options?.addSuffix) {
8194
+ if (options.comparison && options.comparison > 0) {
8195
+ return "in " + result;
8196
+ } else {
8197
+ return result + " ago";
8198
+ }
8199
+ }
8200
+
8201
+ return result;
8202
+ };
8203
+
8204
+ function buildFormatLongFn(args) {
8205
+ return (options = {}) => {
8206
+ // TODO: Remove String()
8207
+ const width = options.width ? String(options.width) : args.defaultWidth;
8208
+ const format = args.formats[width] || args.formats[args.defaultWidth];
8209
+ return format;
8210
+ };
8211
+ }
8212
+
8213
+ const dateFormats$1 = {
8214
+ full: "EEEE, MMMM do, y",
8215
+ long: "MMMM do, y",
8216
+ medium: "MMM d, y",
8217
+ short: "MM/dd/yyyy",
8218
+ };
8219
+
8220
+ const timeFormats$1 = {
8221
+ full: "h:mm:ss a zzzz",
8222
+ long: "h:mm:ss a z",
8223
+ medium: "h:mm:ss a",
8224
+ short: "h:mm a",
8225
+ };
8226
+
8227
+ const dateTimeFormats$1 = {
8228
+ full: "{{date}} 'at' {{time}}",
8229
+ long: "{{date}} 'at' {{time}}",
8230
+ medium: "{{date}}, {{time}}",
8231
+ short: "{{date}}, {{time}}",
8232
+ };
8233
+
8234
+ const formatLong$1 = {
8235
+ date: buildFormatLongFn({
8236
+ formats: dateFormats$1,
8237
+ defaultWidth: "full",
8238
+ }),
8239
+
8240
+ time: buildFormatLongFn({
8241
+ formats: timeFormats$1,
8242
+ defaultWidth: "full",
8243
+ }),
8244
+
8245
+ dateTime: buildFormatLongFn({
8246
+ formats: dateTimeFormats$1,
8247
+ defaultWidth: "full",
8248
+ }),
8249
+ };
8250
+
8251
+ const formatRelativeLocale$1 = {
8252
+ lastWeek: "'last' eeee 'at' p",
8253
+ yesterday: "'yesterday at' p",
8254
+ today: "'today at' p",
8255
+ tomorrow: "'tomorrow at' p",
8256
+ nextWeek: "eeee 'at' p",
8257
+ other: "P",
8258
+ };
8259
+
8260
+ const formatRelative$1 = (token, _date, _baseDate, _options) =>
8261
+ formatRelativeLocale$1[token];
8262
+
8263
+ /**
8264
+ * The localize function argument callback which allows to convert raw value to
8265
+ * the actual type.
8266
+ *
8267
+ * @param value - The value to convert
8268
+ *
8269
+ * @returns The converted value
8270
+ */
8271
+
8272
+ /**
8273
+ * The map of localized values for each width.
8274
+ */
8275
+
8276
+ /**
8277
+ * The index type of the locale unit value. It types conversion of units of
8278
+ * values that don't start at 0 (i.e. quarters).
8279
+ */
8280
+
8281
+ /**
8282
+ * Converts the unit value to the tuple of values.
8283
+ */
8284
+
8285
+ /**
8286
+ * The tuple of localized era values. The first element represents BC,
8287
+ * the second element represents AD.
8288
+ */
8289
+
8290
+ /**
8291
+ * The tuple of localized quarter values. The first element represents Q1.
8292
+ */
8293
+
8294
+ /**
8295
+ * The tuple of localized day values. The first element represents Sunday.
8296
+ */
8297
+
8298
+ /**
8299
+ * The tuple of localized month values. The first element represents January.
8300
+ */
8301
+
8302
+ function buildLocalizeFn(args) {
8303
+ return (value, options) => {
8304
+ const context = options?.context ? String(options.context) : "standalone";
8305
+
8306
+ let valuesArray;
8307
+ if (context === "formatting" && args.formattingValues) {
8308
+ const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
8309
+ const width = options?.width ? String(options.width) : defaultWidth;
8310
+
8311
+ valuesArray =
8312
+ args.formattingValues[width] || args.formattingValues[defaultWidth];
8313
+ } else {
8314
+ const defaultWidth = args.defaultWidth;
8315
+ const width = options?.width ? String(options.width) : args.defaultWidth;
8316
+
8317
+ valuesArray = args.values[width] || args.values[defaultWidth];
8318
+ }
8319
+ const index = args.argumentCallback ? args.argumentCallback(value) : value;
8320
+
8321
+ // @ts-expect-error - For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
8322
+ return valuesArray[index];
8323
+ };
8324
+ }
8325
+
8326
+ const eraValues$1 = {
8327
+ narrow: ["B", "A"],
8328
+ abbreviated: ["BC", "AD"],
8329
+ wide: ["Before Christ", "Anno Domini"],
8330
+ };
8331
+
8332
+ const quarterValues$1 = {
8333
+ narrow: ["1", "2", "3", "4"],
8334
+ abbreviated: ["Q1", "Q2", "Q3", "Q4"],
8335
+ wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"],
8336
+ };
8337
+
8338
+ // Note: in English, the names of days of the week and months are capitalized.
8339
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
8340
+ // Generally, formatted dates should look like they are in the middle of a sentence,
8341
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
8342
+ const monthValues$1 = {
8343
+ narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
8344
+ abbreviated: [
8345
+ "Jan",
8346
+ "Feb",
8347
+ "Mar",
8348
+ "Apr",
8349
+ "May",
8350
+ "Jun",
8351
+ "Jul",
8352
+ "Aug",
8353
+ "Sep",
8354
+ "Oct",
8355
+ "Nov",
8356
+ "Dec",
8357
+ ],
8358
+
8359
+ wide: [
8360
+ "January",
8361
+ "February",
8362
+ "March",
8363
+ "April",
8364
+ "May",
8365
+ "June",
8366
+ "July",
8367
+ "August",
8368
+ "September",
8369
+ "October",
8370
+ "November",
8371
+ "December",
8372
+ ],
8373
+ };
8374
+
8375
+ const dayValues$1 = {
8376
+ narrow: ["S", "M", "T", "W", "T", "F", "S"],
8377
+ short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
8378
+ abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
8379
+ wide: [
8380
+ "Sunday",
8381
+ "Monday",
8382
+ "Tuesday",
8383
+ "Wednesday",
8384
+ "Thursday",
8385
+ "Friday",
8386
+ "Saturday",
8387
+ ],
8388
+ };
8389
+
8390
+ const dayPeriodValues$1 = {
8391
+ narrow: {
8392
+ am: "a",
8393
+ pm: "p",
8394
+ midnight: "mi",
8395
+ noon: "n",
8396
+ morning: "morning",
8397
+ afternoon: "afternoon",
8398
+ evening: "evening",
8399
+ night: "night",
8400
+ },
8401
+ abbreviated: {
8402
+ am: "AM",
8403
+ pm: "PM",
8404
+ midnight: "midnight",
8405
+ noon: "noon",
8406
+ morning: "morning",
8407
+ afternoon: "afternoon",
8408
+ evening: "evening",
8409
+ night: "night",
8410
+ },
8411
+ wide: {
8412
+ am: "a.m.",
8413
+ pm: "p.m.",
8414
+ midnight: "midnight",
8415
+ noon: "noon",
8416
+ morning: "morning",
8417
+ afternoon: "afternoon",
8418
+ evening: "evening",
8419
+ night: "night",
8420
+ },
8421
+ };
8422
+
8423
+ const formattingDayPeriodValues$1 = {
8424
+ narrow: {
8425
+ am: "a",
8426
+ pm: "p",
8427
+ midnight: "mi",
8428
+ noon: "n",
8429
+ morning: "in the morning",
8430
+ afternoon: "in the afternoon",
8431
+ evening: "in the evening",
8432
+ night: "at night",
8433
+ },
8434
+ abbreviated: {
8435
+ am: "AM",
8436
+ pm: "PM",
8437
+ midnight: "midnight",
8438
+ noon: "noon",
8439
+ morning: "in the morning",
8440
+ afternoon: "in the afternoon",
8441
+ evening: "in the evening",
8442
+ night: "at night",
8443
+ },
8444
+ wide: {
8445
+ am: "a.m.",
8446
+ pm: "p.m.",
8447
+ midnight: "midnight",
8448
+ noon: "noon",
8449
+ morning: "in the morning",
8450
+ afternoon: "in the afternoon",
8451
+ evening: "in the evening",
8452
+ night: "at night",
8453
+ },
8454
+ };
8455
+
8456
+ const ordinalNumber$1 = (dirtyNumber, _options) => {
8457
+ const number = Number(dirtyNumber);
8458
+
8459
+ // If ordinal numbers depend on context, for example,
8460
+ // if they are different for different grammatical genders,
8461
+ // use `options.unit`.
8462
+ //
8463
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
8464
+ // 'day', 'hour', 'minute', 'second'.
8465
+
8466
+ const rem100 = number % 100;
8467
+ if (rem100 > 20 || rem100 < 10) {
8468
+ switch (rem100 % 10) {
8469
+ case 1:
8470
+ return number + "st";
8471
+ case 2:
8472
+ return number + "nd";
8473
+ case 3:
8474
+ return number + "rd";
8475
+ }
8476
+ }
8477
+ return number + "th";
8478
+ };
8479
+
8480
+ const localize$1 = {
8481
+ ordinalNumber: ordinalNumber$1,
8482
+
8483
+ era: buildLocalizeFn({
8484
+ values: eraValues$1,
8485
+ defaultWidth: "wide",
8486
+ }),
8487
+
8488
+ quarter: buildLocalizeFn({
8489
+ values: quarterValues$1,
8490
+ defaultWidth: "wide",
8491
+ argumentCallback: (quarter) => quarter - 1,
8492
+ }),
8493
+
8494
+ month: buildLocalizeFn({
8495
+ values: monthValues$1,
8496
+ defaultWidth: "wide",
8497
+ }),
8498
+
8499
+ day: buildLocalizeFn({
8500
+ values: dayValues$1,
8501
+ defaultWidth: "wide",
8502
+ }),
8503
+
8504
+ dayPeriod: buildLocalizeFn({
8505
+ values: dayPeriodValues$1,
8506
+ defaultWidth: "wide",
8507
+ formattingValues: formattingDayPeriodValues$1,
8508
+ defaultFormattingWidth: "wide",
8509
+ }),
8510
+ };
8511
+
8512
+ function buildMatchFn(args) {
8513
+ return (string, options = {}) => {
8514
+ const width = options.width;
8515
+
8516
+ const matchPattern =
8517
+ (width && args.matchPatterns[width]) ||
8518
+ args.matchPatterns[args.defaultMatchWidth];
8519
+ const matchResult = string.match(matchPattern);
8520
+
8521
+ if (!matchResult) {
8522
+ return null;
8523
+ }
8524
+ const matchedString = matchResult[0];
8525
+
8526
+ const parsePatterns =
8527
+ (width && args.parsePatterns[width]) ||
8528
+ args.parsePatterns[args.defaultParseWidth];
8529
+
8530
+ const key = Array.isArray(parsePatterns)
8531
+ ? findIndex$1(parsePatterns, (pattern) => pattern.test(matchedString))
8532
+ : // [TODO] -- I challenge you to fix the type
8533
+ findKey(parsePatterns, (pattern) => pattern.test(matchedString));
8534
+
8535
+ let value;
8536
+
8537
+ value = args.valueCallback ? args.valueCallback(key) : key;
8538
+ value = options.valueCallback
8539
+ ? // [TODO] -- I challenge you to fix the type
8540
+ options.valueCallback(value)
8541
+ : value;
8542
+
8543
+ const rest = string.slice(matchedString.length);
8544
+
8545
+ return { value, rest };
8546
+ };
8547
+ }
8548
+
8549
+ function findKey(object, predicate) {
8550
+ for (const key in object) {
8551
+ if (
8552
+ Object.prototype.hasOwnProperty.call(object, key) &&
8553
+ predicate(object[key])
8554
+ ) {
8555
+ return key;
8556
+ }
8557
+ }
8558
+ return undefined;
8559
+ }
8560
+
8561
+ function findIndex$1(array, predicate) {
8562
+ for (let key = 0; key < array.length; key++) {
8563
+ if (predicate(array[key])) {
8564
+ return key;
8565
+ }
8566
+ }
8567
+ return undefined;
8568
+ }
8569
+
8570
+ function buildMatchPatternFn(args) {
8571
+ return (string, options = {}) => {
8572
+ const matchResult = string.match(args.matchPattern);
8573
+ if (!matchResult) return null;
8574
+ const matchedString = matchResult[0];
8575
+
8576
+ const parseResult = string.match(args.parsePattern);
8577
+ if (!parseResult) return null;
8578
+ let value = args.valueCallback
8579
+ ? args.valueCallback(parseResult[0])
8580
+ : parseResult[0];
8581
+
8582
+ // [TODO] I challenge you to fix the type
8583
+ value = options.valueCallback ? options.valueCallback(value) : value;
8584
+
8585
+ const rest = string.slice(matchedString.length);
8586
+
8587
+ return { value, rest };
8588
+ };
8589
+ }
8590
+
8591
+ const matchOrdinalNumberPattern$1 = /^(\d+)(th|st|nd|rd)?/i;
8592
+ const parseOrdinalNumberPattern$1 = /\d+/i;
8593
+
8594
+ const matchEraPatterns$1 = {
8595
+ narrow: /^(b|a)/i,
8596
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
8597
+ wide: /^(before christ|before common era|anno domini|common era)/i,
8598
+ };
8599
+ const parseEraPatterns$1 = {
8600
+ any: [/^b/i, /^(a|c)/i],
8601
+ };
8602
+
8603
+ const matchQuarterPatterns$1 = {
8604
+ narrow: /^[1234]/i,
8605
+ abbreviated: /^q[1234]/i,
8606
+ wide: /^[1234](th|st|nd|rd)? quarter/i,
8607
+ };
8608
+ const parseQuarterPatterns$1 = {
8609
+ any: [/1/i, /2/i, /3/i, /4/i],
8610
+ };
8611
+
8612
+ const matchMonthPatterns$1 = {
8613
+ narrow: /^[jfmasond]/i,
8614
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
8615
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i,
8616
+ };
8617
+ const parseMonthPatterns$1 = {
8618
+ narrow: [
8619
+ /^j/i,
8620
+ /^f/i,
8621
+ /^m/i,
8622
+ /^a/i,
8623
+ /^m/i,
8624
+ /^j/i,
8625
+ /^j/i,
8626
+ /^a/i,
8627
+ /^s/i,
8628
+ /^o/i,
8629
+ /^n/i,
8630
+ /^d/i,
8631
+ ],
8632
+
8633
+ any: [
8634
+ /^ja/i,
8635
+ /^f/i,
8636
+ /^mar/i,
8637
+ /^ap/i,
8638
+ /^may/i,
8639
+ /^jun/i,
8640
+ /^jul/i,
8641
+ /^au/i,
8642
+ /^s/i,
8643
+ /^o/i,
8644
+ /^n/i,
8645
+ /^d/i,
8646
+ ],
8647
+ };
8648
+
8649
+ const matchDayPatterns$1 = {
8650
+ narrow: /^[smtwf]/i,
8651
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
8652
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
8653
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i,
8654
+ };
8655
+ const parseDayPatterns$1 = {
8656
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
8657
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i],
8658
+ };
8659
+
8660
+ const matchDayPeriodPatterns$1 = {
8661
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
8662
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i,
8663
+ };
8664
+ const parseDayPeriodPatterns$1 = {
8665
+ any: {
8666
+ am: /^a/i,
8667
+ pm: /^p/i,
8668
+ midnight: /^mi/i,
8669
+ noon: /^no/i,
8670
+ morning: /morning/i,
8671
+ afternoon: /afternoon/i,
8672
+ evening: /evening/i,
8673
+ night: /night/i,
8674
+ },
8675
+ };
8676
+
8677
+ const match$1 = {
8678
+ ordinalNumber: buildMatchPatternFn({
8679
+ matchPattern: matchOrdinalNumberPattern$1,
8680
+ parsePattern: parseOrdinalNumberPattern$1,
8681
+ valueCallback: (value) => parseInt(value, 10),
8682
+ }),
8683
+
8684
+ era: buildMatchFn({
8685
+ matchPatterns: matchEraPatterns$1,
8686
+ defaultMatchWidth: "wide",
8687
+ parsePatterns: parseEraPatterns$1,
8688
+ defaultParseWidth: "any",
8689
+ }),
8690
+
8691
+ quarter: buildMatchFn({
8692
+ matchPatterns: matchQuarterPatterns$1,
8693
+ defaultMatchWidth: "wide",
8694
+ parsePatterns: parseQuarterPatterns$1,
8695
+ defaultParseWidth: "any",
8696
+ valueCallback: (index) => index + 1,
8697
+ }),
8698
+
8699
+ month: buildMatchFn({
8700
+ matchPatterns: matchMonthPatterns$1,
8701
+ defaultMatchWidth: "wide",
8702
+ parsePatterns: parseMonthPatterns$1,
8703
+ defaultParseWidth: "any",
8704
+ }),
8705
+
8706
+ day: buildMatchFn({
8707
+ matchPatterns: matchDayPatterns$1,
8708
+ defaultMatchWidth: "wide",
8709
+ parsePatterns: parseDayPatterns$1,
8710
+ defaultParseWidth: "any",
8711
+ }),
8712
+
8713
+ dayPeriod: buildMatchFn({
8714
+ matchPatterns: matchDayPeriodPatterns$1,
8715
+ defaultMatchWidth: "any",
8716
+ parsePatterns: parseDayPeriodPatterns$1,
8717
+ defaultParseWidth: "any",
8718
+ }),
8719
+ };
8720
+
8721
+ /**
8722
+ * @category Locales
8723
+ * @summary English locale (United States).
8724
+ * @language English
8725
+ * @iso-639-2 eng
8726
+ * @author Sasha Koss [@kossnocorp](https://github.com/kossnocorp)
8727
+ * @author Lesha Koss [@leshakoss](https://github.com/leshakoss)
8728
+ */
8729
+ const enUS = {
8730
+ code: "en-US",
8731
+ formatDistance: formatDistance$1,
8732
+ formatLong: formatLong$1,
8733
+ formatRelative: formatRelative$1,
8734
+ localize: localize$1,
8735
+ match: match$1,
8736
+ options: {
8737
+ weekStartsOn: 0 /* Sunday */,
8738
+ firstWeekContainsDate: 1,
8739
+ },
8740
+ };
8741
+
8742
+ /**
8743
+ * The {@link getDayOfYear} function options.
8744
+ */
8745
+
8746
+ /**
8747
+ * @name getDayOfYear
8748
+ * @category Day Helpers
8749
+ * @summary Get the day of the year of the given date.
8750
+ *
8751
+ * @description
8752
+ * Get the day of the year of the given date.
8753
+ *
8754
+ * @param date - The given date
8755
+ * @param options - The options
8756
+ *
8757
+ * @returns The day of year
8758
+ *
8759
+ * @example
8760
+ * // Which day of the year is 2 July 2014?
8761
+ * const result = getDayOfYear(new Date(2014, 6, 2))
8762
+ * //=> 183
8763
+ */
8764
+ function getDayOfYear(date, options) {
8765
+ const _date = toDate(date, options?.in);
8766
+ const diff = differenceInCalendarDays(_date, startOfYear(_date));
8767
+ const dayOfYear = diff + 1;
8768
+ return dayOfYear;
8769
+ }
8770
+
8771
+ /**
8772
+ * The {@link getISOWeek} function options.
8773
+ */
8774
+
8775
+ /**
8776
+ * @name getISOWeek
8777
+ * @category ISO Week Helpers
8778
+ * @summary Get the ISO week of the given date.
8779
+ *
8780
+ * @description
8781
+ * Get the ISO week of the given date.
8782
+ *
8783
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
8784
+ *
8785
+ * @param date - The given date
8786
+ * @param options - The options
8787
+ *
8788
+ * @returns The ISO week
8789
+ *
8790
+ * @example
8791
+ * // Which week of the ISO-week numbering year is 2 January 2005?
8792
+ * const result = getISOWeek(new Date(2005, 0, 2))
8793
+ * //=> 53
8794
+ */
8795
+ function getISOWeek(date, options) {
8796
+ const _date = toDate(date, options?.in);
8797
+ const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
8798
+
8799
+ // Round the number of weeks to the nearest integer because the number of
8800
+ // milliseconds in a week is not constant (e.g. it's different in the week of
8801
+ // the daylight saving time clock shift).
8802
+ return Math.round(diff / millisecondsInWeek) + 1;
8803
+ }
8804
+
8805
+ /**
8806
+ * The {@link getWeekYear} function options.
8807
+ */
8808
+
8809
+ /**
8810
+ * @name getWeekYear
8811
+ * @category Week-Numbering Year Helpers
8812
+ * @summary Get the local week-numbering year of the given date.
8813
+ *
8814
+ * @description
8815
+ * Get the local week-numbering year of the given date.
8816
+ * The exact calculation depends on the values of
8817
+ * `options.weekStartsOn` (which is the index of the first day of the week)
8818
+ * and `options.firstWeekContainsDate` (which is the day of January, which is always in
8819
+ * the first week of the week-numbering year)
8820
+ *
8821
+ * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
8822
+ *
8823
+ * @param date - The given date
8824
+ * @param options - An object with options.
8825
+ *
8826
+ * @returns The local week-numbering year
8827
+ *
8828
+ * @example
8829
+ * // Which week numbering year is 26 December 2004 with the default settings?
8830
+ * const result = getWeekYear(new Date(2004, 11, 26))
8831
+ * //=> 2005
8832
+ *
8833
+ * @example
8834
+ * // Which week numbering year is 26 December 2004 if week starts on Saturday?
8835
+ * const result = getWeekYear(new Date(2004, 11, 26), { weekStartsOn: 6 })
8836
+ * //=> 2004
8837
+ *
8838
+ * @example
8839
+ * // Which week numbering year is 26 December 2004 if the first week contains 4 January?
8840
+ * const result = getWeekYear(new Date(2004, 11, 26), { firstWeekContainsDate: 4 })
8841
+ * //=> 2004
8842
+ */
8843
+ function getWeekYear(date, options) {
8844
+ const _date = toDate(date, options?.in);
8845
+ const year = _date.getFullYear();
8846
+
8847
+ const defaultOptions = getDefaultOptions();
8848
+ const firstWeekContainsDate =
8849
+ options?.firstWeekContainsDate ??
8850
+ options?.locale?.options?.firstWeekContainsDate ??
8851
+ defaultOptions.firstWeekContainsDate ??
8852
+ defaultOptions.locale?.options?.firstWeekContainsDate ??
8853
+ 1;
8854
+
8855
+ const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
8856
+ firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
8857
+ firstWeekOfNextYear.setHours(0, 0, 0, 0);
8858
+ const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
8859
+
8860
+ const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
8861
+ firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
8862
+ firstWeekOfThisYear.setHours(0, 0, 0, 0);
8863
+ const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
8864
+
8865
+ if (+_date >= +startOfNextYear) {
8866
+ return year + 1;
8867
+ } else if (+_date >= +startOfThisYear) {
8868
+ return year;
8869
+ } else {
8870
+ return year - 1;
8871
+ }
8872
+ }
8873
+
8874
+ /**
8875
+ * The {@link startOfWeekYear} function options.
8876
+ */
8877
+
8878
+ /**
8879
+ * @name startOfWeekYear
8880
+ * @category Week-Numbering Year Helpers
8881
+ * @summary Return the start of a local week-numbering year for the given date.
8882
+ *
8883
+ * @description
8884
+ * Return the start of a local week-numbering year.
8885
+ * The exact calculation depends on the values of
8886
+ * `options.weekStartsOn` (which is the index of the first day of the week)
8887
+ * and `options.firstWeekContainsDate` (which is the day of January, which is always in
8888
+ * the first week of the week-numbering year)
8889
+ *
8890
+ * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
8891
+ *
8892
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
8893
+ * @typeParam ResultDate - The result `Date` type.
8894
+ *
8895
+ * @param date - The original date
8896
+ * @param options - An object with options
8897
+ *
8898
+ * @returns The start of a week-numbering year
8899
+ *
8900
+ * @example
8901
+ * // The start of an a week-numbering year for 2 July 2005 with default settings:
8902
+ * const result = startOfWeekYear(new Date(2005, 6, 2))
8903
+ * //=> Sun Dec 26 2004 00:00:00
8904
+ *
8905
+ * @example
8906
+ * // The start of a week-numbering year for 2 July 2005
8907
+ * // if Monday is the first day of week
8908
+ * // and 4 January is always in the first week of the year:
8909
+ * const result = startOfWeekYear(new Date(2005, 6, 2), {
8910
+ * weekStartsOn: 1,
8911
+ * firstWeekContainsDate: 4
8912
+ * })
8913
+ * //=> Mon Jan 03 2005 00:00:00
8914
+ */
8915
+ function startOfWeekYear(date, options) {
8916
+ const defaultOptions = getDefaultOptions();
8917
+ const firstWeekContainsDate =
8918
+ options?.firstWeekContainsDate ??
8919
+ options?.locale?.options?.firstWeekContainsDate ??
8920
+ defaultOptions.firstWeekContainsDate ??
8921
+ defaultOptions.locale?.options?.firstWeekContainsDate ??
8922
+ 1;
8923
+
8924
+ const year = getWeekYear(date, options);
8925
+ const firstWeek = constructFrom(options?.in || date, 0);
8926
+ firstWeek.setFullYear(year, 0, firstWeekContainsDate);
8927
+ firstWeek.setHours(0, 0, 0, 0);
8928
+ const _date = startOfWeek(firstWeek, options);
8929
+ return _date;
8930
+ }
8931
+
8932
+ /**
8933
+ * The {@link getWeek} function options.
8934
+ */
8935
+
8936
+ /**
8937
+ * @name getWeek
8938
+ * @category Week Helpers
8939
+ * @summary Get the local week index of the given date.
8940
+ *
8941
+ * @description
8942
+ * Get the local week index of the given date.
8943
+ * The exact calculation depends on the values of
8944
+ * `options.weekStartsOn` (which is the index of the first day of the week)
8945
+ * and `options.firstWeekContainsDate` (which is the day of January, which is always in
8946
+ * the first week of the week-numbering year)
8947
+ *
8948
+ * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
8949
+ *
8950
+ * @param date - The given date
8951
+ * @param options - An object with options
8952
+ *
8953
+ * @returns The week
8954
+ *
8955
+ * @example
8956
+ * // Which week of the local week numbering year is 2 January 2005 with default options?
8957
+ * const result = getWeek(new Date(2005, 0, 2))
8958
+ * //=> 2
8959
+ *
8960
+ * @example
8961
+ * // Which week of the local week numbering year is 2 January 2005,
8962
+ * // if Monday is the first day of the week,
8963
+ * // and the first week of the year always contains 4 January?
8964
+ * const result = getWeek(new Date(2005, 0, 2), {
8965
+ * weekStartsOn: 1,
8966
+ * firstWeekContainsDate: 4
8967
+ * })
8968
+ * //=> 53
8969
+ */
8970
+ function getWeek(date, options) {
8971
+ const _date = toDate(date, options?.in);
8972
+ const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
8973
+
8974
+ // Round the number of weeks to the nearest integer because the number of
8975
+ // milliseconds in a week is not constant (e.g. it's different in the week of
8976
+ // the daylight saving time clock shift).
8977
+ return Math.round(diff / millisecondsInWeek) + 1;
8978
+ }
8979
+
8980
+ function addLeadingZeros(number, targetLength) {
8981
+ const sign = number < 0 ? "-" : "";
8982
+ const output = Math.abs(number).toString().padStart(targetLength, "0");
8983
+ return sign + output;
8984
+ }
8985
+
8986
+ /*
8987
+ * | | Unit | | Unit |
8988
+ * |-----|--------------------------------|-----|--------------------------------|
8989
+ * | a | AM, PM | A* | |
8990
+ * | d | Day of month | D | |
8991
+ * | h | Hour [1-12] | H | Hour [0-23] |
8992
+ * | m | Minute | M | Month |
8993
+ * | s | Second | S | Fraction of second |
8994
+ * | y | Year (abs) | Y | |
8995
+ *
8996
+ * Letters marked by * are not implemented but reserved by Unicode standard.
8997
+ */
8998
+
8999
+ const lightFormatters = {
9000
+ // Year
9001
+ y(date, token) {
9002
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
9003
+ // | Year | y | yy | yyy | yyyy | yyyyy |
9004
+ // |----------|-------|----|-------|-------|-------|
9005
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
9006
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
9007
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
9008
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
9009
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
9010
+
9011
+ const signedYear = date.getFullYear();
9012
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
9013
+ const year = signedYear > 0 ? signedYear : 1 - signedYear;
9014
+ return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
9015
+ },
9016
+
9017
+ // Month
9018
+ M(date, token) {
9019
+ const month = date.getMonth();
9020
+ return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
9021
+ },
9022
+
9023
+ // Day of the month
9024
+ d(date, token) {
9025
+ return addLeadingZeros(date.getDate(), token.length);
9026
+ },
9027
+
9028
+ // AM or PM
9029
+ a(date, token) {
9030
+ const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
9031
+
9032
+ switch (token) {
9033
+ case "a":
9034
+ case "aa":
9035
+ return dayPeriodEnumValue.toUpperCase();
9036
+ case "aaa":
9037
+ return dayPeriodEnumValue;
9038
+ case "aaaaa":
9039
+ return dayPeriodEnumValue[0];
9040
+ case "aaaa":
9041
+ default:
9042
+ return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
9043
+ }
9044
+ },
9045
+
9046
+ // Hour [1-12]
9047
+ h(date, token) {
9048
+ return addLeadingZeros(date.getHours() % 12 || 12, token.length);
9049
+ },
9050
+
9051
+ // Hour [0-23]
9052
+ H(date, token) {
9053
+ return addLeadingZeros(date.getHours(), token.length);
9054
+ },
9055
+
9056
+ // Minute
9057
+ m(date, token) {
9058
+ return addLeadingZeros(date.getMinutes(), token.length);
9059
+ },
9060
+
9061
+ // Second
9062
+ s(date, token) {
9063
+ return addLeadingZeros(date.getSeconds(), token.length);
9064
+ },
9065
+
9066
+ // Fraction of second
9067
+ S(date, token) {
9068
+ const numberOfDigits = token.length;
9069
+ const milliseconds = date.getMilliseconds();
9070
+ const fractionalSeconds = Math.trunc(
9071
+ milliseconds * Math.pow(10, numberOfDigits - 3),
9072
+ );
9073
+ return addLeadingZeros(fractionalSeconds, token.length);
9074
+ },
9075
+ };
9076
+
9077
+ const dayPeriodEnum = {
9078
+ midnight: "midnight",
9079
+ noon: "noon",
9080
+ morning: "morning",
9081
+ afternoon: "afternoon",
9082
+ evening: "evening",
9083
+ night: "night",
9084
+ };
9085
+
9086
+ /*
9087
+ * | | Unit | | Unit |
9088
+ * |-----|--------------------------------|-----|--------------------------------|
9089
+ * | a | AM, PM | A* | Milliseconds in day |
9090
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
9091
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
9092
+ * | d | Day of month | D | Day of year |
9093
+ * | e | Local day of week | E | Day of week |
9094
+ * | f | | F* | Day of week in month |
9095
+ * | g* | Modified Julian day | G | Era |
9096
+ * | h | Hour [1-12] | H | Hour [0-23] |
9097
+ * | i! | ISO day of week | I! | ISO week of year |
9098
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
9099
+ * | k | Hour [1-24] | K | Hour [0-11] |
9100
+ * | l* | (deprecated) | L | Stand-alone month |
9101
+ * | m | Minute | M | Month |
9102
+ * | n | | N | |
9103
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
9104
+ * | p! | Long localized time | P! | Long localized date |
9105
+ * | q | Stand-alone quarter | Q | Quarter |
9106
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
9107
+ * | s | Second | S | Fraction of second |
9108
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
9109
+ * | u | Extended year | U* | Cyclic year |
9110
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
9111
+ * | w | Local week of year | W* | Week of month |
9112
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
9113
+ * | y | Year (abs) | Y | Local week-numbering year |
9114
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
9115
+ *
9116
+ * Letters marked by * are not implemented but reserved by Unicode standard.
9117
+ *
9118
+ * Letters marked by ! are non-standard, but implemented by date-fns:
9119
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
9120
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
9121
+ * i.e. 7 for Sunday, 1 for Monday, etc.
9122
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
9123
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
9124
+ * `R` is supposed to be used in conjunction with `I` and `i`
9125
+ * for universal ISO week-numbering date, whereas
9126
+ * `Y` is supposed to be used in conjunction with `w` and `e`
9127
+ * for week-numbering date specific to the locale.
9128
+ * - `P` is long localized date format
9129
+ * - `p` is long localized time format
9130
+ */
9131
+
9132
+ const formatters = {
9133
+ // Era
9134
+ G: function (date, token, localize) {
9135
+ const era = date.getFullYear() > 0 ? 1 : 0;
9136
+ switch (token) {
9137
+ // AD, BC
9138
+ case "G":
9139
+ case "GG":
9140
+ case "GGG":
9141
+ return localize.era(era, { width: "abbreviated" });
9142
+ // A, B
9143
+ case "GGGGG":
9144
+ return localize.era(era, { width: "narrow" });
9145
+ // Anno Domini, Before Christ
9146
+ case "GGGG":
9147
+ default:
9148
+ return localize.era(era, { width: "wide" });
9149
+ }
9150
+ },
9151
+
9152
+ // Year
9153
+ y: function (date, token, localize) {
9154
+ // Ordinal number
9155
+ if (token === "yo") {
9156
+ const signedYear = date.getFullYear();
9157
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
9158
+ const year = signedYear > 0 ? signedYear : 1 - signedYear;
9159
+ return localize.ordinalNumber(year, { unit: "year" });
9160
+ }
9161
+
9162
+ return lightFormatters.y(date, token);
9163
+ },
9164
+
9165
+ // Local week-numbering year
9166
+ Y: function (date, token, localize, options) {
9167
+ const signedWeekYear = getWeekYear(date, options);
9168
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
9169
+ const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
9170
+
9171
+ // Two digit year
9172
+ if (token === "YY") {
9173
+ const twoDigitYear = weekYear % 100;
9174
+ return addLeadingZeros(twoDigitYear, 2);
9175
+ }
9176
+
9177
+ // Ordinal number
9178
+ if (token === "Yo") {
9179
+ return localize.ordinalNumber(weekYear, { unit: "year" });
9180
+ }
9181
+
9182
+ // Padding
9183
+ return addLeadingZeros(weekYear, token.length);
9184
+ },
9185
+
9186
+ // ISO week-numbering year
9187
+ R: function (date, token) {
9188
+ const isoWeekYear = getISOWeekYear(date);
9189
+
9190
+ // Padding
9191
+ return addLeadingZeros(isoWeekYear, token.length);
9192
+ },
9193
+
9194
+ // Extended year. This is a single number designating the year of this calendar system.
9195
+ // The main difference between `y` and `u` localizers are B.C. years:
9196
+ // | Year | `y` | `u` |
9197
+ // |------|-----|-----|
9198
+ // | AC 1 | 1 | 1 |
9199
+ // | BC 1 | 1 | 0 |
9200
+ // | BC 2 | 2 | -1 |
9201
+ // Also `yy` always returns the last two digits of a year,
9202
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
9203
+ u: function (date, token) {
9204
+ const year = date.getFullYear();
9205
+ return addLeadingZeros(year, token.length);
9206
+ },
9207
+
9208
+ // Quarter
9209
+ Q: function (date, token, localize) {
9210
+ const quarter = Math.ceil((date.getMonth() + 1) / 3);
9211
+ switch (token) {
9212
+ // 1, 2, 3, 4
9213
+ case "Q":
9214
+ return String(quarter);
9215
+ // 01, 02, 03, 04
9216
+ case "QQ":
9217
+ return addLeadingZeros(quarter, 2);
9218
+ // 1st, 2nd, 3rd, 4th
9219
+ case "Qo":
9220
+ return localize.ordinalNumber(quarter, { unit: "quarter" });
9221
+ // Q1, Q2, Q3, Q4
9222
+ case "QQQ":
9223
+ return localize.quarter(quarter, {
9224
+ width: "abbreviated",
9225
+ context: "formatting",
9226
+ });
9227
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
9228
+ case "QQQQQ":
9229
+ return localize.quarter(quarter, {
9230
+ width: "narrow",
9231
+ context: "formatting",
9232
+ });
9233
+ // 1st quarter, 2nd quarter, ...
9234
+ case "QQQQ":
9235
+ default:
9236
+ return localize.quarter(quarter, {
9237
+ width: "wide",
9238
+ context: "formatting",
9239
+ });
9240
+ }
9241
+ },
9242
+
9243
+ // Stand-alone quarter
9244
+ q: function (date, token, localize) {
9245
+ const quarter = Math.ceil((date.getMonth() + 1) / 3);
9246
+ switch (token) {
9247
+ // 1, 2, 3, 4
9248
+ case "q":
9249
+ return String(quarter);
9250
+ // 01, 02, 03, 04
9251
+ case "qq":
9252
+ return addLeadingZeros(quarter, 2);
9253
+ // 1st, 2nd, 3rd, 4th
9254
+ case "qo":
9255
+ return localize.ordinalNumber(quarter, { unit: "quarter" });
9256
+ // Q1, Q2, Q3, Q4
9257
+ case "qqq":
9258
+ return localize.quarter(quarter, {
9259
+ width: "abbreviated",
9260
+ context: "standalone",
9261
+ });
9262
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
9263
+ case "qqqqq":
9264
+ return localize.quarter(quarter, {
9265
+ width: "narrow",
9266
+ context: "standalone",
9267
+ });
9268
+ // 1st quarter, 2nd quarter, ...
9269
+ case "qqqq":
9270
+ default:
9271
+ return localize.quarter(quarter, {
9272
+ width: "wide",
9273
+ context: "standalone",
9274
+ });
9275
+ }
9276
+ },
9277
+
9278
+ // Month
9279
+ M: function (date, token, localize) {
9280
+ const month = date.getMonth();
9281
+ switch (token) {
9282
+ case "M":
9283
+ case "MM":
9284
+ return lightFormatters.M(date, token);
9285
+ // 1st, 2nd, ..., 12th
9286
+ case "Mo":
9287
+ return localize.ordinalNumber(month + 1, { unit: "month" });
9288
+ // Jan, Feb, ..., Dec
9289
+ case "MMM":
9290
+ return localize.month(month, {
9291
+ width: "abbreviated",
9292
+ context: "formatting",
9293
+ });
9294
+ // J, F, ..., D
9295
+ case "MMMMM":
9296
+ return localize.month(month, {
9297
+ width: "narrow",
9298
+ context: "formatting",
9299
+ });
9300
+ // January, February, ..., December
9301
+ case "MMMM":
9302
+ default:
9303
+ return localize.month(month, { width: "wide", context: "formatting" });
9304
+ }
9305
+ },
9306
+
9307
+ // Stand-alone month
9308
+ L: function (date, token, localize) {
9309
+ const month = date.getMonth();
9310
+ switch (token) {
9311
+ // 1, 2, ..., 12
9312
+ case "L":
9313
+ return String(month + 1);
9314
+ // 01, 02, ..., 12
9315
+ case "LL":
9316
+ return addLeadingZeros(month + 1, 2);
9317
+ // 1st, 2nd, ..., 12th
9318
+ case "Lo":
9319
+ return localize.ordinalNumber(month + 1, { unit: "month" });
9320
+ // Jan, Feb, ..., Dec
9321
+ case "LLL":
9322
+ return localize.month(month, {
9323
+ width: "abbreviated",
9324
+ context: "standalone",
9325
+ });
9326
+ // J, F, ..., D
9327
+ case "LLLLL":
9328
+ return localize.month(month, {
9329
+ width: "narrow",
9330
+ context: "standalone",
9331
+ });
9332
+ // January, February, ..., December
9333
+ case "LLLL":
9334
+ default:
9335
+ return localize.month(month, { width: "wide", context: "standalone" });
9336
+ }
9337
+ },
9338
+
9339
+ // Local week of year
9340
+ w: function (date, token, localize, options) {
9341
+ const week = getWeek(date, options);
9342
+
9343
+ if (token === "wo") {
9344
+ return localize.ordinalNumber(week, { unit: "week" });
9345
+ }
9346
+
9347
+ return addLeadingZeros(week, token.length);
9348
+ },
9349
+
9350
+ // ISO week of year
9351
+ I: function (date, token, localize) {
9352
+ const isoWeek = getISOWeek(date);
9353
+
9354
+ if (token === "Io") {
9355
+ return localize.ordinalNumber(isoWeek, { unit: "week" });
9356
+ }
9357
+
9358
+ return addLeadingZeros(isoWeek, token.length);
9359
+ },
9360
+
9361
+ // Day of the month
9362
+ d: function (date, token, localize) {
9363
+ if (token === "do") {
9364
+ return localize.ordinalNumber(date.getDate(), { unit: "date" });
9365
+ }
9366
+
9367
+ return lightFormatters.d(date, token);
9368
+ },
9369
+
9370
+ // Day of year
9371
+ D: function (date, token, localize) {
9372
+ const dayOfYear = getDayOfYear(date);
9373
+
9374
+ if (token === "Do") {
9375
+ return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
9376
+ }
9377
+
9378
+ return addLeadingZeros(dayOfYear, token.length);
9379
+ },
9380
+
9381
+ // Day of week
9382
+ E: function (date, token, localize) {
9383
+ const dayOfWeek = date.getDay();
9384
+ switch (token) {
9385
+ // Tue
9386
+ case "E":
9387
+ case "EE":
9388
+ case "EEE":
9389
+ return localize.day(dayOfWeek, {
9390
+ width: "abbreviated",
9391
+ context: "formatting",
9392
+ });
9393
+ // T
9394
+ case "EEEEE":
9395
+ return localize.day(dayOfWeek, {
9396
+ width: "narrow",
9397
+ context: "formatting",
9398
+ });
9399
+ // Tu
9400
+ case "EEEEEE":
9401
+ return localize.day(dayOfWeek, {
9402
+ width: "short",
9403
+ context: "formatting",
9404
+ });
9405
+ // Tuesday
9406
+ case "EEEE":
9407
+ default:
9408
+ return localize.day(dayOfWeek, {
9409
+ width: "wide",
9410
+ context: "formatting",
9411
+ });
9412
+ }
9413
+ },
9414
+
9415
+ // Local day of week
9416
+ e: function (date, token, localize, options) {
9417
+ const dayOfWeek = date.getDay();
9418
+ const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
9419
+ switch (token) {
9420
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
9421
+ case "e":
9422
+ return String(localDayOfWeek);
9423
+ // Padded numerical value
9424
+ case "ee":
9425
+ return addLeadingZeros(localDayOfWeek, 2);
9426
+ // 1st, 2nd, ..., 7th
9427
+ case "eo":
9428
+ return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
9429
+ case "eee":
9430
+ return localize.day(dayOfWeek, {
9431
+ width: "abbreviated",
9432
+ context: "formatting",
9433
+ });
9434
+ // T
9435
+ case "eeeee":
9436
+ return localize.day(dayOfWeek, {
9437
+ width: "narrow",
9438
+ context: "formatting",
9439
+ });
9440
+ // Tu
9441
+ case "eeeeee":
9442
+ return localize.day(dayOfWeek, {
9443
+ width: "short",
9444
+ context: "formatting",
9445
+ });
9446
+ // Tuesday
9447
+ case "eeee":
9448
+ default:
9449
+ return localize.day(dayOfWeek, {
9450
+ width: "wide",
9451
+ context: "formatting",
9452
+ });
9453
+ }
9454
+ },
9455
+
9456
+ // Stand-alone local day of week
9457
+ c: function (date, token, localize, options) {
9458
+ const dayOfWeek = date.getDay();
9459
+ const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
9460
+ switch (token) {
9461
+ // Numerical value (same as in `e`)
9462
+ case "c":
9463
+ return String(localDayOfWeek);
9464
+ // Padded numerical value
9465
+ case "cc":
9466
+ return addLeadingZeros(localDayOfWeek, token.length);
9467
+ // 1st, 2nd, ..., 7th
9468
+ case "co":
9469
+ return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
9470
+ case "ccc":
9471
+ return localize.day(dayOfWeek, {
9472
+ width: "abbreviated",
9473
+ context: "standalone",
9474
+ });
9475
+ // T
9476
+ case "ccccc":
9477
+ return localize.day(dayOfWeek, {
9478
+ width: "narrow",
9479
+ context: "standalone",
9480
+ });
9481
+ // Tu
9482
+ case "cccccc":
9483
+ return localize.day(dayOfWeek, {
9484
+ width: "short",
9485
+ context: "standalone",
9486
+ });
9487
+ // Tuesday
9488
+ case "cccc":
9489
+ default:
9490
+ return localize.day(dayOfWeek, {
9491
+ width: "wide",
9492
+ context: "standalone",
9493
+ });
9494
+ }
9495
+ },
9496
+
9497
+ // ISO day of week
9498
+ i: function (date, token, localize) {
9499
+ const dayOfWeek = date.getDay();
9500
+ const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
9501
+ switch (token) {
9502
+ // 2
9503
+ case "i":
9504
+ return String(isoDayOfWeek);
9505
+ // 02
9506
+ case "ii":
9507
+ return addLeadingZeros(isoDayOfWeek, token.length);
9508
+ // 2nd
9509
+ case "io":
9510
+ return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
9511
+ // Tue
9512
+ case "iii":
9513
+ return localize.day(dayOfWeek, {
9514
+ width: "abbreviated",
9515
+ context: "formatting",
9516
+ });
9517
+ // T
9518
+ case "iiiii":
9519
+ return localize.day(dayOfWeek, {
9520
+ width: "narrow",
9521
+ context: "formatting",
9522
+ });
9523
+ // Tu
9524
+ case "iiiiii":
9525
+ return localize.day(dayOfWeek, {
9526
+ width: "short",
9527
+ context: "formatting",
9528
+ });
9529
+ // Tuesday
9530
+ case "iiii":
9531
+ default:
9532
+ return localize.day(dayOfWeek, {
9533
+ width: "wide",
9534
+ context: "formatting",
9535
+ });
9536
+ }
9537
+ },
9538
+
9539
+ // AM or PM
9540
+ a: function (date, token, localize) {
9541
+ const hours = date.getHours();
9542
+ const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
9543
+
9544
+ switch (token) {
9545
+ case "a":
9546
+ case "aa":
9547
+ return localize.dayPeriod(dayPeriodEnumValue, {
9548
+ width: "abbreviated",
9549
+ context: "formatting",
9550
+ });
9551
+ case "aaa":
9552
+ return localize
9553
+ .dayPeriod(dayPeriodEnumValue, {
9554
+ width: "abbreviated",
9555
+ context: "formatting",
9556
+ })
9557
+ .toLowerCase();
9558
+ case "aaaaa":
9559
+ return localize.dayPeriod(dayPeriodEnumValue, {
9560
+ width: "narrow",
9561
+ context: "formatting",
9562
+ });
9563
+ case "aaaa":
9564
+ default:
9565
+ return localize.dayPeriod(dayPeriodEnumValue, {
9566
+ width: "wide",
9567
+ context: "formatting",
9568
+ });
9569
+ }
9570
+ },
9571
+
9572
+ // AM, PM, midnight, noon
9573
+ b: function (date, token, localize) {
9574
+ const hours = date.getHours();
9575
+ let dayPeriodEnumValue;
9576
+ if (hours === 12) {
9577
+ dayPeriodEnumValue = dayPeriodEnum.noon;
9578
+ } else if (hours === 0) {
9579
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
9580
+ } else {
9581
+ dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
9582
+ }
9583
+
9584
+ switch (token) {
9585
+ case "b":
9586
+ case "bb":
9587
+ return localize.dayPeriod(dayPeriodEnumValue, {
9588
+ width: "abbreviated",
9589
+ context: "formatting",
9590
+ });
9591
+ case "bbb":
9592
+ return localize
9593
+ .dayPeriod(dayPeriodEnumValue, {
9594
+ width: "abbreviated",
9595
+ context: "formatting",
9596
+ })
9597
+ .toLowerCase();
9598
+ case "bbbbb":
9599
+ return localize.dayPeriod(dayPeriodEnumValue, {
9600
+ width: "narrow",
9601
+ context: "formatting",
9602
+ });
9603
+ case "bbbb":
9604
+ default:
9605
+ return localize.dayPeriod(dayPeriodEnumValue, {
9606
+ width: "wide",
9607
+ context: "formatting",
9608
+ });
9609
+ }
9610
+ },
9611
+
9612
+ // in the morning, in the afternoon, in the evening, at night
9613
+ B: function (date, token, localize) {
9614
+ const hours = date.getHours();
9615
+ let dayPeriodEnumValue;
9616
+ if (hours >= 17) {
9617
+ dayPeriodEnumValue = dayPeriodEnum.evening;
9618
+ } else if (hours >= 12) {
9619
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
9620
+ } else if (hours >= 4) {
9621
+ dayPeriodEnumValue = dayPeriodEnum.morning;
9622
+ } else {
9623
+ dayPeriodEnumValue = dayPeriodEnum.night;
9624
+ }
9625
+
9626
+ switch (token) {
9627
+ case "B":
9628
+ case "BB":
9629
+ case "BBB":
9630
+ return localize.dayPeriod(dayPeriodEnumValue, {
9631
+ width: "abbreviated",
9632
+ context: "formatting",
9633
+ });
9634
+ case "BBBBB":
9635
+ return localize.dayPeriod(dayPeriodEnumValue, {
9636
+ width: "narrow",
9637
+ context: "formatting",
9638
+ });
9639
+ case "BBBB":
9640
+ default:
9641
+ return localize.dayPeriod(dayPeriodEnumValue, {
9642
+ width: "wide",
9643
+ context: "formatting",
9644
+ });
9645
+ }
9646
+ },
9647
+
9648
+ // Hour [1-12]
9649
+ h: function (date, token, localize) {
9650
+ if (token === "ho") {
9651
+ let hours = date.getHours() % 12;
9652
+ if (hours === 0) hours = 12;
9653
+ return localize.ordinalNumber(hours, { unit: "hour" });
9654
+ }
9655
+
9656
+ return lightFormatters.h(date, token);
9657
+ },
9658
+
9659
+ // Hour [0-23]
9660
+ H: function (date, token, localize) {
9661
+ if (token === "Ho") {
9662
+ return localize.ordinalNumber(date.getHours(), { unit: "hour" });
9663
+ }
9664
+
9665
+ return lightFormatters.H(date, token);
9666
+ },
9667
+
9668
+ // Hour [0-11]
9669
+ K: function (date, token, localize) {
9670
+ const hours = date.getHours() % 12;
9671
+
9672
+ if (token === "Ko") {
9673
+ return localize.ordinalNumber(hours, { unit: "hour" });
9674
+ }
9675
+
9676
+ return addLeadingZeros(hours, token.length);
9677
+ },
9678
+
9679
+ // Hour [1-24]
9680
+ k: function (date, token, localize) {
9681
+ let hours = date.getHours();
9682
+ if (hours === 0) hours = 24;
9683
+
9684
+ if (token === "ko") {
9685
+ return localize.ordinalNumber(hours, { unit: "hour" });
9686
+ }
9687
+
9688
+ return addLeadingZeros(hours, token.length);
9689
+ },
9690
+
9691
+ // Minute
9692
+ m: function (date, token, localize) {
9693
+ if (token === "mo") {
9694
+ return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
9695
+ }
9696
+
9697
+ return lightFormatters.m(date, token);
9698
+ },
9699
+
9700
+ // Second
9701
+ s: function (date, token, localize) {
9702
+ if (token === "so") {
9703
+ return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
9704
+ }
9705
+
9706
+ return lightFormatters.s(date, token);
9707
+ },
9708
+
9709
+ // Fraction of second
9710
+ S: function (date, token) {
9711
+ return lightFormatters.S(date, token);
9712
+ },
9713
+
9714
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
9715
+ X: function (date, token, _localize) {
9716
+ const timezoneOffset = date.getTimezoneOffset();
9717
+
9718
+ if (timezoneOffset === 0) {
9719
+ return "Z";
9720
+ }
9721
+
9722
+ switch (token) {
9723
+ // Hours and optional minutes
9724
+ case "X":
9725
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
9726
+
9727
+ // Hours, minutes and optional seconds without `:` delimiter
9728
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
9729
+ // so this token always has the same output as `XX`
9730
+ case "XXXX":
9731
+ case "XX": // Hours and minutes without `:` delimiter
9732
+ return formatTimezone(timezoneOffset);
9733
+
9734
+ // Hours, minutes and optional seconds with `:` delimiter
9735
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
9736
+ // so this token always has the same output as `XXX`
9737
+ case "XXXXX":
9738
+ case "XXX": // Hours and minutes with `:` delimiter
9739
+ default:
9740
+ return formatTimezone(timezoneOffset, ":");
9741
+ }
9742
+ },
9743
+
9744
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
9745
+ x: function (date, token, _localize) {
9746
+ const timezoneOffset = date.getTimezoneOffset();
9747
+
9748
+ switch (token) {
9749
+ // Hours and optional minutes
9750
+ case "x":
9751
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
9752
+
9753
+ // Hours, minutes and optional seconds without `:` delimiter
9754
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
9755
+ // so this token always has the same output as `xx`
9756
+ case "xxxx":
9757
+ case "xx": // Hours and minutes without `:` delimiter
9758
+ return formatTimezone(timezoneOffset);
9759
+
9760
+ // Hours, minutes and optional seconds with `:` delimiter
9761
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
9762
+ // so this token always has the same output as `xxx`
9763
+ case "xxxxx":
9764
+ case "xxx": // Hours and minutes with `:` delimiter
9765
+ default:
9766
+ return formatTimezone(timezoneOffset, ":");
9767
+ }
9768
+ },
9769
+
9770
+ // Timezone (GMT)
9771
+ O: function (date, token, _localize) {
9772
+ const timezoneOffset = date.getTimezoneOffset();
9773
+
9774
+ switch (token) {
9775
+ // Short
9776
+ case "O":
9777
+ case "OO":
9778
+ case "OOO":
9779
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
9780
+ // Long
9781
+ case "OOOO":
9782
+ default:
9783
+ return "GMT" + formatTimezone(timezoneOffset, ":");
9784
+ }
9785
+ },
9786
+
9787
+ // Timezone (specific non-location)
9788
+ z: function (date, token, _localize) {
9789
+ const timezoneOffset = date.getTimezoneOffset();
9790
+
9791
+ switch (token) {
9792
+ // Short
9793
+ case "z":
9794
+ case "zz":
9795
+ case "zzz":
9796
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
9797
+ // Long
9798
+ case "zzzz":
9799
+ default:
9800
+ return "GMT" + formatTimezone(timezoneOffset, ":");
9801
+ }
9802
+ },
9803
+
9804
+ // Seconds timestamp
9805
+ t: function (date, token, _localize) {
9806
+ const timestamp = Math.trunc(+date / 1000);
9807
+ return addLeadingZeros(timestamp, token.length);
9808
+ },
9809
+
9810
+ // Milliseconds timestamp
9811
+ T: function (date, token, _localize) {
9812
+ return addLeadingZeros(+date, token.length);
9813
+ },
9814
+ };
9815
+
9816
+ function formatTimezoneShort(offset, delimiter = "") {
9817
+ const sign = offset > 0 ? "-" : "+";
9818
+ const absOffset = Math.abs(offset);
9819
+ const hours = Math.trunc(absOffset / 60);
9820
+ const minutes = absOffset % 60;
9821
+ if (minutes === 0) {
9822
+ return sign + String(hours);
9823
+ }
9824
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
9825
+ }
9826
+
9827
+ function formatTimezoneWithOptionalMinutes(offset, delimiter) {
9828
+ if (offset % 60 === 0) {
9829
+ const sign = offset > 0 ? "-" : "+";
9830
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
9831
+ }
9832
+ return formatTimezone(offset, delimiter);
9833
+ }
9834
+
9835
+ function formatTimezone(offset, delimiter = "") {
9836
+ const sign = offset > 0 ? "-" : "+";
9837
+ const absOffset = Math.abs(offset);
9838
+ const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
9839
+ const minutes = addLeadingZeros(absOffset % 60, 2);
9840
+ return sign + hours + delimiter + minutes;
9841
+ }
9842
+
9843
+ const dateLongFormatter = (pattern, formatLong) => {
9844
+ switch (pattern) {
9845
+ case "P":
9846
+ return formatLong.date({ width: "short" });
9847
+ case "PP":
9848
+ return formatLong.date({ width: "medium" });
9849
+ case "PPP":
9850
+ return formatLong.date({ width: "long" });
9851
+ case "PPPP":
9852
+ default:
9853
+ return formatLong.date({ width: "full" });
9854
+ }
9855
+ };
9856
+
9857
+ const timeLongFormatter = (pattern, formatLong) => {
9858
+ switch (pattern) {
9859
+ case "p":
9860
+ return formatLong.time({ width: "short" });
9861
+ case "pp":
9862
+ return formatLong.time({ width: "medium" });
9863
+ case "ppp":
9864
+ return formatLong.time({ width: "long" });
9865
+ case "pppp":
9866
+ default:
9867
+ return formatLong.time({ width: "full" });
9868
+ }
9869
+ };
9870
+
9871
+ const dateTimeLongFormatter = (pattern, formatLong) => {
9872
+ const matchResult = pattern.match(/(P+)(p+)?/) || [];
9873
+ const datePattern = matchResult[1];
9874
+ const timePattern = matchResult[2];
9875
+
9876
+ if (!timePattern) {
9877
+ return dateLongFormatter(pattern, formatLong);
9878
+ }
9879
+
9880
+ let dateTimeFormat;
9881
+
9882
+ switch (datePattern) {
9883
+ case "P":
9884
+ dateTimeFormat = formatLong.dateTime({ width: "short" });
9885
+ break;
9886
+ case "PP":
9887
+ dateTimeFormat = formatLong.dateTime({ width: "medium" });
9888
+ break;
9889
+ case "PPP":
9890
+ dateTimeFormat = formatLong.dateTime({ width: "long" });
9891
+ break;
9892
+ case "PPPP":
9893
+ default:
9894
+ dateTimeFormat = formatLong.dateTime({ width: "full" });
9895
+ break;
9896
+ }
9897
+
9898
+ return dateTimeFormat
9899
+ .replace("{{date}}", dateLongFormatter(datePattern, formatLong))
9900
+ .replace("{{time}}", timeLongFormatter(timePattern, formatLong));
9901
+ };
9902
+
9903
+ const longFormatters = {
9904
+ p: timeLongFormatter,
9905
+ P: dateTimeLongFormatter,
9906
+ };
9907
+
9908
+ const dayOfYearTokenRE = /^D+$/;
9909
+ const weekYearTokenRE = /^Y+$/;
9910
+
9911
+ const throwTokens = ["D", "DD", "YY", "YYYY"];
9912
+
9913
+ function isProtectedDayOfYearToken(token) {
9914
+ return dayOfYearTokenRE.test(token);
9915
+ }
9916
+
9917
+ function isProtectedWeekYearToken(token) {
9918
+ return weekYearTokenRE.test(token);
9919
+ }
9920
+
9921
+ function warnOrThrowProtectedError(token, format, input) {
9922
+ const _message = message(token, format, input);
9923
+ console.warn(_message);
9924
+ if (throwTokens.includes(token)) throw new RangeError(_message);
9925
+ }
9926
+
9927
+ function message(token, format, input) {
9928
+ const subject = token[0] === "Y" ? "years" : "days of the month";
9929
+ return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
9930
+ }
9931
+
9932
+ // This RegExp consists of three parts separated by `|`:
9933
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
9934
+ // (one of the certain letters followed by `o`)
9935
+ // - (\w)\1* matches any sequences of the same letter
9936
+ // - '' matches two quote characters in a row
9937
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
9938
+ // except a single quote symbol, which ends the sequence.
9939
+ // Two quote characters do not end the sequence.
9940
+ // If there is no matching single quote
9941
+ // then the sequence will continue until the end of the string.
9942
+ // - . matches any single character unmatched by previous parts of the RegExps
9943
+ const formattingTokensRegExp =
9944
+ /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
9945
+
9946
+ // This RegExp catches symbols escaped by quotes, and also
9947
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
9948
+ const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
9949
+
9950
+ const escapedStringRegExp = /^'([^]*?)'?$/;
9951
+ const doubleQuoteRegExp = /''/g;
9952
+ const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
9953
+
9954
+ /**
9955
+ * The {@link format} function options.
9956
+ */
9957
+
9958
+ /**
9959
+ * @name format
9960
+ * @alias formatDate
9961
+ * @category Common Helpers
9962
+ * @summary Format the date.
9963
+ *
9964
+ * @description
9965
+ * Return the formatted date string in the given format. The result may vary by locale.
9966
+ *
9967
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
9968
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
9969
+ *
9970
+ * The characters wrapped between two single quotes characters (') are escaped.
9971
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
9972
+ * (see the last example)
9973
+ *
9974
+ * Format of the string is based on Unicode Technical Standard #35:
9975
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
9976
+ * with a few additions (see note 7 below the table).
9977
+ *
9978
+ * Accepted patterns:
9979
+ * | Unit | Pattern | Result examples | Notes |
9980
+ * |---------------------------------|---------|-----------------------------------|-------|
9981
+ * | Era | G..GGG | AD, BC | |
9982
+ * | | GGGG | Anno Domini, Before Christ | 2 |
9983
+ * | | GGGGG | A, B | |
9984
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
9985
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
9986
+ * | | yy | 44, 01, 00, 17 | 5 |
9987
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
9988
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
9989
+ * | | yyyyy | ... | 3,5 |
9990
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
9991
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
9992
+ * | | YY | 44, 01, 00, 17 | 5,8 |
9993
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
9994
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
9995
+ * | | YYYYY | ... | 3,5 |
9996
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
9997
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
9998
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
9999
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
10000
+ * | | RRRRR | ... | 3,5,7 |
10001
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
10002
+ * | | uu | -43, 01, 1900, 2017 | 5 |
10003
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
10004
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
10005
+ * | | uuuuu | ... | 3,5 |
10006
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
10007
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
10008
+ * | | QQ | 01, 02, 03, 04 | |
10009
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
10010
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
10011
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
10012
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
10013
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
10014
+ * | | qq | 01, 02, 03, 04 | |
10015
+ * | | qqq | Q1, Q2, Q3, Q4 | |
10016
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
10017
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
10018
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
10019
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
10020
+ * | | MM | 01, 02, ..., 12 | |
10021
+ * | | MMM | Jan, Feb, ..., Dec | |
10022
+ * | | MMMM | January, February, ..., December | 2 |
10023
+ * | | MMMMM | J, F, ..., D | |
10024
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
10025
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
10026
+ * | | LL | 01, 02, ..., 12 | |
10027
+ * | | LLL | Jan, Feb, ..., Dec | |
10028
+ * | | LLLL | January, February, ..., December | 2 |
10029
+ * | | LLLLL | J, F, ..., D | |
10030
+ * | Local week of year | w | 1, 2, ..., 53 | |
10031
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
10032
+ * | | ww | 01, 02, ..., 53 | |
10033
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
10034
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
10035
+ * | | II | 01, 02, ..., 53 | 7 |
10036
+ * | Day of month | d | 1, 2, ..., 31 | |
10037
+ * | | do | 1st, 2nd, ..., 31st | 7 |
10038
+ * | | dd | 01, 02, ..., 31 | |
10039
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
10040
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
10041
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
10042
+ * | | DDD | 001, 002, ..., 365, 366 | |
10043
+ * | | DDDD | ... | 3 |
10044
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
10045
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
10046
+ * | | EEEEE | M, T, W, T, F, S, S | |
10047
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
10048
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
10049
+ * | | io | 1st, 2nd, ..., 7th | 7 |
10050
+ * | | ii | 01, 02, ..., 07 | 7 |
10051
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
10052
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
10053
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
10054
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
10055
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
10056
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
10057
+ * | | ee | 02, 03, ..., 01 | |
10058
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
10059
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
10060
+ * | | eeeee | M, T, W, T, F, S, S | |
10061
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
10062
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
10063
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
10064
+ * | | cc | 02, 03, ..., 01 | |
10065
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
10066
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
10067
+ * | | ccccc | M, T, W, T, F, S, S | |
10068
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
10069
+ * | AM, PM | a..aa | AM, PM | |
10070
+ * | | aaa | am, pm | |
10071
+ * | | aaaa | a.m., p.m. | 2 |
10072
+ * | | aaaaa | a, p | |
10073
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
10074
+ * | | bbb | am, pm, noon, midnight | |
10075
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
10076
+ * | | bbbbb | a, p, n, mi | |
10077
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
10078
+ * | | BBBB | at night, in the morning, ... | 2 |
10079
+ * | | BBBBB | at night, in the morning, ... | |
10080
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
10081
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
10082
+ * | | hh | 01, 02, ..., 11, 12 | |
10083
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
10084
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
10085
+ * | | HH | 00, 01, 02, ..., 23 | |
10086
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
10087
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
10088
+ * | | KK | 01, 02, ..., 11, 00 | |
10089
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
10090
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
10091
+ * | | kk | 24, 01, 02, ..., 23 | |
10092
+ * | Minute | m | 0, 1, ..., 59 | |
10093
+ * | | mo | 0th, 1st, ..., 59th | 7 |
10094
+ * | | mm | 00, 01, ..., 59 | |
10095
+ * | Second | s | 0, 1, ..., 59 | |
10096
+ * | | so | 0th, 1st, ..., 59th | 7 |
10097
+ * | | ss | 00, 01, ..., 59 | |
10098
+ * | Fraction of second | S | 0, 1, ..., 9 | |
10099
+ * | | SS | 00, 01, ..., 99 | |
10100
+ * | | SSS | 000, 001, ..., 999 | |
10101
+ * | | SSSS | ... | 3 |
10102
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
10103
+ * | | XX | -0800, +0530, Z | |
10104
+ * | | XXX | -08:00, +05:30, Z | |
10105
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
10106
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
10107
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
10108
+ * | | xx | -0800, +0530, +0000 | |
10109
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
10110
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
10111
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
10112
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
10113
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
10114
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
10115
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
10116
+ * | Seconds timestamp | t | 512969520 | 7 |
10117
+ * | | tt | ... | 3,7 |
10118
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
10119
+ * | | TT | ... | 3,7 |
10120
+ * | Long localized date | P | 04/29/1453 | 7 |
10121
+ * | | PP | Apr 29, 1453 | 7 |
10122
+ * | | PPP | April 29th, 1453 | 7 |
10123
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
10124
+ * | Long localized time | p | 12:00 AM | 7 |
10125
+ * | | pp | 12:00:00 AM | 7 |
10126
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
10127
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
10128
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
10129
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
10130
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
10131
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
10132
+ * Notes:
10133
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
10134
+ * are the same as "stand-alone" units, but are different in some languages.
10135
+ * "Formatting" units are declined according to the rules of the language
10136
+ * in the context of a date. "Stand-alone" units are always nominative singular:
10137
+ *
10138
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
10139
+ *
10140
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
10141
+ *
10142
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
10143
+ * the single quote characters (see below).
10144
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
10145
+ * the output will be the same as default pattern for this unit, usually
10146
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
10147
+ * are marked with "2" in the last column of the table.
10148
+ *
10149
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
10150
+ *
10151
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
10152
+ *
10153
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
10154
+ *
10155
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
10156
+ *
10157
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
10158
+ *
10159
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
10160
+ * The output will be padded with zeros to match the length of the pattern.
10161
+ *
10162
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
10163
+ *
10164
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
10165
+ * These tokens represent the shortest form of the quarter.
10166
+ *
10167
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
10168
+ *
10169
+ * | Year | `y` | `u` |
10170
+ * |------|-----|-----|
10171
+ * | AC 1 | 1 | 1 |
10172
+ * | BC 1 | 1 | 0 |
10173
+ * | BC 2 | 2 | -1 |
10174
+ *
10175
+ * Also `yy` always returns the last two digits of a year,
10176
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
10177
+ *
10178
+ * | Year | `yy` | `uu` |
10179
+ * |------|------|------|
10180
+ * | 1 | 01 | 01 |
10181
+ * | 14 | 14 | 14 |
10182
+ * | 376 | 76 | 376 |
10183
+ * | 1453 | 53 | 1453 |
10184
+ *
10185
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
10186
+ * except local week-numbering years are dependent on `options.weekStartsOn`
10187
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear)
10188
+ * and [getWeekYear](https://date-fns.org/docs/getWeekYear)).
10189
+ *
10190
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
10191
+ * so right now these tokens fall back to GMT timezones.
10192
+ *
10193
+ * 7. These patterns are not in the Unicode Technical Standard #35:
10194
+ * - `i`: ISO day of week
10195
+ * - `I`: ISO week of year
10196
+ * - `R`: ISO week-numbering year
10197
+ * - `t`: seconds timestamp
10198
+ * - `T`: milliseconds timestamp
10199
+ * - `o`: ordinal number modifier
10200
+ * - `P`: long localized date
10201
+ * - `p`: long localized time
10202
+ *
10203
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
10204
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
10205
+ *
10206
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
10207
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
10208
+ *
10209
+ * @param date - The original date
10210
+ * @param format - The string of tokens
10211
+ * @param options - An object with options
10212
+ *
10213
+ * @returns The formatted date string
10214
+ *
10215
+ * @throws `date` must not be Invalid Date
10216
+ * @throws `options.locale` must contain `localize` property
10217
+ * @throws `options.locale` must contain `formatLong` property
10218
+ * @throws use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
10219
+ * @throws use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
10220
+ * @throws use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
10221
+ * @throws use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
10222
+ * @throws format string contains an unescaped latin alphabet character
10223
+ *
10224
+ * @example
10225
+ * // Represent 11 February 2014 in middle-endian format:
10226
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
10227
+ * //=> '02/11/2014'
10228
+ *
10229
+ * @example
10230
+ * // Represent 2 July 2014 in Esperanto:
10231
+ * import { eoLocale } from 'date-fns/locale/eo'
10232
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
10233
+ * locale: eoLocale
10234
+ * })
10235
+ * //=> '2-a de julio 2014'
10236
+ *
10237
+ * @example
10238
+ * // Escape string by single quote characters:
10239
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
10240
+ * //=> "3 o'clock"
10241
+ */
10242
+ function format(date, formatStr, options) {
10243
+ const defaultOptions = getDefaultOptions();
10244
+ const locale = defaultOptions.locale ?? enUS;
10245
+
10246
+ const firstWeekContainsDate =
10247
+ defaultOptions.firstWeekContainsDate ??
10248
+ defaultOptions.locale?.options?.firstWeekContainsDate ??
10249
+ 1;
10250
+
10251
+ const weekStartsOn =
10252
+ defaultOptions.weekStartsOn ??
10253
+ defaultOptions.locale?.options?.weekStartsOn ??
10254
+ 0;
10255
+
10256
+ const originalDate = toDate(date, options?.in);
10257
+
10258
+ if (!isValid(originalDate)) {
10259
+ throw new RangeError("Invalid time value");
10260
+ }
10261
+
10262
+ let parts = formatStr
10263
+ .match(longFormattingTokensRegExp)
10264
+ .map((substring) => {
10265
+ const firstCharacter = substring[0];
10266
+ if (firstCharacter === "p" || firstCharacter === "P") {
10267
+ const longFormatter = longFormatters[firstCharacter];
10268
+ return longFormatter(substring, locale.formatLong);
10269
+ }
10270
+ return substring;
10271
+ })
10272
+ .join("")
10273
+ .match(formattingTokensRegExp)
10274
+ .map((substring) => {
10275
+ // Replace two single quote characters with one single quote character
10276
+ if (substring === "''") {
10277
+ return { isToken: false, value: "'" };
10278
+ }
10279
+
10280
+ const firstCharacter = substring[0];
10281
+ if (firstCharacter === "'") {
10282
+ return { isToken: false, value: cleanEscapedString(substring) };
10283
+ }
10284
+
10285
+ if (formatters[firstCharacter]) {
10286
+ return { isToken: true, value: substring };
10287
+ }
10288
+
10289
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
10290
+ throw new RangeError(
10291
+ "Format string contains an unescaped latin alphabet character `" +
10292
+ firstCharacter +
10293
+ "`",
10294
+ );
10295
+ }
10296
+
10297
+ return { isToken: false, value: substring };
10298
+ });
10299
+
10300
+ // invoke localize preprocessor (only for french locales at the moment)
10301
+ if (locale.localize.preprocessor) {
10302
+ parts = locale.localize.preprocessor(originalDate, parts);
10303
+ }
10304
+
10305
+ const formatterOptions = {
10306
+ firstWeekContainsDate,
10307
+ weekStartsOn,
10308
+ locale,
10309
+ };
10310
+
10311
+ return parts
10312
+ .map((part) => {
10313
+ if (!part.isToken) return part.value;
10314
+
10315
+ const token = part.value;
10316
+
10317
+ if (
10318
+ (isProtectedWeekYearToken(token)) ||
10319
+ (isProtectedDayOfYearToken(token))
10320
+ ) {
10321
+ warnOrThrowProtectedError(token, formatStr, String(date));
10322
+ }
10323
+
10324
+ const formatter = formatters[token[0]];
10325
+ return formatter(originalDate, token, locale.localize, formatterOptions);
10326
+ })
10327
+ .join("");
10328
+ }
10329
+
10330
+ function cleanEscapedString(input) {
10331
+ const matched = input.match(escapedStringRegExp);
10332
+
10333
+ if (!matched) {
10334
+ return input;
10335
+ }
10336
+
10337
+ return matched[1].replace(doubleQuoteRegExp, "'");
10338
+ }
10339
+
10340
+ /**
10341
+ * The {@link isSameWeek} function options.
10342
+ */
10343
+
10344
+ /**
10345
+ * @name isSameWeek
10346
+ * @category Week Helpers
10347
+ * @summary Are the given dates in the same week (and month and year)?
10348
+ *
10349
+ * @description
10350
+ * Are the given dates in the same week (and month and year)?
10351
+ *
10352
+ * @param laterDate - The first date to check
10353
+ * @param earlierDate - The second date to check
10354
+ * @param options - An object with options
10355
+ *
10356
+ * @returns The dates are in the same week (and month and year)
10357
+ *
10358
+ * @example
10359
+ * // Are 31 August 2014 and 4 September 2014 in the same week?
10360
+ * const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4))
10361
+ * //=> true
10362
+ *
10363
+ * @example
10364
+ * // If week starts with Monday,
10365
+ * // are 31 August 2014 and 4 September 2014 in the same week?
10366
+ * const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4), {
10367
+ * weekStartsOn: 1
10368
+ * })
10369
+ * //=> false
10370
+ *
10371
+ * @example
10372
+ * // Are 1 January 2014 and 1 January 2015 in the same week?
10373
+ * const result = isSameWeek(new Date(2014, 0, 1), new Date(2015, 0, 1))
10374
+ * //=> false
10375
+ */
10376
+ function isSameWeek(laterDate, earlierDate, options) {
10377
+ const [laterDate_, earlierDate_] = normalizeDates(
10378
+ options?.in,
10379
+ laterDate,
10380
+ earlierDate,
10381
+ );
10382
+ return (
10383
+ +startOfWeek(laterDate_, options) === +startOfWeek(earlierDate_, options)
10384
+ );
10385
+ }
10386
+
10387
+ class LocalizationService {
10388
+ defaultFormatStr = 'dd.MM.yyyy';
10389
+ format({ date, formatStr = this.defaultFormatStr, }) {
10390
+ const formatDate = format(date, formatStr);
10391
+ return formatDate;
10392
+ }
10393
+ }
10394
+ const localizationService = new LocalizationService();
10395
+
7565
10396
  /* eslint-disable no-console */
7566
10397
  class LoggerService {
7567
10398
  constructor() { }
@@ -25948,15 +28779,6 @@ const formatDistance = (token, count, options) => {
25948
28779
  return formatDistanceLocale[token](count, options);
25949
28780
  };
25950
28781
 
25951
- function buildFormatLongFn(args) {
25952
- return (options = {}) => {
25953
- // TODO: Remove String()
25954
- const width = options.width ? String(options.width) : args.defaultWidth;
25955
- const format = args.formats[width] || args.formats[args.defaultWidth];
25956
- return format;
25957
- };
25958
- }
25959
-
25960
28782
  const dateFormats = {
25961
28783
  full: "EEEE, d MMMM y 'г.'",
25962
28784
  long: "d MMMM y 'г.'",
@@ -25992,236 +28814,6 @@ const formatLong = {
25992
28814
  }),
25993
28815
  };
25994
28816
 
25995
- /**
25996
- * @module constants
25997
- * @summary Useful constants
25998
- * @description
25999
- * Collection of useful date constants.
26000
- *
26001
- * The constants could be imported from `date-fns/constants`:
26002
- *
26003
- * ```ts
26004
- * import { maxTime, minTime } from "./constants/date-fns/constants";
26005
- *
26006
- * function isAllowedTime(time) {
26007
- * return time <= maxTime && time >= minTime;
26008
- * }
26009
- * ```
26010
- */
26011
-
26012
-
26013
- /**
26014
- * @constant
26015
- * @name constructFromSymbol
26016
- * @summary Symbol enabling Date extensions to inherit properties from the reference date.
26017
- *
26018
- * The symbol is used to enable the `constructFrom` function to construct a date
26019
- * using a reference date and a value. It allows to transfer extra properties
26020
- * from the reference date to the new date. It's useful for extensions like
26021
- * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as
26022
- * a constructor argument.
26023
- */
26024
- const constructFromSymbol = Symbol.for("constructDateFrom");
26025
-
26026
- /**
26027
- * @name constructFrom
26028
- * @category Generic Helpers
26029
- * @summary Constructs a date using the reference date and the value
26030
- *
26031
- * @description
26032
- * The function constructs a new date using the constructor from the reference
26033
- * date and the given value. It helps to build generic functions that accept
26034
- * date extensions.
26035
- *
26036
- * It defaults to `Date` if the passed reference date is a number or a string.
26037
- *
26038
- * Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]`
26039
- * enabling to transfer extra properties from the reference date to the new date.
26040
- * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
26041
- * that accept a time zone as a constructor argument.
26042
- *
26043
- * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
26044
- *
26045
- * @param date - The reference date to take constructor from
26046
- * @param value - The value to create the date
26047
- *
26048
- * @returns Date initialized using the given date and value
26049
- *
26050
- * @example
26051
- * import { constructFrom } from "./constructFrom/date-fns";
26052
- *
26053
- * // A function that clones a date preserving the original type
26054
- * function cloneDate<DateType extends Date>(date: DateType): DateType {
26055
- * return constructFrom(
26056
- * date, // Use constructor from the given date
26057
- * date.getTime() // Use the date value to create a new date
26058
- * );
26059
- * }
26060
- */
26061
- function constructFrom(date, value) {
26062
- if (typeof date === "function") return date(value);
26063
-
26064
- if (date && typeof date === "object" && constructFromSymbol in date)
26065
- return date[constructFromSymbol](value);
26066
-
26067
- if (date instanceof Date) return new date.constructor(value);
26068
-
26069
- return new Date(value);
26070
- }
26071
-
26072
- function normalizeDates(context, ...dates) {
26073
- const normalize = constructFrom.bind(
26074
- null,
26075
- context || dates.find((date) => typeof date === "object"),
26076
- );
26077
- return dates.map(normalize);
26078
- }
26079
-
26080
- let defaultOptions$2 = {};
26081
-
26082
- function getDefaultOptions() {
26083
- return defaultOptions$2;
26084
- }
26085
-
26086
- /**
26087
- * @name toDate
26088
- * @category Common Helpers
26089
- * @summary Convert the given argument to an instance of Date.
26090
- *
26091
- * @description
26092
- * Convert the given argument to an instance of Date.
26093
- *
26094
- * If the argument is an instance of Date, the function returns its clone.
26095
- *
26096
- * If the argument is a number, it is treated as a timestamp.
26097
- *
26098
- * If the argument is none of the above, the function returns Invalid Date.
26099
- *
26100
- * Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]`
26101
- * enabling to transfer extra properties from the reference date to the new date.
26102
- * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
26103
- * that accept a time zone as a constructor argument.
26104
- *
26105
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
26106
- *
26107
- * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
26108
- * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
26109
- *
26110
- * @param argument - The value to convert
26111
- *
26112
- * @returns The parsed date in the local time zone
26113
- *
26114
- * @example
26115
- * // Clone the date:
26116
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
26117
- * //=> Tue Feb 11 2014 11:30:30
26118
- *
26119
- * @example
26120
- * // Convert the timestamp to date:
26121
- * const result = toDate(1392098430000)
26122
- * //=> Tue Feb 11 2014 11:30:30
26123
- */
26124
- function toDate(argument, context) {
26125
- // [TODO] Get rid of `toDate` or `constructFrom`?
26126
- return constructFrom(context || argument, argument);
26127
- }
26128
-
26129
- /**
26130
- * The {@link startOfWeek} function options.
26131
- */
26132
-
26133
- /**
26134
- * @name startOfWeek
26135
- * @category Week Helpers
26136
- * @summary Return the start of a week for the given date.
26137
- *
26138
- * @description
26139
- * Return the start of a week for the given date.
26140
- * The result will be in the local timezone.
26141
- *
26142
- * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
26143
- * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
26144
- *
26145
- * @param date - The original date
26146
- * @param options - An object with options
26147
- *
26148
- * @returns The start of a week
26149
- *
26150
- * @example
26151
- * // The start of a week for 2 September 2014 11:55:00:
26152
- * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
26153
- * //=> Sun Aug 31 2014 00:00:00
26154
- *
26155
- * @example
26156
- * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
26157
- * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
26158
- * //=> Mon Sep 01 2014 00:00:00
26159
- */
26160
- function startOfWeek(date, options) {
26161
- const defaultOptions = getDefaultOptions();
26162
- const weekStartsOn =
26163
- options?.weekStartsOn ??
26164
- options?.locale?.options?.weekStartsOn ??
26165
- defaultOptions.weekStartsOn ??
26166
- defaultOptions.locale?.options?.weekStartsOn ??
26167
- 0;
26168
-
26169
- const _date = toDate(date, options?.in);
26170
- const day = _date.getDay();
26171
- const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
26172
-
26173
- _date.setDate(_date.getDate() - diff);
26174
- _date.setHours(0, 0, 0, 0);
26175
- return _date;
26176
- }
26177
-
26178
- /**
26179
- * The {@link isSameWeek} function options.
26180
- */
26181
-
26182
- /**
26183
- * @name isSameWeek
26184
- * @category Week Helpers
26185
- * @summary Are the given dates in the same week (and month and year)?
26186
- *
26187
- * @description
26188
- * Are the given dates in the same week (and month and year)?
26189
- *
26190
- * @param laterDate - The first date to check
26191
- * @param earlierDate - The second date to check
26192
- * @param options - An object with options
26193
- *
26194
- * @returns The dates are in the same week (and month and year)
26195
- *
26196
- * @example
26197
- * // Are 31 August 2014 and 4 September 2014 in the same week?
26198
- * const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4))
26199
- * //=> true
26200
- *
26201
- * @example
26202
- * // If week starts with Monday,
26203
- * // are 31 August 2014 and 4 September 2014 in the same week?
26204
- * const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4), {
26205
- * weekStartsOn: 1
26206
- * })
26207
- * //=> false
26208
- *
26209
- * @example
26210
- * // Are 1 January 2014 and 1 January 2015 in the same week?
26211
- * const result = isSameWeek(new Date(2014, 0, 1), new Date(2015, 0, 1))
26212
- * //=> false
26213
- */
26214
- function isSameWeek(laterDate, earlierDate, options) {
26215
- const [laterDate_, earlierDate_] = normalizeDates(
26216
- options?.in,
26217
- laterDate,
26218
- earlierDate,
26219
- );
26220
- return (
26221
- +startOfWeek(laterDate_, options) === +startOfWeek(earlierDate_, options)
26222
- );
26223
- }
26224
-
26225
28817
  const accusativeWeekdays = [
26226
28818
  "воскресенье",
26227
28819
  "понедельник",
@@ -26309,69 +28901,6 @@ const formatRelative = (token, date, baseDate, options) => {
26309
28901
  return format;
26310
28902
  };
26311
28903
 
26312
- /**
26313
- * The localize function argument callback which allows to convert raw value to
26314
- * the actual type.
26315
- *
26316
- * @param value - The value to convert
26317
- *
26318
- * @returns The converted value
26319
- */
26320
-
26321
- /**
26322
- * The map of localized values for each width.
26323
- */
26324
-
26325
- /**
26326
- * The index type of the locale unit value. It types conversion of units of
26327
- * values that don't start at 0 (i.e. quarters).
26328
- */
26329
-
26330
- /**
26331
- * Converts the unit value to the tuple of values.
26332
- */
26333
-
26334
- /**
26335
- * The tuple of localized era values. The first element represents BC,
26336
- * the second element represents AD.
26337
- */
26338
-
26339
- /**
26340
- * The tuple of localized quarter values. The first element represents Q1.
26341
- */
26342
-
26343
- /**
26344
- * The tuple of localized day values. The first element represents Sunday.
26345
- */
26346
-
26347
- /**
26348
- * The tuple of localized month values. The first element represents January.
26349
- */
26350
-
26351
- function buildLocalizeFn(args) {
26352
- return (value, options) => {
26353
- const context = options?.context ? String(options.context) : "standalone";
26354
-
26355
- let valuesArray;
26356
- if (context === "formatting" && args.formattingValues) {
26357
- const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
26358
- const width = options?.width ? String(options.width) : defaultWidth;
26359
-
26360
- valuesArray =
26361
- args.formattingValues[width] || args.formattingValues[defaultWidth];
26362
- } else {
26363
- const defaultWidth = args.defaultWidth;
26364
- const width = options?.width ? String(options.width) : args.defaultWidth;
26365
-
26366
- valuesArray = args.values[width] || args.values[defaultWidth];
26367
- }
26368
- const index = args.argumentCallback ? args.argumentCallback(value) : value;
26369
-
26370
- // @ts-expect-error - For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
26371
- return valuesArray[index];
26372
- };
26373
- }
26374
-
26375
28904
  const eraValues = {
26376
28905
  narrow: ["до н.э.", "н.э."],
26377
28906
  abbreviated: ["до н. э.", "н. э."],
@@ -26581,85 +29110,6 @@ const localize = {
26581
29110
  }),
26582
29111
  };
26583
29112
 
26584
- function buildMatchFn(args) {
26585
- return (string, options = {}) => {
26586
- const width = options.width;
26587
-
26588
- const matchPattern =
26589
- (width && args.matchPatterns[width]) ||
26590
- args.matchPatterns[args.defaultMatchWidth];
26591
- const matchResult = string.match(matchPattern);
26592
-
26593
- if (!matchResult) {
26594
- return null;
26595
- }
26596
- const matchedString = matchResult[0];
26597
-
26598
- const parsePatterns =
26599
- (width && args.parsePatterns[width]) ||
26600
- args.parsePatterns[args.defaultParseWidth];
26601
-
26602
- const key = Array.isArray(parsePatterns)
26603
- ? findIndex$1(parsePatterns, (pattern) => pattern.test(matchedString))
26604
- : // [TODO] -- I challenge you to fix the type
26605
- findKey(parsePatterns, (pattern) => pattern.test(matchedString));
26606
-
26607
- let value;
26608
-
26609
- value = args.valueCallback ? args.valueCallback(key) : key;
26610
- value = options.valueCallback
26611
- ? // [TODO] -- I challenge you to fix the type
26612
- options.valueCallback(value)
26613
- : value;
26614
-
26615
- const rest = string.slice(matchedString.length);
26616
-
26617
- return { value, rest };
26618
- };
26619
- }
26620
-
26621
- function findKey(object, predicate) {
26622
- for (const key in object) {
26623
- if (
26624
- Object.prototype.hasOwnProperty.call(object, key) &&
26625
- predicate(object[key])
26626
- ) {
26627
- return key;
26628
- }
26629
- }
26630
- return undefined;
26631
- }
26632
-
26633
- function findIndex$1(array, predicate) {
26634
- for (let key = 0; key < array.length; key++) {
26635
- if (predicate(array[key])) {
26636
- return key;
26637
- }
26638
- }
26639
- return undefined;
26640
- }
26641
-
26642
- function buildMatchPatternFn(args) {
26643
- return (string, options = {}) => {
26644
- const matchResult = string.match(args.matchPattern);
26645
- if (!matchResult) return null;
26646
- const matchedString = matchResult[0];
26647
-
26648
- const parseResult = string.match(args.parsePattern);
26649
- if (!parseResult) return null;
26650
- let value = args.valueCallback
26651
- ? args.valueCallback(parseResult[0])
26652
- : parseResult[0];
26653
-
26654
- // [TODO] I challenge you to fix the type
26655
- value = options.valueCallback ? options.valueCallback(value) : value;
26656
-
26657
- const rest = string.slice(matchedString.length);
26658
-
26659
- return { value, rest };
26660
- };
26661
- }
26662
-
26663
29113
  const matchOrdinalNumberPattern = /^(\d+)(-?(е|я|й|ое|ье|ая|ья|ый|ой|ий|ый))?/i;
26664
29114
  const parseOrdinalNumberPattern = /\d+/i;
26665
29115
 
@@ -47944,6 +50394,7 @@ exports.getValidLayer = getValidLayer;
47944
50394
  exports.getWaterAreaLayers = getWaterAreaLayers;
47945
50395
  exports.getWaterLinkLayers = getWaterLinkLayers;
47946
50396
  exports.localStateService = localStateService;
50397
+ exports.localizationService = localizationService;
47947
50398
  exports.loggerService = loggerService;
47948
50399
  exports.mapService = mapService;
47949
50400
  exports.modalStore = modalStore;