diff --git a/node_modules/date-fns/differenceInCalendarYears.d.cts b/node_modules/date-fns/differenceInCalendarYears.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2933d8a8eca860c47487ccd95dfbe10c77eda46d --- /dev/null +++ b/node_modules/date-fns/differenceInCalendarYears.d.cts @@ -0,0 +1,33 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInCalendarYears} function options. + */ +export interface DifferenceInCalendarYearsOptions + extends ContextOptions {} +/** + * @name differenceInCalendarYears + * @category Year Helpers + * @summary Get the number of calendar years between the given dates. + * + * @description + * Get the number of calendar years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + + * @returns The number of calendar years + * + * @example + * // How many calendar years are between 31 December 2013 and 11 February 2015? + * const result = differenceInCalendarYears( + * new Date(2015, 1, 11), + * new Date(2013, 11, 31) + * ); + * //=> 2 + */ +export declare function differenceInCalendarYears( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInCalendarYearsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInCalendarYears.d.ts b/node_modules/date-fns/differenceInCalendarYears.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2933d8a8eca860c47487ccd95dfbe10c77eda46d --- /dev/null +++ b/node_modules/date-fns/differenceInCalendarYears.d.ts @@ -0,0 +1,33 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInCalendarYears} function options. + */ +export interface DifferenceInCalendarYearsOptions + extends ContextOptions {} +/** + * @name differenceInCalendarYears + * @category Year Helpers + * @summary Get the number of calendar years between the given dates. + * + * @description + * Get the number of calendar years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + + * @returns The number of calendar years + * + * @example + * // How many calendar years are between 31 December 2013 and 11 February 2015? + * const result = differenceInCalendarYears( + * new Date(2015, 1, 11), + * new Date(2013, 11, 31) + * ); + * //=> 2 + */ +export declare function differenceInCalendarYears( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInCalendarYearsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInCalendarYears.js b/node_modules/date-fns/differenceInCalendarYears.js new file mode 100644 index 0000000000000000000000000000000000000000..3370d6e68d870b0a6c9a43263012c43c40356674 --- /dev/null +++ b/node_modules/date-fns/differenceInCalendarYears.js @@ -0,0 +1,39 @@ +import { normalizeDates } from "./_lib/normalizeDates.js"; + +/** + * The {@link differenceInCalendarYears} function options. + */ + +/** + * @name differenceInCalendarYears + * @category Year Helpers + * @summary Get the number of calendar years between the given dates. + * + * @description + * Get the number of calendar years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + + * @returns The number of calendar years + * + * @example + * // How many calendar years are between 31 December 2013 and 11 February 2015? + * const result = differenceInCalendarYears( + * new Date(2015, 1, 11), + * new Date(2013, 11, 31) + * ); + * //=> 2 + */ +export function differenceInCalendarYears(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + laterDate, + earlierDate, + ); + return laterDate_.getFullYear() - earlierDate_.getFullYear(); +} + +// Fallback for modularized imports: +export default differenceInCalendarYears; diff --git a/node_modules/date-fns/differenceInDays.cjs b/node_modules/date-fns/differenceInDays.cjs new file mode 100644 index 0000000000000000000000000000000000000000..5c997f9f67a0f885a9d27a2647be691bbe4b9750 --- /dev/null +++ b/node_modules/date-fns/differenceInDays.cjs @@ -0,0 +1,107 @@ +"use strict"; +exports.differenceInDays = differenceInDays; +var _index = require("./_lib/normalizeDates.cjs"); +var _index2 = require("./differenceInCalendarDays.cjs"); + +/** + * The {@link differenceInDays} function options. + */ + +/** + * @name differenceInDays + * @category Day Helpers + * @summary Get the number of full days between the given dates. + * + * @description + * Get the number of full day periods between two dates. Fractional days are + * truncated towards zero. + * + * One "full day" is the distance between a local time in one day to the same + * local time on the next or previous day. A full day can sometimes be less than + * or more than 24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/24)|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full days according to the local timezone + * + * @example + * // How many full days are between + * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00? + * const result = differenceInDays( + * new Date(2012, 6, 2, 0, 0), + * new Date(2011, 6, 2, 23, 0) + * ) + * //=> 365 + * + * @example + * // How many full days are between + * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00? + * const result = differenceInDays( + * new Date(2011, 6, 3, 0, 1), + * new Date(2011, 6, 2, 23, 59) + * ) + * //=> 0 + * + * @example + * // How many full days are between + * // 1 March 2020 0:00 and 1 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 92 days, even in + * // time zones where DST starts and the + * // period has only 92*24-1 hours. + * const result = differenceInDays( + * new Date(2020, 5, 1), + * new Date(2020, 2, 1) + * ) + * //=> 92 + */ +function differenceInDays(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = (0, _index.normalizeDates)( + options?.in, + laterDate, + earlierDate, + ); + + const sign = compareLocalAsc(laterDate_, earlierDate_); + const difference = Math.abs( + (0, _index2.differenceInCalendarDays)(laterDate_, earlierDate_), + ); + + laterDate_.setDate(laterDate_.getDate() - sign * difference); + + // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full + // If so, result must be decreased by 1 in absolute value + const isLastDayNotFull = Number( + compareLocalAsc(laterDate_, earlierDate_) === -sign, + ); + + const result = sign * (difference - isLastDayNotFull); + // Prevent negative zero + return result === 0 ? 0 : result; +} + +// Like `compareAsc` but uses local time not UTC, which is needed +// for accurate equality comparisons of UTC timestamps that end up +// having the same representation in local time, e.g. one hour before +// DST ends vs. the instant that DST ends. +function compareLocalAsc(laterDate, earlierDate) { + const diff = + laterDate.getFullYear() - earlierDate.getFullYear() || + laterDate.getMonth() - earlierDate.getMonth() || + laterDate.getDate() - earlierDate.getDate() || + laterDate.getHours() - earlierDate.getHours() || + laterDate.getMinutes() - earlierDate.getMinutes() || + laterDate.getSeconds() - earlierDate.getSeconds() || + laterDate.getMilliseconds() - earlierDate.getMilliseconds(); + + if (diff < 0) return -1; + if (diff > 0) return 1; + + // Return 0 if diff is 0; return NaN if diff is NaN + return diff; +} diff --git a/node_modules/date-fns/differenceInDays.d.cts b/node_modules/date-fns/differenceInDays.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..4dbdc16b52cffc634dda83068d83df0a47eb4769 --- /dev/null +++ b/node_modules/date-fns/differenceInDays.d.cts @@ -0,0 +1,63 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInDays} function options. + */ +export interface DifferenceInDaysOptions extends ContextOptions {} +/** + * @name differenceInDays + * @category Day Helpers + * @summary Get the number of full days between the given dates. + * + * @description + * Get the number of full day periods between two dates. Fractional days are + * truncated towards zero. + * + * One "full day" is the distance between a local time in one day to the same + * local time on the next or previous day. A full day can sometimes be less than + * or more than 24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/24)|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full days according to the local timezone + * + * @example + * // How many full days are between + * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00? + * const result = differenceInDays( + * new Date(2012, 6, 2, 0, 0), + * new Date(2011, 6, 2, 23, 0) + * ) + * //=> 365 + * + * @example + * // How many full days are between + * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00? + * const result = differenceInDays( + * new Date(2011, 6, 3, 0, 1), + * new Date(2011, 6, 2, 23, 59) + * ) + * //=> 0 + * + * @example + * // How many full days are between + * // 1 March 2020 0:00 and 1 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 92 days, even in + * // time zones where DST starts and the + * // period has only 92*24-1 hours. + * const result = differenceInDays( + * new Date(2020, 5, 1), + * new Date(2020, 2, 1) + * ) + * //=> 92 + */ +export declare function differenceInDays( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInDaysOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInDays.d.ts b/node_modules/date-fns/differenceInDays.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4dbdc16b52cffc634dda83068d83df0a47eb4769 --- /dev/null +++ b/node_modules/date-fns/differenceInDays.d.ts @@ -0,0 +1,63 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInDays} function options. + */ +export interface DifferenceInDaysOptions extends ContextOptions {} +/** + * @name differenceInDays + * @category Day Helpers + * @summary Get the number of full days between the given dates. + * + * @description + * Get the number of full day periods between two dates. Fractional days are + * truncated towards zero. + * + * One "full day" is the distance between a local time in one day to the same + * local time on the next or previous day. A full day can sometimes be less than + * or more than 24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/24)|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full days according to the local timezone + * + * @example + * // How many full days are between + * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00? + * const result = differenceInDays( + * new Date(2012, 6, 2, 0, 0), + * new Date(2011, 6, 2, 23, 0) + * ) + * //=> 365 + * + * @example + * // How many full days are between + * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00? + * const result = differenceInDays( + * new Date(2011, 6, 3, 0, 1), + * new Date(2011, 6, 2, 23, 59) + * ) + * //=> 0 + * + * @example + * // How many full days are between + * // 1 March 2020 0:00 and 1 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 92 days, even in + * // time zones where DST starts and the + * // period has only 92*24-1 hours. + * const result = differenceInDays( + * new Date(2020, 5, 1), + * new Date(2020, 2, 1) + * ) + * //=> 92 + */ +export declare function differenceInDays( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInDaysOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInDays.js b/node_modules/date-fns/differenceInDays.js new file mode 100644 index 0000000000000000000000000000000000000000..8d2ce6cabb44a3dd6fda26714115c2358d795a4e --- /dev/null +++ b/node_modules/date-fns/differenceInDays.js @@ -0,0 +1,108 @@ +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { differenceInCalendarDays } from "./differenceInCalendarDays.js"; + +/** + * The {@link differenceInDays} function options. + */ + +/** + * @name differenceInDays + * @category Day Helpers + * @summary Get the number of full days between the given dates. + * + * @description + * Get the number of full day periods between two dates. Fractional days are + * truncated towards zero. + * + * One "full day" is the distance between a local time in one day to the same + * local time on the next or previous day. A full day can sometimes be less than + * or more than 24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/24)|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full days according to the local timezone + * + * @example + * // How many full days are between + * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00? + * const result = differenceInDays( + * new Date(2012, 6, 2, 0, 0), + * new Date(2011, 6, 2, 23, 0) + * ) + * //=> 365 + * + * @example + * // How many full days are between + * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00? + * const result = differenceInDays( + * new Date(2011, 6, 3, 0, 1), + * new Date(2011, 6, 2, 23, 59) + * ) + * //=> 0 + * + * @example + * // How many full days are between + * // 1 March 2020 0:00 and 1 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 92 days, even in + * // time zones where DST starts and the + * // period has only 92*24-1 hours. + * const result = differenceInDays( + * new Date(2020, 5, 1), + * new Date(2020, 2, 1) + * ) + * //=> 92 + */ +export function differenceInDays(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + laterDate, + earlierDate, + ); + + const sign = compareLocalAsc(laterDate_, earlierDate_); + const difference = Math.abs( + differenceInCalendarDays(laterDate_, earlierDate_), + ); + + laterDate_.setDate(laterDate_.getDate() - sign * difference); + + // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full + // If so, result must be decreased by 1 in absolute value + const isLastDayNotFull = Number( + compareLocalAsc(laterDate_, earlierDate_) === -sign, + ); + + const result = sign * (difference - isLastDayNotFull); + // Prevent negative zero + return result === 0 ? 0 : result; +} + +// Like `compareAsc` but uses local time not UTC, which is needed +// for accurate equality comparisons of UTC timestamps that end up +// having the same representation in local time, e.g. one hour before +// DST ends vs. the instant that DST ends. +function compareLocalAsc(laterDate, earlierDate) { + const diff = + laterDate.getFullYear() - earlierDate.getFullYear() || + laterDate.getMonth() - earlierDate.getMonth() || + laterDate.getDate() - earlierDate.getDate() || + laterDate.getHours() - earlierDate.getHours() || + laterDate.getMinutes() - earlierDate.getMinutes() || + laterDate.getSeconds() - earlierDate.getSeconds() || + laterDate.getMilliseconds() - earlierDate.getMilliseconds(); + + if (diff < 0) return -1; + if (diff > 0) return 1; + + // Return 0 if diff is 0; return NaN if diff is NaN + return diff; +} + +// Fallback for modularized imports: +export default differenceInDays; diff --git a/node_modules/date-fns/differenceInHours.cjs b/node_modules/date-fns/differenceInHours.cjs new file mode 100644 index 0000000000000000000000000000000000000000..649460dbda342cd28510ca9c9c40f9f6a6413653 --- /dev/null +++ b/node_modules/date-fns/differenceInHours.cjs @@ -0,0 +1,41 @@ +"use strict"; +exports.differenceInHours = differenceInHours; +var _index = require("./_lib/getRoundingMethod.cjs"); +var _index2 = require("./_lib/normalizeDates.cjs"); +var _index3 = require("./constants.cjs"); + +/** + * The {@link differenceInHours} function options. + */ + +/** + * @name differenceInHours + * @category Hour Helpers + * @summary Get the number of hours between the given dates. + * + * @description + * Get the number of hours between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of hours + * + * @example + * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00? + * const result = differenceInHours( + * new Date(2014, 6, 2, 19, 0), + * new Date(2014, 6, 2, 6, 50) + * ) + * //=> 12 + */ +function differenceInHours(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = (0, _index2.normalizeDates)( + options?.in, + laterDate, + earlierDate, + ); + const diff = (+laterDate_ - +earlierDate_) / _index3.millisecondsInHour; + return (0, _index.getRoundingMethod)(options?.roundingMethod)(diff); +} diff --git a/node_modules/date-fns/differenceInHours.d.cts b/node_modules/date-fns/differenceInHours.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..74ff5329d342d286c9e0f435c5b799472f8b132a --- /dev/null +++ b/node_modules/date-fns/differenceInHours.d.cts @@ -0,0 +1,34 @@ +import type { ContextOptions, DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInHours} function options. + */ +export interface DifferenceInHoursOptions + extends RoundingOptions, + ContextOptions {} +/** + * @name differenceInHours + * @category Hour Helpers + * @summary Get the number of hours between the given dates. + * + * @description + * Get the number of hours between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of hours + * + * @example + * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00? + * const result = differenceInHours( + * new Date(2014, 6, 2, 19, 0), + * new Date(2014, 6, 2, 6, 50) + * ) + * //=> 12 + */ +export declare function differenceInHours( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInHoursOptions, +): number; diff --git a/node_modules/date-fns/differenceInHours.d.ts b/node_modules/date-fns/differenceInHours.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74ff5329d342d286c9e0f435c5b799472f8b132a --- /dev/null +++ b/node_modules/date-fns/differenceInHours.d.ts @@ -0,0 +1,34 @@ +import type { ContextOptions, DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInHours} function options. + */ +export interface DifferenceInHoursOptions + extends RoundingOptions, + ContextOptions {} +/** + * @name differenceInHours + * @category Hour Helpers + * @summary Get the number of hours between the given dates. + * + * @description + * Get the number of hours between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of hours + * + * @example + * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00? + * const result = differenceInHours( + * new Date(2014, 6, 2, 19, 0), + * new Date(2014, 6, 2, 6, 50) + * ) + * //=> 12 + */ +export declare function differenceInHours( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInHoursOptions, +): number; diff --git a/node_modules/date-fns/differenceInHours.js b/node_modules/date-fns/differenceInHours.js new file mode 100644 index 0000000000000000000000000000000000000000..e5d85bed74a4033e4b7512db8d9c12cd1f85ec63 --- /dev/null +++ b/node_modules/date-fns/differenceInHours.js @@ -0,0 +1,42 @@ +import { getRoundingMethod } from "./_lib/getRoundingMethod.js"; +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { millisecondsInHour } from "./constants.js"; + +/** + * The {@link differenceInHours} function options. + */ + +/** + * @name differenceInHours + * @category Hour Helpers + * @summary Get the number of hours between the given dates. + * + * @description + * Get the number of hours between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of hours + * + * @example + * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00? + * const result = differenceInHours( + * new Date(2014, 6, 2, 19, 0), + * new Date(2014, 6, 2, 6, 50) + * ) + * //=> 12 + */ +export function differenceInHours(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + laterDate, + earlierDate, + ); + const diff = (+laterDate_ - +earlierDate_) / millisecondsInHour; + return getRoundingMethod(options?.roundingMethod)(diff); +} + +// Fallback for modularized imports: +export default differenceInHours; diff --git a/node_modules/date-fns/differenceInISOWeekYears.cjs b/node_modules/date-fns/differenceInISOWeekYears.cjs new file mode 100644 index 0000000000000000000000000000000000000000..684379b394a8ff70486fada8a9425e57950c5e93 --- /dev/null +++ b/node_modules/date-fns/differenceInISOWeekYears.cjs @@ -0,0 +1,65 @@ +"use strict"; +exports.differenceInISOWeekYears = differenceInISOWeekYears; +var _index = require("./_lib/normalizeDates.cjs"); +var _index2 = require("./compareAsc.cjs"); +var _index3 = require("./differenceInCalendarISOWeekYears.cjs"); +var _index4 = require("./subISOWeekYears.cjs"); + +/** + * The {@link differenceInISOWeekYears} function options. + */ + +/** + * @name differenceInISOWeekYears + * @category ISO Week-Numbering Year Helpers + * @summary Get the number of full ISO week-numbering years between the given dates. + * + * @description + * Get the number of full ISO week-numbering years between the given dates. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - The options + * + * @returns The number of full ISO week-numbering years + * + * @example + * // How many full ISO week-numbering years are between 1 January 2010 and 1 January 2012? + * const result = differenceInISOWeekYears( + * new Date(2012, 0, 1), + * new Date(2010, 0, 1) + * ) + * // => 1 + */ +function differenceInISOWeekYears(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = (0, _index.normalizeDates)( + options?.in, + laterDate, + earlierDate, + ); + + const sign = (0, _index2.compareAsc)(laterDate_, earlierDate_); + const diff = Math.abs( + (0, _index3.differenceInCalendarISOWeekYears)( + laterDate_, + earlierDate_, + options, + ), + ); + + const adjustedDate = (0, _index4.subISOWeekYears)( + laterDate_, + sign * diff, + options, + ); + + const isLastISOWeekYearNotFull = Number( + (0, _index2.compareAsc)(adjustedDate, earlierDate_) === -sign, + ); + const result = sign * (diff - isLastISOWeekYearNotFull); + + // Prevent negative zero + return result === 0 ? 0 : result; +} diff --git a/node_modules/date-fns/differenceInISOWeekYears.d.cts b/node_modules/date-fns/differenceInISOWeekYears.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..21c4edc468a7a90ec6d0f91872bf693424315e7b --- /dev/null +++ b/node_modules/date-fns/differenceInISOWeekYears.d.cts @@ -0,0 +1,34 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInISOWeekYears} function options. + */ +export interface DifferenceInISOWeekYearsOptions extends ContextOptions {} +/** + * @name differenceInISOWeekYears + * @category ISO Week-Numbering Year Helpers + * @summary Get the number of full ISO week-numbering years between the given dates. + * + * @description + * Get the number of full ISO week-numbering years between the given dates. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - The options + * + * @returns The number of full ISO week-numbering years + * + * @example + * // How many full ISO week-numbering years are between 1 January 2010 and 1 January 2012? + * const result = differenceInISOWeekYears( + * new Date(2012, 0, 1), + * new Date(2010, 0, 1) + * ) + * // => 1 + */ +export declare function differenceInISOWeekYears( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInISOWeekYearsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInISOWeekYears.d.ts b/node_modules/date-fns/differenceInISOWeekYears.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..21c4edc468a7a90ec6d0f91872bf693424315e7b --- /dev/null +++ b/node_modules/date-fns/differenceInISOWeekYears.d.ts @@ -0,0 +1,34 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInISOWeekYears} function options. + */ +export interface DifferenceInISOWeekYearsOptions extends ContextOptions {} +/** + * @name differenceInISOWeekYears + * @category ISO Week-Numbering Year Helpers + * @summary Get the number of full ISO week-numbering years between the given dates. + * + * @description + * Get the number of full ISO week-numbering years between the given dates. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - The options + * + * @returns The number of full ISO week-numbering years + * + * @example + * // How many full ISO week-numbering years are between 1 January 2010 and 1 January 2012? + * const result = differenceInISOWeekYears( + * new Date(2012, 0, 1), + * new Date(2010, 0, 1) + * ) + * // => 1 + */ +export declare function differenceInISOWeekYears( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInISOWeekYearsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInISOWeekYears.js b/node_modules/date-fns/differenceInISOWeekYears.js new file mode 100644 index 0000000000000000000000000000000000000000..bf9e371d4ffda83cd3bc2b47674f14608dbe1f5e --- /dev/null +++ b/node_modules/date-fns/differenceInISOWeekYears.js @@ -0,0 +1,58 @@ +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { compareAsc } from "./compareAsc.js"; +import { differenceInCalendarISOWeekYears } from "./differenceInCalendarISOWeekYears.js"; +import { subISOWeekYears } from "./subISOWeekYears.js"; + +/** + * The {@link differenceInISOWeekYears} function options. + */ + +/** + * @name differenceInISOWeekYears + * @category ISO Week-Numbering Year Helpers + * @summary Get the number of full ISO week-numbering years between the given dates. + * + * @description + * Get the number of full ISO week-numbering years between the given dates. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - The options + * + * @returns The number of full ISO week-numbering years + * + * @example + * // How many full ISO week-numbering years are between 1 January 2010 and 1 January 2012? + * const result = differenceInISOWeekYears( + * new Date(2012, 0, 1), + * new Date(2010, 0, 1) + * ) + * // => 1 + */ +export function differenceInISOWeekYears(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + laterDate, + earlierDate, + ); + + const sign = compareAsc(laterDate_, earlierDate_); + const diff = Math.abs( + differenceInCalendarISOWeekYears(laterDate_, earlierDate_, options), + ); + + const adjustedDate = subISOWeekYears(laterDate_, sign * diff, options); + + const isLastISOWeekYearNotFull = Number( + compareAsc(adjustedDate, earlierDate_) === -sign, + ); + const result = sign * (diff - isLastISOWeekYearNotFull); + + // Prevent negative zero + return result === 0 ? 0 : result; +} + +// Fallback for modularized imports: +export default differenceInISOWeekYears; diff --git a/node_modules/date-fns/differenceInMilliseconds.cjs b/node_modules/date-fns/differenceInMilliseconds.cjs new file mode 100644 index 0000000000000000000000000000000000000000..665e04ef8e5487603bd6bf58d1f8f343747a39af --- /dev/null +++ b/node_modules/date-fns/differenceInMilliseconds.cjs @@ -0,0 +1,29 @@ +"use strict"; +exports.differenceInMilliseconds = differenceInMilliseconds; +var _index = require("./toDate.cjs"); + +/** + * @name differenceInMilliseconds + * @category Millisecond Helpers + * @summary Get the number of milliseconds between the given dates. + * + * @description + * Get the number of milliseconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * + * @returns The number of milliseconds + * + * @example + * // How many milliseconds are between + * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700? + * const result = differenceInMilliseconds( + * new Date(2014, 6, 2, 12, 30, 21, 700), + * new Date(2014, 6, 2, 12, 30, 20, 600) + * ) + * //=> 1100 + */ +function differenceInMilliseconds(laterDate, earlierDate) { + return +(0, _index.toDate)(laterDate) - +(0, _index.toDate)(earlierDate); +} diff --git a/node_modules/date-fns/differenceInMilliseconds.d.cts b/node_modules/date-fns/differenceInMilliseconds.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..3e1abc50ffb0efd082fbc9bd49e5f5ee2d24085c --- /dev/null +++ b/node_modules/date-fns/differenceInMilliseconds.d.cts @@ -0,0 +1,27 @@ +import type { DateArg } from "./types.ts"; +/** + * @name differenceInMilliseconds + * @category Millisecond Helpers + * @summary Get the number of milliseconds between the given dates. + * + * @description + * Get the number of milliseconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * + * @returns The number of milliseconds + * + * @example + * // How many milliseconds are between + * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700? + * const result = differenceInMilliseconds( + * new Date(2014, 6, 2, 12, 30, 21, 700), + * new Date(2014, 6, 2, 12, 30, 20, 600) + * ) + * //=> 1100 + */ +export declare function differenceInMilliseconds( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, +): number; diff --git a/node_modules/date-fns/differenceInMilliseconds.d.ts b/node_modules/date-fns/differenceInMilliseconds.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e1abc50ffb0efd082fbc9bd49e5f5ee2d24085c --- /dev/null +++ b/node_modules/date-fns/differenceInMilliseconds.d.ts @@ -0,0 +1,27 @@ +import type { DateArg } from "./types.ts"; +/** + * @name differenceInMilliseconds + * @category Millisecond Helpers + * @summary Get the number of milliseconds between the given dates. + * + * @description + * Get the number of milliseconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * + * @returns The number of milliseconds + * + * @example + * // How many milliseconds are between + * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700? + * const result = differenceInMilliseconds( + * new Date(2014, 6, 2, 12, 30, 21, 700), + * new Date(2014, 6, 2, 12, 30, 20, 600) + * ) + * //=> 1100 + */ +export declare function differenceInMilliseconds( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, +): number; diff --git a/node_modules/date-fns/differenceInMilliseconds.js b/node_modules/date-fns/differenceInMilliseconds.js new file mode 100644 index 0000000000000000000000000000000000000000..377f008836d24710696f5035d3dd023a24c201a6 --- /dev/null +++ b/node_modules/date-fns/differenceInMilliseconds.js @@ -0,0 +1,30 @@ +import { toDate } from "./toDate.js"; + +/** + * @name differenceInMilliseconds + * @category Millisecond Helpers + * @summary Get the number of milliseconds between the given dates. + * + * @description + * Get the number of milliseconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * + * @returns The number of milliseconds + * + * @example + * // How many milliseconds are between + * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700? + * const result = differenceInMilliseconds( + * new Date(2014, 6, 2, 12, 30, 21, 700), + * new Date(2014, 6, 2, 12, 30, 20, 600) + * ) + * //=> 1100 + */ +export function differenceInMilliseconds(laterDate, earlierDate) { + return +toDate(laterDate) - +toDate(earlierDate); +} + +// Fallback for modularized imports: +export default differenceInMilliseconds; diff --git a/node_modules/date-fns/differenceInMinutes.cjs b/node_modules/date-fns/differenceInMinutes.cjs new file mode 100644 index 0000000000000000000000000000000000000000..488fc4f1876fba5fa85f18827ee1b0792545c97d --- /dev/null +++ b/node_modules/date-fns/differenceInMinutes.cjs @@ -0,0 +1,46 @@ +"use strict"; +exports.differenceInMinutes = differenceInMinutes; +var _index = require("./_lib/getRoundingMethod.cjs"); +var _index2 = require("./constants.cjs"); +var _index3 = require("./differenceInMilliseconds.cjs"); + +/** + * The {@link differenceInMinutes} function options. + */ + +/** + * @name differenceInMinutes + * @category Minute Helpers + * @summary Get the number of minutes between the given dates. + * + * @description + * Get the signed number of full (rounded towards 0) minutes between the given dates. + * + * @param dateLeft - The later date + * @param dateRight - The earlier date + * @param options - An object with options. + * + * @returns The number of minutes + * + * @example + * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00? + * const result = differenceInMinutes( + * new Date(2014, 6, 2, 12, 20, 0), + * new Date(2014, 6, 2, 12, 7, 59) + * ) + * //=> 12 + * + * @example + * // How many minutes are between 10:01:59 and 10:00:00 + * const result = differenceInMinutes( + * new Date(2000, 0, 1, 10, 0, 0), + * new Date(2000, 0, 1, 10, 1, 59) + * ) + * //=> -1 + */ +function differenceInMinutes(dateLeft, dateRight, options) { + const diff = + (0, _index3.differenceInMilliseconds)(dateLeft, dateRight) / + _index2.millisecondsInMinute; + return (0, _index.getRoundingMethod)(options?.roundingMethod)(diff); +} diff --git a/node_modules/date-fns/differenceInMinutes.d.cts b/node_modules/date-fns/differenceInMinutes.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..ebbf34c88f5b69e225dc0404230d90ecc80c6298 --- /dev/null +++ b/node_modules/date-fns/differenceInMinutes.d.cts @@ -0,0 +1,40 @@ +import type { DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInMinutes} function options. + */ +export interface DifferenceInMinutesOptions extends RoundingOptions {} +/** + * @name differenceInMinutes + * @category Minute Helpers + * @summary Get the number of minutes between the given dates. + * + * @description + * Get the signed number of full (rounded towards 0) minutes between the given dates. + * + * @param dateLeft - The later date + * @param dateRight - The earlier date + * @param options - An object with options. + * + * @returns The number of minutes + * + * @example + * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00? + * const result = differenceInMinutes( + * new Date(2014, 6, 2, 12, 20, 0), + * new Date(2014, 6, 2, 12, 7, 59) + * ) + * //=> 12 + * + * @example + * // How many minutes are between 10:01:59 and 10:00:00 + * const result = differenceInMinutes( + * new Date(2000, 0, 1, 10, 0, 0), + * new Date(2000, 0, 1, 10, 1, 59) + * ) + * //=> -1 + */ +export declare function differenceInMinutes( + dateLeft: DateArg & {}, + dateRight: DateArg & {}, + options?: DifferenceInMinutesOptions, +): number; diff --git a/node_modules/date-fns/differenceInMinutes.d.ts b/node_modules/date-fns/differenceInMinutes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebbf34c88f5b69e225dc0404230d90ecc80c6298 --- /dev/null +++ b/node_modules/date-fns/differenceInMinutes.d.ts @@ -0,0 +1,40 @@ +import type { DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInMinutes} function options. + */ +export interface DifferenceInMinutesOptions extends RoundingOptions {} +/** + * @name differenceInMinutes + * @category Minute Helpers + * @summary Get the number of minutes between the given dates. + * + * @description + * Get the signed number of full (rounded towards 0) minutes between the given dates. + * + * @param dateLeft - The later date + * @param dateRight - The earlier date + * @param options - An object with options. + * + * @returns The number of minutes + * + * @example + * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00? + * const result = differenceInMinutes( + * new Date(2014, 6, 2, 12, 20, 0), + * new Date(2014, 6, 2, 12, 7, 59) + * ) + * //=> 12 + * + * @example + * // How many minutes are between 10:01:59 and 10:00:00 + * const result = differenceInMinutes( + * new Date(2000, 0, 1, 10, 0, 0), + * new Date(2000, 0, 1, 10, 1, 59) + * ) + * //=> -1 + */ +export declare function differenceInMinutes( + dateLeft: DateArg & {}, + dateRight: DateArg & {}, + options?: DifferenceInMinutesOptions, +): number; diff --git a/node_modules/date-fns/differenceInMinutes.js b/node_modules/date-fns/differenceInMinutes.js new file mode 100644 index 0000000000000000000000000000000000000000..b97f06c79a7f4df54689bed0d366caae64715e91 --- /dev/null +++ b/node_modules/date-fns/differenceInMinutes.js @@ -0,0 +1,46 @@ +import { getRoundingMethod } from "./_lib/getRoundingMethod.js"; +import { millisecondsInMinute } from "./constants.js"; +import { differenceInMilliseconds } from "./differenceInMilliseconds.js"; + +/** + * The {@link differenceInMinutes} function options. + */ + +/** + * @name differenceInMinutes + * @category Minute Helpers + * @summary Get the number of minutes between the given dates. + * + * @description + * Get the signed number of full (rounded towards 0) minutes between the given dates. + * + * @param dateLeft - The later date + * @param dateRight - The earlier date + * @param options - An object with options. + * + * @returns The number of minutes + * + * @example + * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00? + * const result = differenceInMinutes( + * new Date(2014, 6, 2, 12, 20, 0), + * new Date(2014, 6, 2, 12, 7, 59) + * ) + * //=> 12 + * + * @example + * // How many minutes are between 10:01:59 and 10:00:00 + * const result = differenceInMinutes( + * new Date(2000, 0, 1, 10, 0, 0), + * new Date(2000, 0, 1, 10, 1, 59) + * ) + * //=> -1 + */ +export function differenceInMinutes(dateLeft, dateRight, options) { + const diff = + differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute; + return getRoundingMethod(options?.roundingMethod)(diff); +} + +// Fallback for modularized imports: +export default differenceInMinutes; diff --git a/node_modules/date-fns/differenceInMonths.cjs b/node_modules/date-fns/differenceInMonths.cjs new file mode 100644 index 0000000000000000000000000000000000000000..bcf10304409b6974ee912b6d3d6bb1deae7c647c --- /dev/null +++ b/node_modules/date-fns/differenceInMonths.cjs @@ -0,0 +1,57 @@ +"use strict"; +exports.differenceInMonths = differenceInMonths; +var _index = require("./_lib/normalizeDates.cjs"); +var _index2 = require("./compareAsc.cjs"); +var _index3 = require("./differenceInCalendarMonths.cjs"); +var _index4 = require("./isLastDayOfMonth.cjs"); + +/** + * The {@link differenceInMonths} function options. + */ + +/** + * @name differenceInMonths + * @category Month Helpers + * @summary Get the number of full months between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full months + * + * @example + * // How many full months are between 31 January 2014 and 1 September 2014? + * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31)) + * //=> 7 + */ +function differenceInMonths(laterDate, earlierDate, options) { + const [laterDate_, workingLaterDate, earlierDate_] = (0, + _index.normalizeDates)(options?.in, laterDate, laterDate, earlierDate); + + const sign = (0, _index2.compareAsc)(workingLaterDate, earlierDate_); + const difference = Math.abs( + (0, _index3.differenceInCalendarMonths)(workingLaterDate, earlierDate_), + ); + + if (difference < 1) return 0; + + if (workingLaterDate.getMonth() === 1 && workingLaterDate.getDate() > 27) + workingLaterDate.setDate(30); + + workingLaterDate.setMonth(workingLaterDate.getMonth() - sign * difference); + + let isLastMonthNotFull = + (0, _index2.compareAsc)(workingLaterDate, earlierDate_) === -sign; + + if ( + (0, _index4.isLastDayOfMonth)(laterDate_) && + difference === 1 && + (0, _index2.compareAsc)(laterDate_, earlierDate_) === 1 + ) { + isLastMonthNotFull = false; + } + + const result = sign * (difference - +isLastMonthNotFull); + return result === 0 ? 0 : result; +} diff --git a/node_modules/date-fns/differenceInMonths.d.cts b/node_modules/date-fns/differenceInMonths.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..6396b8c2f500852628f1dca63825b9f53766effa --- /dev/null +++ b/node_modules/date-fns/differenceInMonths.d.cts @@ -0,0 +1,26 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInMonths} function options. + */ +export interface DifferenceInMonthsOptions extends ContextOptions {} +/** + * @name differenceInMonths + * @category Month Helpers + * @summary Get the number of full months between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full months + * + * @example + * // How many full months are between 31 January 2014 and 1 September 2014? + * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31)) + * //=> 7 + */ +export declare function differenceInMonths( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInMonthsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInMonths.d.ts b/node_modules/date-fns/differenceInMonths.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6396b8c2f500852628f1dca63825b9f53766effa --- /dev/null +++ b/node_modules/date-fns/differenceInMonths.d.ts @@ -0,0 +1,26 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInMonths} function options. + */ +export interface DifferenceInMonthsOptions extends ContextOptions {} +/** + * @name differenceInMonths + * @category Month Helpers + * @summary Get the number of full months between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full months + * + * @example + * // How many full months are between 31 January 2014 and 1 September 2014? + * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31)) + * //=> 7 + */ +export declare function differenceInMonths( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInMonthsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInMonths.js b/node_modules/date-fns/differenceInMonths.js new file mode 100644 index 0000000000000000000000000000000000000000..c65928b2827f65237af38c0a6cca48caac5c5e8f --- /dev/null +++ b/node_modules/date-fns/differenceInMonths.js @@ -0,0 +1,61 @@ +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { compareAsc } from "./compareAsc.js"; +import { differenceInCalendarMonths } from "./differenceInCalendarMonths.js"; +import { isLastDayOfMonth } from "./isLastDayOfMonth.js"; + +/** + * The {@link differenceInMonths} function options. + */ + +/** + * @name differenceInMonths + * @category Month Helpers + * @summary Get the number of full months between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full months + * + * @example + * // How many full months are between 31 January 2014 and 1 September 2014? + * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31)) + * //=> 7 + */ +export function differenceInMonths(laterDate, earlierDate, options) { + const [laterDate_, workingLaterDate, earlierDate_] = normalizeDates( + options?.in, + laterDate, + laterDate, + earlierDate, + ); + + const sign = compareAsc(workingLaterDate, earlierDate_); + const difference = Math.abs( + differenceInCalendarMonths(workingLaterDate, earlierDate_), + ); + + if (difference < 1) return 0; + + if (workingLaterDate.getMonth() === 1 && workingLaterDate.getDate() > 27) + workingLaterDate.setDate(30); + + workingLaterDate.setMonth(workingLaterDate.getMonth() - sign * difference); + + let isLastMonthNotFull = compareAsc(workingLaterDate, earlierDate_) === -sign; + + if ( + isLastDayOfMonth(laterDate_) && + difference === 1 && + compareAsc(laterDate_, earlierDate_) === 1 + ) { + isLastMonthNotFull = false; + } + + const result = sign * (difference - +isLastMonthNotFull); + return result === 0 ? 0 : result; +} + +// Fallback for modularized imports: +export default differenceInMonths; diff --git a/node_modules/date-fns/differenceInQuarters.cjs b/node_modules/date-fns/differenceInQuarters.cjs new file mode 100644 index 0000000000000000000000000000000000000000..1e25db4d787e06b6be60ee418edf912a8172360e --- /dev/null +++ b/node_modules/date-fns/differenceInQuarters.cjs @@ -0,0 +1,33 @@ +"use strict"; +exports.differenceInQuarters = differenceInQuarters; +var _index = require("./_lib/getRoundingMethod.cjs"); +var _index2 = require("./differenceInMonths.cjs"); + +/** + * The {@link differenceInQuarters} function options. + */ + +/** + * @name differenceInQuarters + * @category Quarter Helpers + * @summary Get the number of quarters between the given dates. + * + * @description + * Get the number of quarters between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of full quarters + * + * @example + * // How many full quarters are between 31 December 2013 and 2 July 2014? + * const result = differenceInQuarters(new Date(2014, 6, 2), new Date(2013, 11, 31)) + * //=> 2 + */ +function differenceInQuarters(laterDate, earlierDate, options) { + const diff = + (0, _index2.differenceInMonths)(laterDate, earlierDate, options) / 3; + return (0, _index.getRoundingMethod)(options?.roundingMethod)(diff); +} diff --git a/node_modules/date-fns/differenceInQuarters.d.cts b/node_modules/date-fns/differenceInQuarters.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..82b7f7d0b49d453297168f5064acf3c8f6e636a6 --- /dev/null +++ b/node_modules/date-fns/differenceInQuarters.d.cts @@ -0,0 +1,31 @@ +import type { ContextOptions, DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInQuarters} function options. + */ +export interface DifferenceInQuartersOptions + extends RoundingOptions, + ContextOptions {} +/** + * @name differenceInQuarters + * @category Quarter Helpers + * @summary Get the number of quarters between the given dates. + * + * @description + * Get the number of quarters between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of full quarters + * + * @example + * // How many full quarters are between 31 December 2013 and 2 July 2014? + * const result = differenceInQuarters(new Date(2014, 6, 2), new Date(2013, 11, 31)) + * //=> 2 + */ +export declare function differenceInQuarters( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInQuartersOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInQuarters.d.ts b/node_modules/date-fns/differenceInQuarters.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..82b7f7d0b49d453297168f5064acf3c8f6e636a6 --- /dev/null +++ b/node_modules/date-fns/differenceInQuarters.d.ts @@ -0,0 +1,31 @@ +import type { ContextOptions, DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInQuarters} function options. + */ +export interface DifferenceInQuartersOptions + extends RoundingOptions, + ContextOptions {} +/** + * @name differenceInQuarters + * @category Quarter Helpers + * @summary Get the number of quarters between the given dates. + * + * @description + * Get the number of quarters between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of full quarters + * + * @example + * // How many full quarters are between 31 December 2013 and 2 July 2014? + * const result = differenceInQuarters(new Date(2014, 6, 2), new Date(2013, 11, 31)) + * //=> 2 + */ +export declare function differenceInQuarters( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInQuartersOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInQuarters.js b/node_modules/date-fns/differenceInQuarters.js new file mode 100644 index 0000000000000000000000000000000000000000..b91f385e6b19219bc0d188ca24b1bf4aa1f503cb --- /dev/null +++ b/node_modules/date-fns/differenceInQuarters.js @@ -0,0 +1,33 @@ +import { getRoundingMethod } from "./_lib/getRoundingMethod.js"; +import { differenceInMonths } from "./differenceInMonths.js"; + +/** + * The {@link differenceInQuarters} function options. + */ + +/** + * @name differenceInQuarters + * @category Quarter Helpers + * @summary Get the number of quarters between the given dates. + * + * @description + * Get the number of quarters between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of full quarters + * + * @example + * // How many full quarters are between 31 December 2013 and 2 July 2014? + * const result = differenceInQuarters(new Date(2014, 6, 2), new Date(2013, 11, 31)) + * //=> 2 + */ +export function differenceInQuarters(laterDate, earlierDate, options) { + const diff = differenceInMonths(laterDate, earlierDate, options) / 3; + return getRoundingMethod(options?.roundingMethod)(diff); +} + +// Fallback for modularized imports: +export default differenceInQuarters; diff --git a/node_modules/date-fns/differenceInSeconds.cjs b/node_modules/date-fns/differenceInSeconds.cjs new file mode 100644 index 0000000000000000000000000000000000000000..60c6e70ffe7256e81febbd34b47dc6e3aec580cb --- /dev/null +++ b/node_modules/date-fns/differenceInSeconds.cjs @@ -0,0 +1,37 @@ +"use strict"; +exports.differenceInSeconds = differenceInSeconds; +var _index = require("./_lib/getRoundingMethod.cjs"); +var _index2 = require("./differenceInMilliseconds.cjs"); + +/** + * The {@link differenceInSeconds} function options. + */ + +/** + * @name differenceInSeconds + * @category Second Helpers + * @summary Get the number of seconds between the given dates. + * + * @description + * Get the number of seconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of seconds + * + * @example + * // How many seconds are between + * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000? + * const result = differenceInSeconds( + * new Date(2014, 6, 2, 12, 30, 20, 0), + * new Date(2014, 6, 2, 12, 30, 7, 999) + * ) + * //=> 12 + */ +function differenceInSeconds(laterDate, earlierDate, options) { + const diff = + (0, _index2.differenceInMilliseconds)(laterDate, earlierDate) / 1000; + return (0, _index.getRoundingMethod)(options?.roundingMethod)(diff); +} diff --git a/node_modules/date-fns/differenceInSeconds.d.cts b/node_modules/date-fns/differenceInSeconds.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..f1c8b4ce69bf46748fec870aff8e2c15ac8a10ec --- /dev/null +++ b/node_modules/date-fns/differenceInSeconds.d.cts @@ -0,0 +1,33 @@ +import type { DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInSeconds} function options. + */ +export interface DifferenceInSecondsOptions extends RoundingOptions {} +/** + * @name differenceInSeconds + * @category Second Helpers + * @summary Get the number of seconds between the given dates. + * + * @description + * Get the number of seconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of seconds + * + * @example + * // How many seconds are between + * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000? + * const result = differenceInSeconds( + * new Date(2014, 6, 2, 12, 30, 20, 0), + * new Date(2014, 6, 2, 12, 30, 7, 999) + * ) + * //=> 12 + */ +export declare function differenceInSeconds( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInSecondsOptions, +): number; diff --git a/node_modules/date-fns/differenceInSeconds.d.ts b/node_modules/date-fns/differenceInSeconds.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1c8b4ce69bf46748fec870aff8e2c15ac8a10ec --- /dev/null +++ b/node_modules/date-fns/differenceInSeconds.d.ts @@ -0,0 +1,33 @@ +import type { DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInSeconds} function options. + */ +export interface DifferenceInSecondsOptions extends RoundingOptions {} +/** + * @name differenceInSeconds + * @category Second Helpers + * @summary Get the number of seconds between the given dates. + * + * @description + * Get the number of seconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of seconds + * + * @example + * // How many seconds are between + * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000? + * const result = differenceInSeconds( + * new Date(2014, 6, 2, 12, 30, 20, 0), + * new Date(2014, 6, 2, 12, 30, 7, 999) + * ) + * //=> 12 + */ +export declare function differenceInSeconds( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInSecondsOptions, +): number; diff --git a/node_modules/date-fns/differenceInSeconds.js b/node_modules/date-fns/differenceInSeconds.js new file mode 100644 index 0000000000000000000000000000000000000000..dd506d155fe6bb5ee6ec412187954d64fa994bef --- /dev/null +++ b/node_modules/date-fns/differenceInSeconds.js @@ -0,0 +1,37 @@ +import { getRoundingMethod } from "./_lib/getRoundingMethod.js"; +import { differenceInMilliseconds } from "./differenceInMilliseconds.js"; + +/** + * The {@link differenceInSeconds} function options. + */ + +/** + * @name differenceInSeconds + * @category Second Helpers + * @summary Get the number of seconds between the given dates. + * + * @description + * Get the number of seconds between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options. + * + * @returns The number of seconds + * + * @example + * // How many seconds are between + * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000? + * const result = differenceInSeconds( + * new Date(2014, 6, 2, 12, 30, 20, 0), + * new Date(2014, 6, 2, 12, 30, 7, 999) + * ) + * //=> 12 + */ +export function differenceInSeconds(laterDate, earlierDate, options) { + const diff = differenceInMilliseconds(laterDate, earlierDate) / 1000; + return getRoundingMethod(options?.roundingMethod)(diff); +} + +// Fallback for modularized imports: +export default differenceInSeconds; diff --git a/node_modules/date-fns/differenceInWeeks.cjs b/node_modules/date-fns/differenceInWeeks.cjs new file mode 100644 index 0000000000000000000000000000000000000000..ed39308eae22faaeb158d8f698c7082d0b707300 --- /dev/null +++ b/node_modules/date-fns/differenceInWeeks.cjs @@ -0,0 +1,54 @@ +"use strict"; +exports.differenceInWeeks = differenceInWeeks; +var _index = require("./_lib/getRoundingMethod.cjs"); +var _index2 = require("./differenceInDays.cjs"); + +/** + * The {@link differenceInWeeks} function options. + */ + +/** + * @name differenceInWeeks + * @category Week Helpers + * @summary Get the number of full weeks between the given dates. + * + * @description + * Get the number of full weeks between two dates. Fractional weeks are + * truncated towards zero by default. + * + * One "full week" is the distance between a local time in one day to the same + * local time 7 days earlier or later. A full week can sometimes be less than + * or more than 7*24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 7*24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/(7*24))|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full weeks + * + * @example + * // How many full weeks are between 5 July 2014 and 20 July 2014? + * const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5)) + * //=> 2 + * + * @example + * // How many full weeks are between + * // 1 March 2020 0:00 and 6 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 8 weeks (54 days), + * // even if DST starts and the period has + * // only 54*24-1 hours. + * const result = differenceInWeeks( + * new Date(2020, 5, 1), + * new Date(2020, 2, 6) + * ) + * //=> 8 + */ +function differenceInWeeks(laterDate, earlierDate, options) { + const diff = + (0, _index2.differenceInDays)(laterDate, earlierDate, options) / 7; + return (0, _index.getRoundingMethod)(options?.roundingMethod)(diff); +} diff --git a/node_modules/date-fns/differenceInWeeks.d.cts b/node_modules/date-fns/differenceInWeeks.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..625d7521249afb4d2873fb2d0e343a8d484e0063 --- /dev/null +++ b/node_modules/date-fns/differenceInWeeks.d.cts @@ -0,0 +1,52 @@ +import type { ContextOptions, DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInWeeks} function options. + */ +export interface DifferenceInWeeksOptions + extends RoundingOptions, + ContextOptions {} +/** + * @name differenceInWeeks + * @category Week Helpers + * @summary Get the number of full weeks between the given dates. + * + * @description + * Get the number of full weeks between two dates. Fractional weeks are + * truncated towards zero by default. + * + * One "full week" is the distance between a local time in one day to the same + * local time 7 days earlier or later. A full week can sometimes be less than + * or more than 7*24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 7*24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/(7*24))|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full weeks + * + * @example + * // How many full weeks are between 5 July 2014 and 20 July 2014? + * const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5)) + * //=> 2 + * + * @example + * // How many full weeks are between + * // 1 March 2020 0:00 and 6 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 8 weeks (54 days), + * // even if DST starts and the period has + * // only 54*24-1 hours. + * const result = differenceInWeeks( + * new Date(2020, 5, 1), + * new Date(2020, 2, 6) + * ) + * //=> 8 + */ +export declare function differenceInWeeks( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInWeeksOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInWeeks.d.ts b/node_modules/date-fns/differenceInWeeks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..625d7521249afb4d2873fb2d0e343a8d484e0063 --- /dev/null +++ b/node_modules/date-fns/differenceInWeeks.d.ts @@ -0,0 +1,52 @@ +import type { ContextOptions, DateArg, RoundingOptions } from "./types.ts"; +/** + * The {@link differenceInWeeks} function options. + */ +export interface DifferenceInWeeksOptions + extends RoundingOptions, + ContextOptions {} +/** + * @name differenceInWeeks + * @category Week Helpers + * @summary Get the number of full weeks between the given dates. + * + * @description + * Get the number of full weeks between two dates. Fractional weeks are + * truncated towards zero by default. + * + * One "full week" is the distance between a local time in one day to the same + * local time 7 days earlier or later. A full week can sometimes be less than + * or more than 7*24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 7*24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/(7*24))|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full weeks + * + * @example + * // How many full weeks are between 5 July 2014 and 20 July 2014? + * const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5)) + * //=> 2 + * + * @example + * // How many full weeks are between + * // 1 March 2020 0:00 and 6 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 8 weeks (54 days), + * // even if DST starts and the period has + * // only 54*24-1 hours. + * const result = differenceInWeeks( + * new Date(2020, 5, 1), + * new Date(2020, 2, 6) + * ) + * //=> 8 + */ +export declare function differenceInWeeks( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInWeeksOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInWeeks.js b/node_modules/date-fns/differenceInWeeks.js new file mode 100644 index 0000000000000000000000000000000000000000..cbab4ca248a3ed4d00bb3739ec0e77899b5cb01b --- /dev/null +++ b/node_modules/date-fns/differenceInWeeks.js @@ -0,0 +1,54 @@ +import { getRoundingMethod } from "./_lib/getRoundingMethod.js"; +import { differenceInDays } from "./differenceInDays.js"; + +/** + * The {@link differenceInWeeks} function options. + */ + +/** + * @name differenceInWeeks + * @category Week Helpers + * @summary Get the number of full weeks between the given dates. + * + * @description + * Get the number of full weeks between two dates. Fractional weeks are + * truncated towards zero by default. + * + * One "full week" is the distance between a local time in one day to the same + * local time 7 days earlier or later. A full week can sometimes be less than + * or more than 7*24 hours if a daylight savings change happens between two dates. + * + * To ignore DST and only measure exact 7*24-hour periods, use this instead: + * `Math.trunc(differenceInHours(dateLeft, dateRight)/(7*24))|0`. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full weeks + * + * @example + * // How many full weeks are between 5 July 2014 and 20 July 2014? + * const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5)) + * //=> 2 + * + * @example + * // How many full weeks are between + * // 1 March 2020 0:00 and 6 June 2020 0:00 ? + * // Note: because local time is used, the + * // result will always be 8 weeks (54 days), + * // even if DST starts and the period has + * // only 54*24-1 hours. + * const result = differenceInWeeks( + * new Date(2020, 5, 1), + * new Date(2020, 2, 6) + * ) + * //=> 8 + */ +export function differenceInWeeks(laterDate, earlierDate, options) { + const diff = differenceInDays(laterDate, earlierDate, options) / 7; + return getRoundingMethod(options?.roundingMethod)(diff); +} + +// Fallback for modularized imports: +export default differenceInWeeks; diff --git a/node_modules/date-fns/differenceInYears.cjs b/node_modules/date-fns/differenceInYears.cjs new file mode 100644 index 0000000000000000000000000000000000000000..256bac6063eab54f5fc77f6d2355742bebe6e2df --- /dev/null +++ b/node_modules/date-fns/differenceInYears.cjs @@ -0,0 +1,64 @@ +"use strict"; +exports.differenceInYears = differenceInYears; +var _index = require("./_lib/normalizeDates.cjs"); +var _index2 = require("./compareAsc.cjs"); +var _index3 = require("./differenceInCalendarYears.cjs"); + +/** + * The {@link differenceInYears} function options. + */ + +/** + * @name differenceInYears + * @category Year Helpers + * @summary Get the number of full years between the given dates. + * + * @description + * Get the number of full years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full years + * + * @example + * // How many full years are between 31 December 2013 and 11 February 2015? + * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31)) + * //=> 1 + */ +function differenceInYears(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = (0, _index.normalizeDates)( + options?.in, + laterDate, + earlierDate, + ); + + // -1 if the left date is earlier than the right date + // 2023-12-31 - 2024-01-01 = -1 + const sign = (0, _index2.compareAsc)(laterDate_, earlierDate_); + + // First calculate the difference in calendar years + // 2024-01-01 - 2023-12-31 = 1 year + const diff = Math.abs( + (0, _index3.differenceInCalendarYears)(laterDate_, earlierDate_), + ); + + // Now we need to calculate if the difference is full. To do that we set + // both dates to the same year and check if the both date's month and day + // form a full year. + laterDate_.setFullYear(1584); + earlierDate_.setFullYear(1584); + + // For it to be true, when the later date is indeed later than the earlier date + // (2026-02-01 - 2023-12-10 = 3 years), the difference is full if + // the normalized later date is also later than the normalized earlier date. + // In our example, 1584-02-01 is earlier than 1584-12-10, so the difference + // is partial, hence we need to subtract 1 from the difference 3 - 1 = 2. + const partial = (0, _index2.compareAsc)(laterDate_, earlierDate_) === -sign; + + const result = sign * (diff - +partial); + + // Prevent negative zero + return result === 0 ? 0 : result; +} diff --git a/node_modules/date-fns/differenceInYears.d.cts b/node_modules/date-fns/differenceInYears.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..9bd6cfe21cb8cfa39b5b341ba9eaf6717cbf82b3 --- /dev/null +++ b/node_modules/date-fns/differenceInYears.d.cts @@ -0,0 +1,29 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInYears} function options. + */ +export interface DifferenceInYearsOptions extends ContextOptions {} +/** + * @name differenceInYears + * @category Year Helpers + * @summary Get the number of full years between the given dates. + * + * @description + * Get the number of full years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full years + * + * @example + * // How many full years are between 31 December 2013 and 11 February 2015? + * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31)) + * //=> 1 + */ +export declare function differenceInYears( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInYearsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInYears.d.ts b/node_modules/date-fns/differenceInYears.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9bd6cfe21cb8cfa39b5b341ba9eaf6717cbf82b3 --- /dev/null +++ b/node_modules/date-fns/differenceInYears.d.ts @@ -0,0 +1,29 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link differenceInYears} function options. + */ +export interface DifferenceInYearsOptions extends ContextOptions {} +/** + * @name differenceInYears + * @category Year Helpers + * @summary Get the number of full years between the given dates. + * + * @description + * Get the number of full years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full years + * + * @example + * // How many full years are between 31 December 2013 and 11 February 2015? + * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31)) + * //=> 1 + */ +export declare function differenceInYears( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: DifferenceInYearsOptions | undefined, +): number; diff --git a/node_modules/date-fns/differenceInYears.js b/node_modules/date-fns/differenceInYears.js new file mode 100644 index 0000000000000000000000000000000000000000..d367610eeea814291c494d1637886f768a509ec7 --- /dev/null +++ b/node_modules/date-fns/differenceInYears.js @@ -0,0 +1,63 @@ +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { compareAsc } from "./compareAsc.js"; +import { differenceInCalendarYears } from "./differenceInCalendarYears.js"; + +/** + * The {@link differenceInYears} function options. + */ + +/** + * @name differenceInYears + * @category Year Helpers + * @summary Get the number of full years between the given dates. + * + * @description + * Get the number of full years between the given dates. + * + * @param laterDate - The later date + * @param earlierDate - The earlier date + * @param options - An object with options + * + * @returns The number of full years + * + * @example + * // How many full years are between 31 December 2013 and 11 February 2015? + * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31)) + * //=> 1 + */ +export function differenceInYears(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + laterDate, + earlierDate, + ); + + // -1 if the left date is earlier than the right date + // 2023-12-31 - 2024-01-01 = -1 + const sign = compareAsc(laterDate_, earlierDate_); + + // First calculate the difference in calendar years + // 2024-01-01 - 2023-12-31 = 1 year + const diff = Math.abs(differenceInCalendarYears(laterDate_, earlierDate_)); + + // Now we need to calculate if the difference is full. To do that we set + // both dates to the same year and check if the both date's month and day + // form a full year. + laterDate_.setFullYear(1584); + earlierDate_.setFullYear(1584); + + // For it to be true, when the later date is indeed later than the earlier date + // (2026-02-01 - 2023-12-10 = 3 years), the difference is full if + // the normalized later date is also later than the normalized earlier date. + // In our example, 1584-02-01 is earlier than 1584-12-10, so the difference + // is partial, hence we need to subtract 1 from the difference 3 - 1 = 2. + const partial = compareAsc(laterDate_, earlierDate_) === -sign; + + const result = sign * (diff - +partial); + + // Prevent negative zero + return result === 0 ? 0 : result; +} + +// Fallback for modularized imports: +export default differenceInYears; diff --git a/node_modules/date-fns/docs/cdn.md b/node_modules/date-fns/docs/cdn.md new file mode 100644 index 0000000000000000000000000000000000000000..cb33f5038f84e0c270bbae5f8f81de1de9fa615c --- /dev/null +++ b/node_modules/date-fns/docs/cdn.md @@ -0,0 +1,120 @@ +# CDN + +The CDN versions of date-fns are available as the [`@date-fns/cdn`](https://www.jsdelivr.com/package/npm/@date-fns/cdn) package on jsDelivr and other CDNs. They expose the date-fns functionality via the `window.dateFns` global variable. + +> ⚠️ The legacy CDN files in the `date-fns` package are deprecated and will be removed in a future version. They remain available for compatibility, but they log a migration notice in the console. Please update your URLs from `date-fns` to `@date-fns/cdn`. + +Unlike the npm package, the CDN is transpiled to be compatible with IE11, so it supports a wide variety of legacy browsers and environments. + +```html + + + + +``` + +Legacy URLs still work for now but should be replaced: + +```diff +- https://cdn.jsdelivr.net/npm/date-fns@VERSION/cdn.min.js ++ https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/cdn.min.js +``` + +The CDN versions are available for the main module, all & individual locales, and the FP submodule. + +They come in two flavors: `cdn.js` and `cdn.min.js`. The latter is minified and should be used in production. The former is useful for debugging and development. + +Keep in mind that using the CDN versions in production is suboptimal because they bundle all the date-fns functionality you will never use. It's much better to use the npm package and a tree-shaking-enabled bundler like webpack or Rollup. However, the CDN versions are helpful for quick prototyping, small projects, educational purposes, or working in a legacy environment. + +## Main module + +The main module with all functions bundled: + +``` +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/cdn.js +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/cdn.min.js +``` + +You can access it via the `dateFns` global variable: + +```html + + +``` + +## The FP submodule + +The FP submodule with all functions bundled: + +``` +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/fp/cdn.js +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/fp/cdn.min.js +``` + +You can access it via the `dateFns.fp` global variable: + +```html + + +``` + +## Locales + +All locales bundled: + +``` +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/cdn.js +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/cdn.min.js +``` + +You can access them via the `dateFns.locale` global variable: + +```html + + + +``` + +The locales are also available as individual files. + +``` +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/LOCALE/cdn.js +https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/LOCALE/cdn.min.js +``` + +You can access them via the `dateFns.locale.LOCALE` global variable: + +```html + + + +``` diff --git a/node_modules/date-fns/docs/config.d.ts b/node_modules/date-fns/docs/config.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c12b03a4c7fef4e9ad8e659001ba0e4256af4682 --- /dev/null +++ b/node_modules/date-fns/docs/config.d.ts @@ -0,0 +1,2 @@ +import type { DateFnsDocs } from "@date-fns/docs"; +export declare const config: DateFnsDocs.Config; diff --git a/node_modules/date-fns/docs/config.js b/node_modules/date-fns/docs/config.js new file mode 100644 index 0000000000000000000000000000000000000000..5044edb183367e7a888a3ae6abf3a98e96d0ac5f --- /dev/null +++ b/node_modules/date-fns/docs/config.js @@ -0,0 +1,135 @@ +/** @type {import('@date-fns/docs').DateFnsDocs.Config} */ +export const config = { + package: "..", + + json: "../tmp/docs.json", + + categories: [ + "General", + "Misc", + "Common Helpers", + "Conversion Helpers", + "Interval Helpers", + "Timestamp Helpers", + "Millisecond Helpers", + "Second Helpers", + "Minute Helpers", + "Hour Helpers", + "Day Helpers", + "Weekday Helpers", + "Week Helpers", + "ISO Week Helpers", + "Month Helpers", + "Quarter Helpers", + "Year Helpers", + "ISO Week-Numbering Year Helpers", + "Decade Helpers", + "Generic Helpers", + ], + + files: [ + { + type: "markdown", + slug: "Getting-Started", + category: "General", + title: "Getting Started", + summary: "Introduction & installation instructions", + path: "gettingStarted.md", + }, + { + type: "markdown", + slug: "Change-Log", + category: "General", + title: "Change Log", + summary: "Changes for each version of the library", + path: "../CHANGELOG.md", + }, + { + type: "markdown", + slug: "Contributing", + category: "General", + title: "Contributing", + summary: "Contribution manual", + path: "../../../CONTRIBUTING.md", + }, + { + type: "markdown", + slug: "Security", + category: "General", + title: "Security policy", + summary: "Security policy", + path: "../../../SECURITY.md", + }, + { + type: "markdown", + slug: "I18n", + category: "General", + title: "I18n", + summary: "Internationalization", + path: "i18n.md", + }, + { + type: "markdown", + slug: "I18n-Contribution-Guide", + category: "General", + title: "I18n Contribution Guide", + summary: "Locales manual", + path: "i18nContributionGuide.md", + }, + { + type: "markdown", + slug: "Time-Zones", + category: "General", + title: "Time Zones", + summary: "Time zone support", + path: "timeZones.md", + }, + { + type: "markdown", + slug: "CDN", + category: "General", + title: "CDN", + summary: "CDN version of date-fns", + path: "cdn.md", + }, + { + type: "markdown", + slug: "webpack", + category: "General", + title: "webpack", + summary: "Using date-fns with webpack", + path: "webpack.md", + }, + { + type: "markdown", + slug: "FP-Guide", + category: "General", + title: "FP Guide", + summary: "Curried functions", + path: "fp.md", + }, + { + type: "markdown", + slug: "Unicode-Tokens", + category: "General", + title: "Unicode Tokens", + summary: "Usage of the Unicode tokens in parse and format", + path: "unicodeTokens.md", + }, + { + type: "markdown", + slug: "License", + category: "General", + title: "License", + summary: "MIT © Sasha Koss", + path: "../LICENSE.md", + }, + ], + + kindsMap: { + "src/constants/index.ts": { + kind: "constants", + category: "Misc", + }, + }, +}; diff --git a/node_modules/date-fns/docs/fp.md b/node_modules/date-fns/docs/fp.md new file mode 100644 index 0000000000000000000000000000000000000000..0482fd43009ffdfafa083e3034d833034d76c3b0 --- /dev/null +++ b/node_modules/date-fns/docs/fp.md @@ -0,0 +1,72 @@ +# FP Guide + +**date-fns** v2.x provides [functional programming](https://en.wikipedia.org/wiki/Functional_programming) (FP) +friendly functions, like those in [lodash](https://github.com/lodash/lodash/wiki/FP-Guide), +that support [currying](https://en.wikipedia.org/wiki/Currying). + +## Table of Contents + +- [Usage](#usage) + +- [Using Function Composition](#using-function-composition) + +## Usage + +FP functions are provided via `'date-fns/fp'` submodule. + +Functions with options (`format`, `parse`, etc.) have two FP counterparts: +one that has the options object as its first argument and one that hasn't. +The name of the former has `WithOptions` added to the end of its name. + +In **date-fns'** FP functions, the order of arguments is reversed. + +```javascript +import { addYears, formatWithOptions } from "date-fns/fp"; +import { eo } from "date-fns/locale"; +import toUpper from "lodash/fp/toUpper"; // 'date-fns/fp' is compatible with 'lodash/fp'! + +// If FP function has not received enough arguments, it returns another function +const addFiveYears = addYears(5); + +// Several arguments can be curried at once +const dateToString = formatWithOptions({ locale: eo }, "d MMMM yyyy"); + +const dates = [ + new Date(2017, 0 /* Jan */, 1), + new Date(2017, 1 /* Feb */, 11), + new Date(2017, 6 /* Jul */, 2), +]; + +const formattedDates = dates.map(addFiveYears).map(dateToString).map(toUpper); +//=> ['1 JANUARO 2022', '11 FEBRUARO 2022', '2 JULIO 2022'] +``` + +## Using Function Composition + +The main advantage of FP functions is support of functional-style +[function composing](https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba). + +In the example above, you can compose `addFiveYears`, `dateToString` and `toUpper` into a single function: + +```javascript +const formattedDates = dates.map((date) => + toUpper(dateToString(addFiveYears(date))), +); +``` + +Or you can use `compose` function provided by [lodash](https://lodash.com) to do the same in more idiomatic way: + +```javascript +import { compose } from "lodash/fp/compose"; + +const formattedDates = dates.map(compose(toUpper, dateToString, addFiveYears)); +``` + +Or if you prefer natural direction of composing (as opposed to the computationally correct order), +you can use lodash' `flow` instead: + +```javascript +import flow from "lodash/fp/flow"; + +const formattedDates = dates.map(flow(addFiveYears, dateToString, toUpper)); +``` diff --git a/node_modules/date-fns/docs/gettingStarted.md b/node_modules/date-fns/docs/gettingStarted.md new file mode 100644 index 0000000000000000000000000000000000000000..ddae14892426b3d371d35b2f956a11cd83aeac37 --- /dev/null +++ b/node_modules/date-fns/docs/gettingStarted.md @@ -0,0 +1,76 @@ +# Getting Started + +## Table of Contents + +- [Introduction](#introduction) + +- [Submodules](#submodules) + +- [Installation](#installation) + +## Introduction + +**date-fns** provides the most comprehensive, yet simple and consistent toolset +for manipulating **JavaScript dates** in **a browser** & **Node.js**. + +**date-fns** is like [lodash](https://lodash.com) for dates. It has +[**200+ functions** for all occasions](https://date-fns.org/docs/). + +```js +import { format, compareAsc } from "date-fns"; + +format(new Date(2014, 1, 11), "MM/dd/yyyy"); +//=> '02/11/2014' + +const dates = [ + new Date(1995, 6, 2), + new Date(1987, 1, 11), + new Date(1989, 6, 10), +]; +dates.sort(compareAsc); +//=> [ +// Wed Feb 11 1987 00:00:00, +// Mon Jul 10 1989 00:00:00, +// Sun Jul 02 1995 00:00:00 +// ] +``` + +## Submodules + +**date-fns** includes some optional features as submodules in the npm package. +Here is the list of them, in order of nesting: + +- FP — functional programming-friendly variations of the functions. See [FP Guide](https://date-fns.org/docs/FP-Guide); + +The later submodules are also included inside the former if you want to use multiple features from the list. + +To use submodule features, [install the npm package](#npm) and then import a function from a submodule: + +```js +// The main submodule: +import { addDays } from "date-fns"; + +// FP variation: +import { addDays, format } from "date-fns/fp"; +``` + +## Installation + +The library is available as an [npm package](https://www.npmjs.com/package/date-fns). + +To install the package, run: + +```bash +npm install date-fns --save +# or +yarn add date-fns +``` + +Start using: + +```js +import { formatDistance, subDays } from "date-fns"; + +formatDistance(subDays(new Date(), 3), new Date(), { addSuffix: true }); +//=> "3 days ago" +``` diff --git a/node_modules/date-fns/docs/i18n.md b/node_modules/date-fns/docs/i18n.md new file mode 100644 index 0000000000000000000000000000000000000000..96d81576ef3977ed2d5fcbbb22a0284f05878a1e --- /dev/null +++ b/node_modules/date-fns/docs/i18n.md @@ -0,0 +1,91 @@ +# Internationalization + +## Table of Contents + +- [Usage](#usage) + +- [Adding New Language](#adding-new-language) + +## Usage + +There are just a few functions that support I18n: + +- [`format`](https://date-fns.org/docs/format) +- [`formatDistance`](https://date-fns.org/docs/formatDistance) +- [`formatDistanceStrict`](https://date-fns.org/docs/formatDistanceStrict) +- [`formatRelative`](https://date-fns.org/docs/formatRelative) + +To use a locale, you need to require it and then pass +as an option to a function: + +```js +import { formatDistance } from "date-fns"; +// Require Esperanto locale +import { eo } from "date-fns/locale"; + +const result = formatDistance( + new Date(2016, 7, 1), + new Date(2015, 0, 1), + { locale: eo }, // Pass the locale as an option +); +//=> 'pli ol 1 jaro' +``` + +It might seem complicated to require and pass locales as options, +but unlike Moment.js which bloats your build with all the locales +by default date-fns forces developer to manually require locales when needed. +To make API simple, we encourage you to write tiny wrappers and use those +instead of original functions: + +```js +// app/_lib/format.js + +import { format } from "date-fns"; +import { enGB, eo, ru } from "date-fns/locale"; + +const locales = { enGB, eo, ru }; + +// by providing a default string of 'PP' or any of its variants for `formatStr` +// it will format dates in whichever way is appropriate to the locale +export default function (date, formatStr = "PP") { + return format(date, formatStr, { + locale: locales[window.__localeId__], // or global.__localeId__ + }); +} + +// Later: + +import format from "app/_lib/format"; + +window.__localeId__ = "enGB"; +format(friday13, "EEEE d"); +//=> 'Friday 13' + +window.__localeId__ = "eo"; +format(friday13, "EEEE d"); +//=> 'vendredo 13' + +// If the format string is omitted, it will take the default for the locale. +window.__localeId__ = "enGB"; +format(friday13); +//=> Jul 13, 2019 + +window.__localeId__ = "eo"; +format(friday13); +//=> 2019-jul-13 +``` + +## Adding New Language + +At the moment there is no definitive guide, so if you feel brave enough, +use this quick guide: + +- First of all, [create an issue](https://github.com/date-fns/date-fns/issues/new?title=XXX%20language%20support) + so you won't overlap with others. +- A detailed explanation of how to [add a new locale](https://github.com/date-fns/date-fns/blob/master/docs/i18nContributionGuide.md#adding-a-new-locale). +- Use [English locale](https://github.com/date-fns/date-fns/tree/master/src/locale/en-US) + as the basis and then incrementally adjust the tests and the code. +- Directions on [adding a locale with the same language as another locale](https://github.com/date-fns/date-fns/blob/master/docs/i18nContributionGuide.md#creating-a-locale-with-the-same-language-as-another-locale). +- If you have questions or need guidance, leave a comment in the issue. + +Thank you for your support! diff --git a/node_modules/date-fns/docs/i18nContributionGuide.md b/node_modules/date-fns/docs/i18nContributionGuide.md new file mode 100644 index 0000000000000000000000000000000000000000..8d6764408b16098f986758f483d83105e1c28b20 --- /dev/null +++ b/node_modules/date-fns/docs/i18nContributionGuide.md @@ -0,0 +1,1059 @@ +# I18n Contribution Guide + +## Table of Contents + +- [Adding a new locale](#adding-a-new-locale) + - [Choosing a directory name for a locale](#choosing-a-directory-name-for-a-locale) + + - [index.js](#index.js) + + - [localize](#localize) + - [localize.ordinalNumber](#localize.ordinalnumber) + + - [localize.era and using buildLocalizeFn function](#localize.era-and-using-buildlocalizefn-function) + + - [Formatting localizers](#formatting-localizers) + + - [localize.quarter](#localize.quarter) + + - [localize.month](#localize.month) + + - [localize.day](#localize.day) + + - [localize.dayPeriod](#localize.dayperiod) + + - [formatLong](#formatlong) + - [formatLong.dateFormats](#formatlong.dateformats) + + - [formatLong.timeFormats](#formatlong.timeformats) + + - [formatLong.dateTimeFormats](#formatlong.datetimeformats) + + - [formatRelative](#formatrelative) + + - [match](#match) + + - [formatDistance](#formatdistance) + + - [Tests](#tests) + +- [Creating a locale with the same language as another locale](#creating-a-locale-with-the-same-language-as-another-locale) + +## Adding a new locale + +To add a new locale: + +- [Choose a directory name for it](#choosing-a-directory-name-for-a-locale). + +- Copy the content of an existing locale (e.g. `en-US`) into the newly created directory. + +- Replace the values in the content with yours file-by-file. + Use [CLDR data](https://www.unicode.org/cldr/charts/32/summary/root.html) + as a point of reference which values to choose. + +All locales contain a number of properties: + +- [`formatDistance`](#formatdistance) — distance localizer function used by `formatDistance` and `formatDistanceStrict`. +- [`formatLong`](#formatlong) — contains long date localizer functions used by `format` and `formatRelative`. +- [`formatRelative`](#formatrelative) — relative date localizer function used by `formatRelative`. +- [`localize`](#localize) — contains functions, which localize the various date values. Required by `format` and `formatRelative`. +- [`match`](#match) — contains functions to parse date values. Required by `parse`. +- [`options`](#indexjs) — contains the index of the first day of the week for functions such as `startOfWeek`, + and the value which determines the first week of the year + for functions like `setWeek`. + +### Choosing a directory name for a locale + +Use the four letter code for the directory name (e.g. `en-GB`), + +Use the two/three letter code: + +- if the language code and the country code are the same (e.g. `pt` instead of `pt-PT`). + +- if the language is used in only one country (e.g. `fil` instead of `fil-PH`). + +- if all countries who use the language + also use the same regional standards: the first day of the week, + the week numbering (see: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system), + calendar date format (see: https://en.wikipedia.org/wiki/Calendar_date) + and date representation (see: https://en.wikipedia.org/wiki/Date_and_time_representation_by_country + and: https://en.wikipedia.org/wiki/Date_format_by_country) + (e.g. `ca` instead of `ca-ES` and `ca-AD`). + +### index.js + +Locale's `index.js` is where all the properties of the locale are combined in a single file, +documented in JSDoc format. + +```javascript +import formatDistance from "./_lib/formatDistance/index.js"; +import formatLong from "./_lib/formatLong/index.js"; +import formatRelative from "./_lib/formatRelative/index.js"; +import localize from "./_lib/localize/index.js"; +import match from "./_lib/match/index.js"; + +/** + * @type {Locale} + * @category Locales + * + * // Name of the locale. + * // Inside the parentheses - name of the country - if the locale uses the four letter code, e.g. en-US, fr-CA or pt-BR. + * @summary English locale (United States). + * + * // Name of the language (used by https://date-fns.org/ website) + * @language English + * + * // ISO 639-2 code. See the list here: + * // https://www.loc.gov/standards/iso639-2/php/code_list.php + * // Used by https://date-fns.org/ to detect the list of the countries that uses the language. + * @iso-639-2 eng + * + * // Authors of the locale (including anyone who corrected or fixed the locale) + * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp} + * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss} + */ +var locale = { + code: "en", + formatDistance: formatDistance, + formatLong: formatLong, + formatRelative: formatRelative, + localize: localize, + match: match, + options: { + // Index of the first day of the week. + // Sunday is 0, Monday is 1, Saturday is 6. + weekStartsOn: 0, + + // Nth of January which is always in the first week of the year. See: + // https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system + // http://www.pjh2.de/datetime/weeknumber/wnd.php?l=en + firstWeekContainsDate: 1, + }, +}; + +export default locale; +``` + +### localize + +Put this object in `_lib/localize/index.js` inside your locale directory. +Contains a number of functions for used by `format`: + +```js +var localize = { + ordinalNumber, + era, + quarter, + month, + day, + dayPeriod, +}; + +export default localize; +``` + +#### localize.ordinalNumber + +Function that takes a numeric argument and returns a string with ordinal number: + +```js +// In `en-US` locale: +function ordinalNumber(dirtyNumber, dirtyOptions) { + var number = Number(dirtyNumber); + + var rem100 = number % 100; + if (rem100 > 20 || rem100 < 10) { + switch (rem100 % 10) { + case 1: + return number + "st"; + case 2: + return number + "nd"; + case 3: + return number + "rd"; + } + } + return number + "th"; +} + +var localize = { + ordinalNumber: ordinalNumber, + // ... +}; +``` + +If the form of the ordinal number depends on the grammatical case (or other grammatical structures), +use `options.unit` argument which could be one of the values 'year', 'quarter', 'month', 'week', +'date', 'dayOfYear', 'day', 'hour', 'minute' or 'second': + +```js +// In `ru` locale: +function ordinalNumber(dirtyNumber, dirtyOptions) { + var options = dirtyOptions || {}; + var unit = String(options.unit); + var suffix; + + if (unit === "date") { + suffix = "-е"; + } else if (unit === "week" || unit === "minute" || unit === "second") { + suffix = "-я"; + } else { + suffix = "-й"; + } + + return dirtyNumber + suffix; +} +``` + +#### localize.era and using buildLocalizeFn function + +Localizes a numeric era. Takes either 0 or 1 as the first argument. +As with many of the `localize` functions, they can be generated by built-in +`buildLocalizeFn` function. + +From the CLDR chart, use ['Date & Time'/'Gregorian'/'Eras'](https://www.unicode.org/cldr/charts/32/summary/en.html#1771) values. + +```js +// In `en-US` locale: +import buildLocalizeFn from "../../../_lib/buildLocalizeFn/index.js"; + +var eraValues = { + narrow: ["B", "A"], + abbreviated: ["BC", "AD"], + wide: ["Before Christ", "Anno Domini"], +}; + +var localize = { + // ... + era: buildLocalizeFn({ + values: eraValues, + defaultWidth: "wide", + }), + // ... +}; + +export default localize; +``` + +General usage of the function: + +```js +var result = locale.localize.era(1, { width: "abbreviated" }); +//=> 'AD' +``` + +If `width` is not provided or the `values` object does not contain values for the provided width, +`defaultWidth` will be used. `defaultWidth` should indicate the longest form of the localized value. +The same is true for all other `localize` functions. +`width` for `localize.era` function could be either 'narrow', 'abbreviated' or 'wide'. + +```js +var result = locale.localize.era(1, { width: "foobar" }); +//=> 'Anno Domini' +``` + +#### Formatting localizers + +For some languages, there is a difference between "stand-alone" localizers and "formatting" localizers. +"Stand-alone" means that the resulting value should make grammatical sense without context. +"Formatting" means that the resulting value should be decided using the grammar rules of the language +as if the value was a part of a date. +For example, for languages with grammatical cases, the stand-alone month could be in the nominative case ("January"), +and the formatting month could decline as a part of the phrase "1st of January". +In this case, use parameters `formattingValues` and `defaultFormattingWidth` of `buildLocalizeFn` function. + +Any localizer could be stand-alone and formatting. +Check the CLDR chart for the unit to see if stand-alone and formatting values are different for a certain unit. +If there's no difference (usually it happens in languages without grammatical cases), +parameters `formattingValues` and `defaultFormattingWidth` are not needed. + +In this example, in Russian language a stand-alone month is in the nominative case ("январь"), +and formatting month is in the genitive case ("января" as in "1-е января"). Notice the different endings: + +```js +// In `ru` locale: +var monthValues = { + narrow: ["Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"], + abbreviated: [ + "янв.", + "фев.", + "март", + "апр.", + "май", + "июнь", + "июль", + "авг.", + "сент.", + "окт.", + "нояб.", + "дек.", + ], + wide: [ + "январь", + "февраль", + "март", + "апрель", + "май", + "июнь", + "июль", + "август", + "сентябрь", + "октябрь", + "ноябрь", + "декабрь", + ], +}; +var formattingMonthValues = { + narrow: ["Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"], + abbreviated: [ + "янв.", + "фев.", + "мар.", + "апр.", + "мая", + "июн.", + "июл.", + "авг.", + "сент.", + "окт.", + "нояб.", + "дек.", + ], + wide: [ + "января", + "февраля", + "марта", + "апреля", + "мая", + "июня", + "июля", + "августа", + "сентября", + "октября", + "ноября", + "декабря", + ], +}; + +var localize = { + // ... + month: buildLocalizeFn({ + values: monthValues, + defaultWidth: "wide", + formattingValues: formattingMonthValues, + defaultFormattingWidth: "wide", + }), + // ... +}; + +export default localize; +``` + +#### localize.quarter + +Localizes a quarter. Takes 1, 2, 3 or 4 as the first argument. +`width` could be either 'narrow', 'abbreviated' or 'wide'. +From the CLDR chart, use ['Date & Time'/'Gregorian'/'Quarters'](https://www.unicode.org/cldr/charts/32/summary/en.html#1781) values. + +```js +// In `en-US` locale: +import buildLocalizeFn from "../../../_lib/buildLocalizeFn/index.js"; + +var quarterValues = { + narrow: ["1", "2", "3", "4"], + abbreviated: ["Q1", "Q2", "Q3", "Q4"], + wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"], +}; + +var localize = { + // ... + quarter: buildLocalizeFn({ + values: quarterValues, + defaultWidth: "wide", + argumentCallback: function (quarter) { + return Number(quarter) - 1; + }, + }), + // ... +}; + +export default localize; +``` + +Note the usage of `argumentCallback` here. It converts the value passed into `localize.quarter` function +(one of 1, 2, 3 or 4) into the index of the values array inside `quarterValues` (one of 0, 1, 2 or 3). + +#### localize.month + +Localizes a month. Takes numbers between 0 (for January) and 11 (for December). +`width` could be either 'narrow', 'abbreviated' or 'wide'. +From the CLDR chart, use ['Date & Time'/'Gregorian'/'Months'](https://www.unicode.org/cldr/charts/32/summary/en.html#1793) values. + +```js +// In `en-US` locale: +import buildLocalizeFn from "../../../_lib/buildLocalizeFn/index.js"; + +var monthValues = { + narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], + abbreviated: [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", + ], + wide: [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + ], +}; + +var localize = { + // ... + month: buildLocalizeFn({ + values: monthValues, + defaultWidth: "wide", + }), + // ... +}; + +export default localize; +``` + +**NOTE**: in English, the names of days of the week and months are capitalized. +Check if the same is true for the language you're working on. +Generally, formatted dates should look like they are in the middle of a sentence, +e.g. in Spanish language the weekdays and months should be in the lowercase: + +```js +// In `es` locale: +var monthValues = { + narrow: ["E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], + abbreviated: [ + "ene.", + "feb.", + "mar.", + "abr.", + "may.", + "jun.", + "jul.", + "ago.", + "sep.", + "oct.", + "nov.", + "dic.", + ], + wide: [ + "enero", + "febrero", + "marzo", + "abril", + "mayo", + "junio", + "julio", + "agosto", + "septiembre", + "octubre", + "noviembre", + "diciembre", + ], +}; +``` + +`monthValues.narrow` are usually capitalized in every language. Check the CLDR chart for your language. + +#### localize.day + +Localizes a week day. Takes numbers between 0 (for Sunday) and 6 (for Saturday). +`width` could be either 'narrow', 'short', 'abbreviated' or 'wide'. +From the CLDR chart, use ['Date & Time'/'Gregorian'/'Days'](https://www.unicode.org/cldr/charts/32/summary/en.html#1829) values. + +```js +// In `en-US` locale: +import buildLocalizeFn from "../../../_lib/buildLocalizeFn/index.js"; + +var dayValues = { + narrow: ["S", "M", "T", "W", "T", "F", "S"], + short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], + abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + wide: [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + ], +}; + +var localize = { + // ... + day: buildLocalizeFn({ + values: dayValues, + defaultWidth: "wide", + }), + // ... +}; + +export default localize; +``` + +**NOTE**: the rules of capitalization from `localize.month` are also true for `localize.day`. + +#### localize.dayPeriod + +Localizes a certain day period. +Could take one of these strings as the argument: 'am', 'pm', 'midnight', 'noon', 'morning', 'afternoon', 'evening', 'night'. +`width` could be either 'narrow', 'abbreviated' or 'wide'. +From the CLDR chart, use ['Date & Time'/'Gregorian'/'Day periods'](https://www.unicode.org/cldr/charts/32/summary/en.html#1857) values. + +```js +// In `en-US` locale: +import buildLocalizeFn from "../../../_lib/buildLocalizeFn/index.js"; + +var dayPeriodValues = { + narrow: { + am: "a", + pm: "p", + midnight: "mi", + noon: "n", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night", + }, + abbreviated: { + am: "AM", + pm: "PM", + midnight: "midnight", + noon: "noon", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night", + }, + wide: { + am: "a.m.", + pm: "p.m.", + midnight: "midnight", + noon: "noon", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night", + }, +}; + +var localize = { + // ... + dayPeriod: buildLocalizeFn({ + values: dayPeriodValues, + defaultWidth: "wide", + }), +}; + +export default localize; +``` + +### formatLong + +Put this object in `_lib/formatLong/index.js` inside your locale directory. +Locale date formats written in `format` token string format. +See the list of tokens: https://date-fns.org/docs/format +Use https://en.wikipedia.org/wiki/Date_format_by_country and CLDR chart as the reference. + +#### formatLong.dateFormats + +Use ['Date & Time'/'Gregorian'/'Formats - Standard - Date Formats'](https://www.unicode.org/cldr/charts/32/summary/en.html#1901) values +from the CLDR chart as a reference. + +```js +// In `en-US` locale +import buildFormatLongFn from "../../../_lib/buildFormatLongFn/index.js"; + +var dateFormats = { + full: "EEEE, MMMM do, y", + long: "MMMM do, y", + medium: "MMM d, y", + short: "MM/dd/yyyy", +}; + +var formatLong = { + date: buildFormatLongFn({ + formats: dateFormats, + defaultWidth: "full", + }), + // ... +}; + +export default formatLong; +``` + +`dateFormats.long` usually contains the longest form of writing the year, the month, and the day of the month. +Use ordinal day of the month ('do' token) where applicable (date-fns, unlike CLDR supports ordinal numbers). + +`dateFormats.full` contains the same but with the day of the week. + +`dateFormats.medium` contains the same values as `dateFormats.long`, but with short form of month and non-ordinal day. + +`dateFormats.short` usually contains a strictly numerical form of the date. +Pay attention to the order of units (big-, little- or middle-endian) + +#### formatLong.timeFormats + +Use ['Date & Time'/'Gregorian'/'Formats - Standard - Time Formats'](https://www.unicode.org/cldr/charts/32/summary/en.html#1906) values +from the CLDR chart as a reference. + +Use some variation of 'h:mm aa' for 12-hour clock locales or 'H:mm' for 24-hour clock locales. Use the local time separator. + +```js +// In `en-US` locale +import buildFormatLongFn from "../../../_lib/buildFormatLongFn/index.js"; + +var timeFormats = { + full: "h:mm:ss a zzzz", + long: "h:mm:ss a z", + medium: "h:mm:ss a", + short: "h:mm a", +}; + +var formatLong = { + // ... + time: buildFormatLongFn({ + formats: timeFormats, + defaultWidth: "full", + }), + // ... +}; + +export default formatLong; +``` + +#### formatLong.dateTimeFormats + +Use +['Date & Time'/'Gregorian'/'Formats - Standard - Date & Time Combination Formats'](https://www.unicode.org/cldr/charts/32/summary/en.html#1910) +values from the CLDR chart. + +```js +// In `en-US` locale +import buildFormatLongFn from "../../../_lib/buildFormatLongFn/index.js"; + +var dateTimeFormats = { + full: "{{date}} 'at' {{time}}", + long: "{{date}} 'at' {{time}}", + medium: "{{date}}, {{time}}", + short: "{{date}}, {{time}}", +}; + +var formatLong = { + // ... + dateTime: buildFormatLongFn({ + formats: dateTimeFormats, + defaultWidth: "full", + }), +}; + +export default formatLong; +``` + +'{{date}}' and '{{time}}' from the strings will be replaced with the date and time respectively. + +### formatRelative + +Put this function in `_lib/formatRelative/index.js` inside your locale directory. +Relative date formats written in `format` token string format. +See the list of tokens: https://date-fns.org/docs/format. +Has to process `lastWeek`, `yesterday`, `today`, `tomorrow`, `nextWeek` and `other` tokens. + +```javascript +// In `en-US` locale +var formatRelativeLocale = { + lastWeek: "'last' eeee 'at' p", + yesterday: "'yesterday at' p", + today: "'today at' p", + tomorrow: "'tomorrow at' p", + nextWeek: "eeee 'at' p", + other: "P", +}; + +export default function formatRelative(token, date, baseDate, options) { + return formatRelativeLocale[token]; +} +``` + +You can use `date` and `baseDate` supplied to the function for the difficult situations +(e.g. grammatical genders and cases of the days of the week). +Example is below. Note the different grammatical case for weekdays (accusative instead of nominative) +and declension of word "прошлый" which depends on the grammatical gender of the weekday: + +```javascript +// In `ru` locale +var accusativeWeekdays = [ + "воскресенье", + "понедельник", + "вторник", + "среду", + "четверг", + "пятницу", + "субботу", +]; + +function lastWeek(day) { + var weekday = accusativeWeekdays[day]; + + switch (day) { + case 0: + return "'в прошлое " + weekday + " в' p"; + case 1: + case 2: + case 4: + return "'в прошлый " + weekday + " в' p"; + case 3: + case 5: + case 6: + return "'в прошлую " + weekday + " в' p"; + } +} + +function thisWeek(day) { + // ... +} + +function nextWeek(day) { + // ... +} + +var formatRelativeLocale = { + lastWeek: function (date, baseDate, options) { + var day = date.getDay(); + if (isSameUTCWeek(date, baseDate, options)) { + return thisWeek(day); + } else { + return lastWeek(day); + } + }, + yesterday: "'вчера в' p", + today: "'сегодня в' p", + tomorrow: "'завтра в' p", + nextWeek: function (date, baseDate, options) { + var day = date.getDay(); + if (isSameUTCWeek(date, baseDate, options)) { + return thisWeek(day); + } else { + return nextWeek(day); + } + }, + other: "P", +}; + +export default function formatRelative(token, date, baseDate, options) { + var format = formatRelativeLocale[token]; + + if (typeof format === "function") { + return format(date, baseDate, options); + } + + return format; +} +``` + +### match + +Put this object in `_lib/match/index.js` inside your locale directory. +Contains the functions used by `parse` to parse a localized value: + +```js +// In `en-US` locale: +import buildMatchPatternFn from "../../../_lib/buildMatchPatternFn/index.js"; +import buildMatchFn from "../../../_lib/buildMatchFn/index.js"; + +var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; +var parseOrdinalNumberPattern = /\d+/i; + +var matchEraPatterns = { + narrow: /^(b|a)/i, + abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, + wide: /^(before christ|before common era|anno domini|common era)/i, +}; +var parseEraPatterns = { + any: [/^b/i, /^(a|c)/i], +}; + +var matchQuarterPatterns = { + narrow: /^[1234]/i, + abbreviated: /^q[1234]/i, + wide: /^[1234](th|st|nd|rd)? quarter/i, +}; +var parseQuarterPatterns = { + any: [/1/i, /2/i, /3/i, /4/i], +}; + +var matchMonthPatterns = { + narrow: /^[jfmasond]/i, + abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, + wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i, +}; +var parseMonthPatterns = { + narrow: [ + /^j/i, + /^f/i, + /^m/i, + /^a/i, + /^m/i, + /^j/i, + /^j/i, + /^a/i, + /^s/i, + /^o/i, + /^n/i, + /^d/i, + ], + any: [ + /^ja/i, + /^f/i, + /^mar/i, + /^ap/i, + /^may/i, + /^jun/i, + /^jul/i, + /^au/i, + /^s/i, + /^o/i, + /^n/i, + /^d/i, + ], +}; + +var matchDayPatterns = { + narrow: /^[smtwf]/i, + short: /^(su|mo|tu|we|th|fr|sa)/i, + abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, + wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i, +}; +var parseDayPatterns = { + narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], + any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i], +}; + +var matchDayPeriodPatterns = { + narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, + any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i, +}; +var parseDayPeriodPatterns = { + any: { + am: /^a/i, + pm: /^p/i, + midnight: /^mi/i, + noon: /^no/i, + morning: /morning/i, + afternoon: /afternoon/i, + evening: /evening/i, + night: /night/i, + }, +}; + +var match = { + ordinalNumber: buildMatchPatternFn({ + matchPattern: matchOrdinalNumberPattern, + parsePattern: parseOrdinalNumberPattern, + valueCallback: function (value) { + return parseInt(value, 10); + }, + }), + + era: buildMatchFn({ + matchPatterns: matchEraPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseEraPatterns, + defaultParseWidth: "any", + }), + + quarter: buildMatchFn({ + matchPatterns: matchQuarterPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseQuarterPatterns, + defaultParseWidth: "any", + valueCallback: function (index) { + return index + 1; + }, + }), + + month: buildMatchFn({ + matchPatterns: matchMonthPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseMonthPatterns, + defaultParseWidth: "any", + }), + + day: buildMatchFn({ + matchPatterns: matchDayPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseDayPatterns, + defaultParseWidth: "any", + }), + + dayPeriod: buildMatchFn({ + matchPatterns: matchDayPeriodPatterns, + defaultMatchWidth: "any", + parsePatterns: parseDayPeriodPatterns, + defaultParseWidth: "any", + }), +}; + +export default match; +``` + +These functions mirror those in `localize`. + +For `matchPatterns` the patterns should match the whole meaningful word for the parsed value +(which will be cut from the string in the process of parsing). +`parsePatterns` contains patterns to detect one of the values from the result of `matchPatterns` +Note that the patterns for `parsePatterns` don't necessary contain the whole word: + +```javascript +// In `en-US` locale: +var parseDayPatterns = { + narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], + any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i], +}; +``` + +but only the bare minimum to parse the value. + +Also note that all patterns have "case-insensitive" flags +to match as much arbitrary user input as possible. For the same reason, try to match +any variation of diacritical marks: + +```javascript +// In `eo` locale: +var matchDayPatterns = { + narrow: /^[dlmĵjvs]/i, + short: /^(di|lu|ma|me|(ĵ|jx|jh|j)a|ve|sa)/i, + abbreviated: /^(dim|lun|mar|mer|(ĵ|jx|jh|j)a(ŭ|ux|uh|u)|ven|sab)/i, + wide: /^(diman(ĉ|cx|ch|c)o|lundo|mardo|merkredo|(ĵ|jx|jh|j)a(ŭ|ux|uh|u)do|vendredo|sabato)/i, +}; +var parseDayPatterns = { + narrow: [/^d/i, /^l/i, /^m/i, /^m/i, /^(j|ĵ)/i, /^v/i, /^s/i], + any: [/^d/i, /^l/i, /^ma/i, /^me/i, /^(j|ĵ)/i, /^v/i, /^s/i], +}; +``` + +Here, for the word "dimanĉo" the functions will match also "dimancxo", "dimancho" +and even grammatically incorrect "dimanco". + +Try to match any possible way of writing the word. Don't forget the grammatical cases: + +```javascript +// In `ru` locale: +var matchMonthPatterns = { + narrow: /^[яфмаисонд]/i, + abbreviated: + /^(янв|фев|март?|апр|ма[йя]|июн[ья]?|июл[ья]?|авг|сент?|окт|нояб?|дек)/i, + wide: /^(январ[ья]|феврал[ья]|марта?|апрел[ья]|ма[йя]|июн[ья]|июл[ья]|августа?|сентябр[ья]|октябр[ья]|октябр[ья]|ноябр[ья]|декабр[ья])/i, +}; +``` + +and variations of short weekdays and months: + +```javascript +// In `ru` locale: +var matchDayPatterns = { + narrow: /^[впсч]/i, + short: /^(вс|во|пн|по|вт|ср|чт|че|пт|пя|сб|су)\.?/i, + abbreviated: /^(вск|вос|пнд|пон|втр|вто|срд|сре|чтв|чет|птн|пят|суб).?/i, + wide: /^(воскресень[ея]|понедельника?|вторника?|сред[аы]|четверга?|пятниц[аы]|суббот[аы])/i, +}; +``` + +(here, the `abbreviated` pattern will match both `вск` and `вос` as the short of `воскресенье` {Sunday}) + +In `match.ordinalNumber` match ordinal numbers as well as non-ordinal numbers: + +```javascript +// In `en-US` locale: +var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; +``` + +Don't forget the grammatical genders: + +```javascript +// In `ru` locale: +var matchOrdinalNumberPattern = /^(\d+)(-?(е|я|й|ое|ье|ая|ья|ый|ой|ий|ый))?/i; +``` + +### formatDistance + +`formatDistance` property of locale is a function which takes three arguments: +token passed by date-fns' `formatDistance` function (e.g. 'lessThanXMinutes'), +a number of units to be displayed by the function +(e.g. `locale.formatDistance('lessThanXMinutes', 5)` would display localized 'less than 5 minutes') +and object with options. + +Your best guess is to copy `formatDistance` property from another locale and change the values. + +### Tests + +To test locales we use snapshots. See [`en-US` snapshot](https://github.com/date-fns/date-fns/blob/master/src/locale/en-US/snapshot.md) for an example. + +To generate snapshots, run `pnpm run locale-snapshots`. The snapshot for the locale +you're working on will appear in the root locale directory (e.g. `src/locales/ru/snapshot.md`). + +Once you are done with the locale, generate the snapshot and review the output values. + +## Creating a locale with the same language as another locale + +Import the locale properties already implemented for the language, +but replace unique properties. + +```javascript +// Same as en-US +import formatDistance from "../en-US/_lib/formatDistance/index.js"; +import formatRelative from "../en-US/_lib/formatRelative/index.js"; +import localize from "../en-US/_lib/localize/index.js"; +import match from "../en-US/_lib/match/index.js"; + +// Unique for en-GB +import formatLong from "./_lib/formatLong/index.js"; + +/** + * @type {Locale} + * @category Locales + * @summary English locale (United Kingdom). + * @language English + * @iso-639-2 eng + * @author John Doe [@example]{@link https://github.com/example} + */ +var locale = { + formatDistance: formatDistance, + formatLong: formatLong, + formatRelative: formatRelative, + localize: localize, + match: match, + + // Unique for en-GB + options: { + weekStartsOn: 1, + firstWeekContainsDate: 4, + }, +}; + +export default locale; +``` diff --git a/node_modules/date-fns/docs/logo.svg b/node_modules/date-fns/docs/logo.svg new file mode 100644 index 0000000000000000000000000000000000000000..212e227bea154eb4a80dc290bf6f5fdbdf66d4f7 --- /dev/null +++ b/node_modules/date-fns/docs/logo.svg @@ -0,0 +1,26 @@ + + + + Slice 1 + Created with Sketch. + + + + + \ No newline at end of file diff --git a/node_modules/date-fns/docs/logotype.svg b/node_modules/date-fns/docs/logotype.svg new file mode 100644 index 0000000000000000000000000000000000000000..8b2a3a464ec277d2fc344a38366fd80693ce8755 --- /dev/null +++ b/node_modules/date-fns/docs/logotype.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/date-fns/docs/release.md b/node_modules/date-fns/docs/release.md new file mode 100644 index 0000000000000000000000000000000000000000..63ef35c276bf5e09c7a961c272468a97d5430097 --- /dev/null +++ b/node_modules/date-fns/docs/release.md @@ -0,0 +1,19 @@ +# Releasing date-fns + +1. First, make sure that the library is built by running `./scripts/build/build.sh` and committing and pushing any change you would have. + +2. Then add the changelog entry generated by `node scripts/release/buildChangelog.ts` to (CHANGELOG.md)[../CHANGELOG.md]. Make sure that the output is valid Markdown and fix if there're any errors. Commit and push the file. + +3. Using the version that the changelog script generated, run the command: + + ```bash + env VERSION="vX.XX.X" APP_ENV="production" GOOGLE_APPLICATION_CREDENTIALS="secrets/production/key.json" ./scripts/release/release.sh + ``` + + The script will change `package.json`. **Do not commit the change, and reset it instead**. + +4. Now when the package is published, go to [GitHub Releases](https://github.com/date-fns/date-fns/releases) and draft a new version using the changelog entry you generated earlier. + +5. Finally, write an announce tweet using the created GitHub release as the tweet link. + +You're done, great job! diff --git a/node_modules/date-fns/docs/timeZones.md b/node_modules/date-fns/docs/timeZones.md new file mode 100644 index 0000000000000000000000000000000000000000..cb8a0fc249806915e3c4796e9669e0998b86a5ef --- /dev/null +++ b/node_modules/date-fns/docs/timeZones.md @@ -0,0 +1,127 @@ +# Time zones + +Starting from v4, date-fns has first-class support for time zones. It is provided via [`@date-fns/tz`] and [`@date-fns/utc`] packages. Visit the links to learn more about corresponding packages. + +Just like with everything else in date-fns, the time zones support has a minimal bundle size footprint with `UTCDateMini` and `TZDateMini` being `239 B` and `761 B`, respectively. + +If you're looking for time zone support prior to date-fns v4, see the third-party [`date-fns-tz`](https://github.com/marnusw/date-fns-tz) package. + +[See the announcement blog post](https://blog.date-fns.org/v40-with-time-zone-support/) for details about the motivation and implementation and [the change log entry for the list of changes in v4.0](https://date-fns.org/v4.0.0/docs/Change-Log#v4.0.0-2024-09-16). + +## Working with time zones + +There are two ways to start working with time zones: + +- [Using the `Date` extensions `TZDate` and `UTCDate`](#using-tzdate-utcdate) +- [Using the date-fns functions' `in` option](#using-in-option) + +### Using `TZDate` & `UTCDate` + +One way is to use [`TZDate`](https://github.com/date-fns/tz) or [`UTCDate`](https://github.com/date-fns/tz) `Date` extensions,with regular date-fns functions: + +```ts +import { TZDate } from "@date-fns/tz"; +import { addHours } from "date-fns"; + +// Given that the system time zone is America/Los_Angeles +// where DST happens on Sunday, 13 March 2022, 02:00:00 + +// Using the system time zone will produce 03:00 instead of 02:00 because of DST: +const date = new Date(2022, 2, 13); +addHours(date, 2).toString(); +//=> 'Sun Mar 13 2022 03:00:00 GMT-0700 (Pacific Daylight Time)' + +// Using Asia/Singapore will provide the expected 02:00: +const tzDate = new TZDate(2022, 2, 13, "Asia/Singapore"); +addHours(tzDate, 2).toString(); +//=> 'Sun Mar 13 2022 02:00:00 GMT+0800 (Singapore Standard Time)' +``` + +You can safely mix and match regular `Date` instances, as well as `UTCDate` or `TZDate` in different time zones and primitive values (timestamps and strings). date-fns will normalize the arguments, taking the first object argument (`Date` or a `Date` extension instance) as the reference and return the result in the reference type: + +```ts +import { TZDate } from "@date-fns/tz"; +import { differenceInBusinessDays } from "date-fns"; + +const laterDate = new TZDate(2025, 0, 1, "Asia/Singapore"); +const earlierDate = new TZDate(2024, 0, 1, "America/New_York"); + +// Will calculate in Asia/Singapore +differenceInBusinessDays(laterDate, earlierDate); +//=> 262 + +// Will calculate in America/New_York +differenceInBusinessDays(earlierDate, laterDate); +//=> -261 +``` + +In the given example, the one-day difference comes from the fact that in New York (UTC-5), the `earlierDate` will be `Dec 31` rather than `Jan 1`: + +```ts +laterDate.withTimeZone("Asia/Singapore").toString(); +//=> 'Wed Jan 01 2025 00:00:00 GMT+0800 (Singapore Standard Time)' +earlierDate.withTimeZone("Asia/Singapore").toString(); +//=> 'Mon Jan 01 2024 13:00:00 GMT+0800 (Singapore Standard Time)' + +laterDate.withTimeZone("America/New_York").toString(); +//=> 'Tue Dec 31 2024 11:00:00 GMT-0500 (Eastern Standard Time)' +earlierDate.withTimeZone("America/New_York").toString(); +//=> 'Mon Jan 01 2024 00:00:00 GMT-0500 (Eastern Standard Time)' +``` + +This is essential to understand and consider when making calculations. + +### Using `in` option + +When it is important to get the value in a specific time zone or when you are unsure about the type of arguments, use the function context `in` option. + +Each function, where the calculation might be affected by the time zone, like with `differenceInBusinessDays`, accepts the `in` option that provides the context for the arguments and the result, so you can explicitly say what time zone to use: + +```ts +import { tz } from "@date-fns/tz"; + +// Will calculate in Asia/Singapore +differenceInBusinessDays(laterDate, earlierDate); +//=> 262 + +// Will normalize to America/Los_Angeles +differenceInBusinessDays(laterDate, earlierDate, { + in: tz("America/Los_Angeles"), +}); +//=> 261 +``` + +In the example, we forced `differenceInBusinessDays` to use the Los Angeles time zone. + +## Transposing date values + +Sometimes, you want to transpose date values from a date instance to another time zone or vice versa. For that, you would use the `transpose` function: + +```ts +import { transpose } from "date-fns"; +import { tz } from "@date-fns/tz"; + +// Singapore is the system time zone: +const sgDate = new Date(2024, 8 /* Sep */, 7, 6, 5, 4); +//=> 'Wed Sep 07 2024 06:05:04 GMT+0800 (Singapore Standard Time)' + +// Transpose the date to Los Angeles time zone: +const laDate = transpose(sgDate, tz("America/Los_Angeles")); +//=> 'Wed Sep 07 2024 06:05:04 GMT-0700 (Pacific Daylight Time)' + +// Transpose back to local time zone using Date: +const systemDate = transpose(laDate, Date); +//=> 'Wed Sep 07 2024 06:05:04 GMT+0800 (Singapore Standard Time)' +``` + +This is the `date-fns-tz`'s `fromZonedTime` and `toZonedTime` equivalent. + +## Further reading + +Read more about the time zone packages visiting their READMEs: + +- [`@date-fns/tz`] +- [`@date-fns/utc`] + +[`@date-fns/tz`]: https://github.com/date-fns/tz +[`@date-fns/utc`]: https://github.com/date-fns/utc diff --git a/node_modules/date-fns/docs/unicodeTokens.md b/node_modules/date-fns/docs/unicodeTokens.md new file mode 100644 index 0000000000000000000000000000000000000000..c5c926cb1a5bb7ab116c32bb3075f3ca6c1b87d0 --- /dev/null +++ b/node_modules/date-fns/docs/unicodeTokens.md @@ -0,0 +1,54 @@ +# Unicode Tokens + +Starting with v2, `format` and `parse` use [Unicode tokens]. + +The tokens are different from Moment.js and other libraries that opted to use +custom formatting rules. While usage of a standard ensures compatibility and +the future of the library, it causes confusion that this document intends +to resolve. + +## Popular mistakes + +There are 4 tokens that cause most of the confusion: + +- `D` and `DD` that represent the day of a year (1, 2, ..., 365, 366) + are often confused with `d` and `dd` that represent the day of a month + (1, 2, ..., 31). + +- `YY` and `YYYY` that represent the local week-numbering year (44, 01, 00, 17) + are often confused with `yy` and `yyyy` that represent the calendar year. + +```js +// ❌ Wrong! +format(new Date(), "YYYY-MM-DD"); +//=> 2018-10-283 + +// ✅ Correct +format(new Date(), "yyyy-MM-dd"); +//=> 2018-10-10 + +// ❌ Wrong! +parse("11.02.87", "D.MM.YY", new Date()).toString(); +//=> 'Sat Jan 11 1986 00:00:00 GMT+0200 (EET)' + +// ✅ Correct +parse("11.02.87", "d.MM.yy", new Date()).toString(); +//=> 'Wed Feb 11 1987 00:00:00 GMT+0200 (EET)' +``` + +To help with the issue, `format` and `parse` functions won't accept +these tokens without `useAdditionalDayOfYearTokens` option for `D` and `DD` and +`useAdditionalWeekYearTokens` options for `YY` and `YYYY`: + +```js +format(new Date(), "D", { useAdditionalDayOfYearTokens: true }); +//=> '283' + +parse("365+1987", "DD+YYYY", new Date(), { + useAdditionalDayOfYearTokens: true, + useAdditionalWeekYearTokens: true, +}).toString(); +//=> 'Wed Dec 31 1986 00:00:00 GMT+0200 (EET)' +``` + +[Unicode tokens]: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table diff --git a/node_modules/date-fns/docs/webpack.md b/node_modules/date-fns/docs/webpack.md new file mode 100644 index 0000000000000000000000000000000000000000..ab756f72035d51ccc467c7b60171eed3765aaa61 --- /dev/null +++ b/node_modules/date-fns/docs/webpack.md @@ -0,0 +1,53 @@ +# webpack + +## Removing unused languages from dynamic import + +If a locale is imported dynamically, then all locales from date-fns are loaded by webpack into a bundle (~160kb) or split across the chunks. This prolongs the build process and increases the amount of space taken. However, it is possible to use webpack to trim down languages using [ContextReplacementPlugin]. + +Let's assume that we have a single point in which supported locales are present: + +`config.js`: + +```js +// `see date-fns/src/locale` for available locales +export const supportedLocales = ["en-US", "de", "pl", "it"]; +``` + +We could also have a function that formats the date: + +```js +const getLocale = (locale) => import(`date-fns-locale/locale/${locale}.js`); // or require() if using CommonJS + +const formatDate = (date, formatStyle, locale) => { + return format(date, formatStyle, { + locale: getLocale(locale).default, + }); +}; +``` + +In order to exclude unused languages we can use webpacks [ContextReplacementPlugin]. + +`webpack.config.js`: + +```js +import webpack from "webpack"; +import { supportedLocales } from "./config.js"; + +export default config = { + resolve: { + alias: { + "date-fns-locale": path.dirname(require.resolve("date-fns/package.json")), + }, + }, + plugins: [ + new webpack.ContextReplacementPlugin( + /date-fns[/\\]locale/, + new RegExp(`(${locales.join("|")})\.js$`), + ), + ], +}; +``` + +This results in a language bundle of ~23kb . + +[contextreplacementplugin]: https://webpack.js.org/plugins/context-replacement-plugin/ diff --git a/node_modules/date-fns/eachDayOfInterval.cjs b/node_modules/date-fns/eachDayOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..7cd40c1966f52fddd7973401adce3a64887774ce --- /dev/null +++ b/node_modules/date-fns/eachDayOfInterval.cjs @@ -0,0 +1,71 @@ +"use strict"; +exports.eachDayOfInterval = eachDayOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./constructFrom.cjs"); + +/** + * The {@link eachDayOfInterval} function options. + */ + +/** + * The {@link eachDayOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachDayOfInterval + * @category Interval Helpers + * @summary Return the array of dates within the specified time interval. + * + * @description + * Return the array of dates within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of days from the day of the interval start to the day of the interval end + * + * @example + * // Each day between 6 October 2014 and 10 October 2014: + * const result = eachDayOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 9, 10) + * }) + * //=> [ + * // Mon Oct 06 2014 00:00:00, + * // Tue Oct 07 2014 00:00:00, + * // Wed Oct 08 2014 00:00:00, + * // Thu Oct 09 2014 00:00:00, + * // Fri Oct 10 2014 00:00:00 + * // ] + */ +function eachDayOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setHours(0, 0, 0, 0); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push((0, _index2.constructFrom)(start, date)); + date.setDate(date.getDate() + step); + date.setHours(0, 0, 0, 0); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachDayOfInterval.d.cts b/node_modules/date-fns/eachDayOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..b671ae41e4b49bb9562bc5449bd4cbd8cc4ebcde --- /dev/null +++ b/node_modules/date-fns/eachDayOfInterval.d.cts @@ -0,0 +1,62 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachDayOfInterval} function options. + */ +export interface EachDayOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachDayOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachDayOfIntervalResult< + IntervalType extends Interval, + Options extends EachDayOfIntervalOptions | undefined, +> = Array< + Options extends EachDayOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachDayOfInterval + * @category Interval Helpers + * @summary Return the array of dates within the specified time interval. + * + * @description + * Return the array of dates within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of days from the day of the interval start to the day of the interval end + * + * @example + * // Each day between 6 October 2014 and 10 October 2014: + * const result = eachDayOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 9, 10) + * }) + * //=> [ + * // Mon Oct 06 2014 00:00:00, + * // Tue Oct 07 2014 00:00:00, + * // Wed Oct 08 2014 00:00:00, + * // Thu Oct 09 2014 00:00:00, + * // Fri Oct 10 2014 00:00:00 + * // ] + */ +export declare function eachDayOfInterval< + IntervalType extends Interval, + Options extends EachDayOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachDayOfIntervalResult; diff --git a/node_modules/date-fns/eachDayOfInterval.d.ts b/node_modules/date-fns/eachDayOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b671ae41e4b49bb9562bc5449bd4cbd8cc4ebcde --- /dev/null +++ b/node_modules/date-fns/eachDayOfInterval.d.ts @@ -0,0 +1,62 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachDayOfInterval} function options. + */ +export interface EachDayOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachDayOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachDayOfIntervalResult< + IntervalType extends Interval, + Options extends EachDayOfIntervalOptions | undefined, +> = Array< + Options extends EachDayOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachDayOfInterval + * @category Interval Helpers + * @summary Return the array of dates within the specified time interval. + * + * @description + * Return the array of dates within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of days from the day of the interval start to the day of the interval end + * + * @example + * // Each day between 6 October 2014 and 10 October 2014: + * const result = eachDayOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 9, 10) + * }) + * //=> [ + * // Mon Oct 06 2014 00:00:00, + * // Tue Oct 07 2014 00:00:00, + * // Wed Oct 08 2014 00:00:00, + * // Thu Oct 09 2014 00:00:00, + * // Fri Oct 10 2014 00:00:00 + * // ] + */ +export declare function eachDayOfInterval< + IntervalType extends Interval, + Options extends EachDayOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachDayOfIntervalResult; diff --git a/node_modules/date-fns/eachDayOfInterval.js b/node_modules/date-fns/eachDayOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..65a2c1a4a71943399745a5b00ffd064e811c5e56 --- /dev/null +++ b/node_modules/date-fns/eachDayOfInterval.js @@ -0,0 +1,72 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { constructFrom } from "./constructFrom.js"; + +/** + * The {@link eachDayOfInterval} function options. + */ + +/** + * The {@link eachDayOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachDayOfInterval + * @category Interval Helpers + * @summary Return the array of dates within the specified time interval. + * + * @description + * Return the array of dates within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of days from the day of the interval start to the day of the interval end + * + * @example + * // Each day between 6 October 2014 and 10 October 2014: + * const result = eachDayOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 9, 10) + * }) + * //=> [ + * // Mon Oct 06 2014 00:00:00, + * // Tue Oct 07 2014 00:00:00, + * // Wed Oct 08 2014 00:00:00, + * // Thu Oct 09 2014 00:00:00, + * // Fri Oct 10 2014 00:00:00 + * // ] + */ +export function eachDayOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setHours(0, 0, 0, 0); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push(constructFrom(start, date)); + date.setDate(date.getDate() + step); + date.setHours(0, 0, 0, 0); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachDayOfInterval; diff --git a/node_modules/date-fns/eachHourOfInterval.cjs b/node_modules/date-fns/eachHourOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..464177174b3e286caf7b49f2fec355e39a20e103 --- /dev/null +++ b/node_modules/date-fns/eachHourOfInterval.cjs @@ -0,0 +1,67 @@ +"use strict"; +exports.eachHourOfInterval = eachHourOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./constructFrom.cjs"); + +/** + * The {@link eachHourOfInterval} function options. + */ + +/** + * The {@link eachHourOfInterval} function result type. + * Resolves to the appropriate date type based on inputs. + */ + +/** + * @name eachHourOfInterval + * @category Interval Helpers + * @summary Return the array of hours within the specified time interval. + * + * @description + * Return the array of hours within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of hours from the hour of the interval start to the hour of the interval end + * + * @example + * // Each hour between 6 October 2014, 12:00 and 6 October 2014, 15:00 + * const result = eachHourOfInterval({ + * start: new Date(2014, 9, 6, 12), + * end: new Date(2014, 9, 6, 15) + * }); + * //=> [ + * // Mon Oct 06 2014 12:00:00, + * // Mon Oct 06 2014 13:00:00, + * // Mon Oct 06 2014 14:00:00, + * // Mon Oct 06 2014 15:00:00 + * // ] + */ +function eachHourOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setMinutes(0, 0, 0); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push((0, _index2.constructFrom)(start, date)); + date.setHours(date.getHours() + step); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachHourOfInterval.d.cts b/node_modules/date-fns/eachHourOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..e4aba97e6284fd24bec484b5f7f2feedf8a5342c --- /dev/null +++ b/node_modules/date-fns/eachHourOfInterval.d.cts @@ -0,0 +1,59 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachHourOfInterval} function options. + */ +export interface EachHourOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachHourOfInterval} function result type. + * Resolves to the appropriate date type based on inputs. + */ +export type EachHourOfIntervalResult< + IntervalType extends Interval, + Options extends EachHourOfIntervalOptions | undefined, +> = Array< + Options extends EachHourOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachHourOfInterval + * @category Interval Helpers + * @summary Return the array of hours within the specified time interval. + * + * @description + * Return the array of hours within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of hours from the hour of the interval start to the hour of the interval end + * + * @example + * // Each hour between 6 October 2014, 12:00 and 6 October 2014, 15:00 + * const result = eachHourOfInterval({ + * start: new Date(2014, 9, 6, 12), + * end: new Date(2014, 9, 6, 15) + * }); + * //=> [ + * // Mon Oct 06 2014 12:00:00, + * // Mon Oct 06 2014 13:00:00, + * // Mon Oct 06 2014 14:00:00, + * // Mon Oct 06 2014 15:00:00 + * // ] + */ +export declare function eachHourOfInterval< + IntervalType extends Interval, + Options extends EachHourOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachHourOfIntervalResult; diff --git a/node_modules/date-fns/eachHourOfInterval.d.ts b/node_modules/date-fns/eachHourOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4aba97e6284fd24bec484b5f7f2feedf8a5342c --- /dev/null +++ b/node_modules/date-fns/eachHourOfInterval.d.ts @@ -0,0 +1,59 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachHourOfInterval} function options. + */ +export interface EachHourOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachHourOfInterval} function result type. + * Resolves to the appropriate date type based on inputs. + */ +export type EachHourOfIntervalResult< + IntervalType extends Interval, + Options extends EachHourOfIntervalOptions | undefined, +> = Array< + Options extends EachHourOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachHourOfInterval + * @category Interval Helpers + * @summary Return the array of hours within the specified time interval. + * + * @description + * Return the array of hours within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of hours from the hour of the interval start to the hour of the interval end + * + * @example + * // Each hour between 6 October 2014, 12:00 and 6 October 2014, 15:00 + * const result = eachHourOfInterval({ + * start: new Date(2014, 9, 6, 12), + * end: new Date(2014, 9, 6, 15) + * }); + * //=> [ + * // Mon Oct 06 2014 12:00:00, + * // Mon Oct 06 2014 13:00:00, + * // Mon Oct 06 2014 14:00:00, + * // Mon Oct 06 2014 15:00:00 + * // ] + */ +export declare function eachHourOfInterval< + IntervalType extends Interval, + Options extends EachHourOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachHourOfIntervalResult; diff --git a/node_modules/date-fns/eachHourOfInterval.js b/node_modules/date-fns/eachHourOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8dd3a1211855f18d73018f946cb84c87300bd1 --- /dev/null +++ b/node_modules/date-fns/eachHourOfInterval.js @@ -0,0 +1,68 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { constructFrom } from "./constructFrom.js"; + +/** + * The {@link eachHourOfInterval} function options. + */ + +/** + * The {@link eachHourOfInterval} function result type. + * Resolves to the appropriate date type based on inputs. + */ + +/** + * @name eachHourOfInterval + * @category Interval Helpers + * @summary Return the array of hours within the specified time interval. + * + * @description + * Return the array of hours within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of hours from the hour of the interval start to the hour of the interval end + * + * @example + * // Each hour between 6 October 2014, 12:00 and 6 October 2014, 15:00 + * const result = eachHourOfInterval({ + * start: new Date(2014, 9, 6, 12), + * end: new Date(2014, 9, 6, 15) + * }); + * //=> [ + * // Mon Oct 06 2014 12:00:00, + * // Mon Oct 06 2014 13:00:00, + * // Mon Oct 06 2014 14:00:00, + * // Mon Oct 06 2014 15:00:00 + * // ] + */ +export function eachHourOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setMinutes(0, 0, 0); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push(constructFrom(start, date)); + date.setHours(date.getHours() + step); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachHourOfInterval; diff --git a/node_modules/date-fns/eachMinuteOfInterval.cjs b/node_modules/date-fns/eachMinuteOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..3dcc64c1b9c6fe8ae992986b937e3fe235d8bce0 --- /dev/null +++ b/node_modules/date-fns/eachMinuteOfInterval.cjs @@ -0,0 +1,71 @@ +"use strict"; +exports.eachMinuteOfInterval = eachMinuteOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./addMinutes.cjs"); +var _index3 = require("./constructFrom.cjs"); + +/** + * The {@link eachMinuteOfInterval} function options. + */ + +/** + * The {@link eachMinuteOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachMinuteOfInterval + * @category Interval Helpers + * @summary Return the array of minutes within the specified time interval. + * + * @description + * Returns the array of minutes within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of minutes from the minute of the interval start to the minute of the interval end + * + * @example + * // Each minute between 14 October 2020, 13:00 and 14 October 2020, 13:03 + * const result = eachMinuteOfInterval({ + * start: new Date(2014, 9, 14, 13), + * end: new Date(2014, 9, 14, 13, 3) + * }) + * //=> [ + * // Wed Oct 14 2014 13:00:00, + * // Wed Oct 14 2014 13:01:00, + * // Wed Oct 14 2014 13:02:00, + * // Wed Oct 14 2014 13:03:00 + * // ] + */ +function eachMinuteOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + // Set to the start of the minute + start.setSeconds(0, 0); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + let date = reversed ? end : start; + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push((0, _index3.constructFrom)(start, date)); + date = (0, _index2.addMinutes)(date, step); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachMinuteOfInterval.d.cts b/node_modules/date-fns/eachMinuteOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..eda61b0bbfae41bfbc107ea486814478363fc749 --- /dev/null +++ b/node_modules/date-fns/eachMinuteOfInterval.d.cts @@ -0,0 +1,61 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachMinuteOfInterval} function options. + */ +export interface EachMinuteOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachMinuteOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachMinuteOfIntervalResult< + IntervalType extends Interval, + Options extends EachMinuteOfIntervalOptions | undefined, +> = Array< + Options extends EachMinuteOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachMinuteOfInterval + * @category Interval Helpers + * @summary Return the array of minutes within the specified time interval. + * + * @description + * Returns the array of minutes within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of minutes from the minute of the interval start to the minute of the interval end + * + * @example + * // Each minute between 14 October 2020, 13:00 and 14 October 2020, 13:03 + * const result = eachMinuteOfInterval({ + * start: new Date(2014, 9, 14, 13), + * end: new Date(2014, 9, 14, 13, 3) + * }) + * //=> [ + * // Wed Oct 14 2014 13:00:00, + * // Wed Oct 14 2014 13:01:00, + * // Wed Oct 14 2014 13:02:00, + * // Wed Oct 14 2014 13:03:00 + * // ] + */ +export declare function eachMinuteOfInterval< + IntervalType extends Interval, + Options extends EachMinuteOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachMinuteOfIntervalResult; diff --git a/node_modules/date-fns/eachMinuteOfInterval.d.ts b/node_modules/date-fns/eachMinuteOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eda61b0bbfae41bfbc107ea486814478363fc749 --- /dev/null +++ b/node_modules/date-fns/eachMinuteOfInterval.d.ts @@ -0,0 +1,61 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachMinuteOfInterval} function options. + */ +export interface EachMinuteOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachMinuteOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachMinuteOfIntervalResult< + IntervalType extends Interval, + Options extends EachMinuteOfIntervalOptions | undefined, +> = Array< + Options extends EachMinuteOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachMinuteOfInterval + * @category Interval Helpers + * @summary Return the array of minutes within the specified time interval. + * + * @description + * Returns the array of minutes within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of minutes from the minute of the interval start to the minute of the interval end + * + * @example + * // Each minute between 14 October 2020, 13:00 and 14 October 2020, 13:03 + * const result = eachMinuteOfInterval({ + * start: new Date(2014, 9, 14, 13), + * end: new Date(2014, 9, 14, 13, 3) + * }) + * //=> [ + * // Wed Oct 14 2014 13:00:00, + * // Wed Oct 14 2014 13:01:00, + * // Wed Oct 14 2014 13:02:00, + * // Wed Oct 14 2014 13:03:00 + * // ] + */ +export declare function eachMinuteOfInterval< + IntervalType extends Interval, + Options extends EachMinuteOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachMinuteOfIntervalResult; diff --git a/node_modules/date-fns/eachMinuteOfInterval.js b/node_modules/date-fns/eachMinuteOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..2c9d5900df7ca8b2fe687e1ae4ac104e2549188f --- /dev/null +++ b/node_modules/date-fns/eachMinuteOfInterval.js @@ -0,0 +1,72 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { addMinutes } from "./addMinutes.js"; +import { constructFrom } from "./constructFrom.js"; + +/** + * The {@link eachMinuteOfInterval} function options. + */ + +/** + * The {@link eachMinuteOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachMinuteOfInterval + * @category Interval Helpers + * @summary Return the array of minutes within the specified time interval. + * + * @description + * Returns the array of minutes within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of minutes from the minute of the interval start to the minute of the interval end + * + * @example + * // Each minute between 14 October 2020, 13:00 and 14 October 2020, 13:03 + * const result = eachMinuteOfInterval({ + * start: new Date(2014, 9, 14, 13), + * end: new Date(2014, 9, 14, 13, 3) + * }) + * //=> [ + * // Wed Oct 14 2014 13:00:00, + * // Wed Oct 14 2014 13:01:00, + * // Wed Oct 14 2014 13:02:00, + * // Wed Oct 14 2014 13:03:00 + * // ] + */ +export function eachMinuteOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + // Set to the start of the minute + start.setSeconds(0, 0); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + let date = reversed ? end : start; + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push(constructFrom(start, date)); + date = addMinutes(date, step); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachMinuteOfInterval; diff --git a/node_modules/date-fns/eachMonthOfInterval.cjs b/node_modules/date-fns/eachMonthOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..b4b4c152c537270131acb21225334a78f18ecc7e --- /dev/null +++ b/node_modules/date-fns/eachMonthOfInterval.cjs @@ -0,0 +1,70 @@ +"use strict"; +exports.eachMonthOfInterval = eachMonthOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./constructFrom.cjs"); + +/** + * The {@link eachMonthOfInterval} function options. + */ + +/** + * The {@link eachMonthOfInterval} function result type. It resolves the proper data type. + */ + +/** + * @name eachMonthOfInterval + * @category Interval Helpers + * @summary Return the array of months within the specified time interval. + * + * @description + * Return the array of months within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of months from the month of the interval start to the month of the interval end + * + * @example + * // Each month between 6 February 2014 and 10 August 2014: + * const result = eachMonthOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10) + * }) + * //=> [ + * // Sat Feb 01 2014 00:00:00, + * // Sat Mar 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Thu May 01 2014 00:00:00, + * // Sun Jun 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // Fri Aug 01 2014 00:00:00 + * // ] + */ +function eachMonthOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setHours(0, 0, 0, 0); + date.setDate(1); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push((0, _index2.constructFrom)(start, date)); + date.setMonth(date.getMonth() + step); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachMonthOfInterval.d.cts b/node_modules/date-fns/eachMonthOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..0bbdc608c61edcf2e59d2bc62ea1a6148de3bd0d --- /dev/null +++ b/node_modules/date-fns/eachMonthOfInterval.d.cts @@ -0,0 +1,61 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachMonthOfInterval} function options. + */ +export interface EachMonthOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachMonthOfInterval} function result type. It resolves the proper data type. + */ +export type EachMonthOfIntervalResult< + IntervalType extends Interval, + Options extends EachMonthOfIntervalOptions | undefined, +> = Array< + Options extends EachMonthOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachMonthOfInterval + * @category Interval Helpers + * @summary Return the array of months within the specified time interval. + * + * @description + * Return the array of months within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of months from the month of the interval start to the month of the interval end + * + * @example + * // Each month between 6 February 2014 and 10 August 2014: + * const result = eachMonthOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10) + * }) + * //=> [ + * // Sat Feb 01 2014 00:00:00, + * // Sat Mar 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Thu May 01 2014 00:00:00, + * // Sun Jun 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // Fri Aug 01 2014 00:00:00 + * // ] + */ +export declare function eachMonthOfInterval< + IntervalType extends Interval, + Options extends EachMonthOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachMonthOfIntervalResult; diff --git a/node_modules/date-fns/eachMonthOfInterval.d.ts b/node_modules/date-fns/eachMonthOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0bbdc608c61edcf2e59d2bc62ea1a6148de3bd0d --- /dev/null +++ b/node_modules/date-fns/eachMonthOfInterval.d.ts @@ -0,0 +1,61 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachMonthOfInterval} function options. + */ +export interface EachMonthOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachMonthOfInterval} function result type. It resolves the proper data type. + */ +export type EachMonthOfIntervalResult< + IntervalType extends Interval, + Options extends EachMonthOfIntervalOptions | undefined, +> = Array< + Options extends EachMonthOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachMonthOfInterval + * @category Interval Helpers + * @summary Return the array of months within the specified time interval. + * + * @description + * Return the array of months within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of months from the month of the interval start to the month of the interval end + * + * @example + * // Each month between 6 February 2014 and 10 August 2014: + * const result = eachMonthOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10) + * }) + * //=> [ + * // Sat Feb 01 2014 00:00:00, + * // Sat Mar 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Thu May 01 2014 00:00:00, + * // Sun Jun 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // Fri Aug 01 2014 00:00:00 + * // ] + */ +export declare function eachMonthOfInterval< + IntervalType extends Interval, + Options extends EachMonthOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachMonthOfIntervalResult; diff --git a/node_modules/date-fns/eachMonthOfInterval.js b/node_modules/date-fns/eachMonthOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..4671df83dac3794b0d05a9ac9de5a9c91d98adc5 --- /dev/null +++ b/node_modules/date-fns/eachMonthOfInterval.js @@ -0,0 +1,71 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { constructFrom } from "./constructFrom.js"; + +/** + * The {@link eachMonthOfInterval} function options. + */ + +/** + * The {@link eachMonthOfInterval} function result type. It resolves the proper data type. + */ + +/** + * @name eachMonthOfInterval + * @category Interval Helpers + * @summary Return the array of months within the specified time interval. + * + * @description + * Return the array of months within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of months from the month of the interval start to the month of the interval end + * + * @example + * // Each month between 6 February 2014 and 10 August 2014: + * const result = eachMonthOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10) + * }) + * //=> [ + * // Sat Feb 01 2014 00:00:00, + * // Sat Mar 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Thu May 01 2014 00:00:00, + * // Sun Jun 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // Fri Aug 01 2014 00:00:00 + * // ] + */ +export function eachMonthOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setHours(0, 0, 0, 0); + date.setDate(1); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push(constructFrom(start, date)); + date.setMonth(date.getMonth() + step); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachMonthOfInterval; diff --git a/node_modules/date-fns/eachQuarterOfInterval.cjs b/node_modules/date-fns/eachQuarterOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..119221a6626c9e686b41ac0d74e5cbe82b0699bf --- /dev/null +++ b/node_modules/date-fns/eachQuarterOfInterval.cjs @@ -0,0 +1,73 @@ +"use strict"; +exports.eachQuarterOfInterval = eachQuarterOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./addQuarters.cjs"); +var _index3 = require("./constructFrom.cjs"); +var _index4 = require("./startOfQuarter.cjs"); + +/** + * The {@link eachQuarterOfInterval} function options. + */ + +/** + * The {@link eachQuarterOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachQuarterOfInterval + * @category Interval Helpers + * @summary Return the array of quarters within the specified time interval. + * + * @description + * Return the array of quarters within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval + * @param options - An object with options + * + * @returns The array with starts of quarters from the quarter of the interval start to the quarter of the interval end + * + * @example + * // Each quarter within interval 6 February 2014 - 10 August 2014: + * const result = eachQuarterOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10), + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // ] + */ +function eachQuarterOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed + ? +(0, _index4.startOfQuarter)(start) + : +(0, _index4.startOfQuarter)(end); + let date = reversed + ? (0, _index4.startOfQuarter)(end) + : (0, _index4.startOfQuarter)(start); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push((0, _index3.constructFrom)(start, date)); + date = (0, _index2.addQuarters)(date, step); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachQuarterOfInterval.d.cts b/node_modules/date-fns/eachQuarterOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..52d0db6a018e70ac08f24bf9fe5799b85f9c1fd1 --- /dev/null +++ b/node_modules/date-fns/eachQuarterOfInterval.d.cts @@ -0,0 +1,60 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachQuarterOfInterval} function options. + */ +export interface EachQuarterOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachQuarterOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachQuarterOfIntervalResult< + IntervalType extends Interval, + Options extends EachQuarterOfIntervalOptions | undefined, +> = Array< + Options extends EachQuarterOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachQuarterOfInterval + * @category Interval Helpers + * @summary Return the array of quarters within the specified time interval. + * + * @description + * Return the array of quarters within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval + * @param options - An object with options + * + * @returns The array with starts of quarters from the quarter of the interval start to the quarter of the interval end + * + * @example + * // Each quarter within interval 6 February 2014 - 10 August 2014: + * const result = eachQuarterOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10), + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // ] + */ +export declare function eachQuarterOfInterval< + IntervalType extends Interval, + Options extends EachQuarterOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachQuarterOfIntervalResult; diff --git a/node_modules/date-fns/eachQuarterOfInterval.d.ts b/node_modules/date-fns/eachQuarterOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52d0db6a018e70ac08f24bf9fe5799b85f9c1fd1 --- /dev/null +++ b/node_modules/date-fns/eachQuarterOfInterval.d.ts @@ -0,0 +1,60 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachQuarterOfInterval} function options. + */ +export interface EachQuarterOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachQuarterOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachQuarterOfIntervalResult< + IntervalType extends Interval, + Options extends EachQuarterOfIntervalOptions | undefined, +> = Array< + Options extends EachQuarterOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachQuarterOfInterval + * @category Interval Helpers + * @summary Return the array of quarters within the specified time interval. + * + * @description + * Return the array of quarters within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval + * @param options - An object with options + * + * @returns The array with starts of quarters from the quarter of the interval start to the quarter of the interval end + * + * @example + * // Each quarter within interval 6 February 2014 - 10 August 2014: + * const result = eachQuarterOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10), + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // ] + */ +export declare function eachQuarterOfInterval< + IntervalType extends Interval, + Options extends EachQuarterOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachQuarterOfIntervalResult; diff --git a/node_modules/date-fns/eachQuarterOfInterval.js b/node_modules/date-fns/eachQuarterOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..f834b0d2dbfc08012a8f166d5e76ea71ba76ca6a --- /dev/null +++ b/node_modules/date-fns/eachQuarterOfInterval.js @@ -0,0 +1,70 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { addQuarters } from "./addQuarters.js"; +import { constructFrom } from "./constructFrom.js"; +import { startOfQuarter } from "./startOfQuarter.js"; + +/** + * The {@link eachQuarterOfInterval} function options. + */ + +/** + * The {@link eachQuarterOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachQuarterOfInterval + * @category Interval Helpers + * @summary Return the array of quarters within the specified time interval. + * + * @description + * Return the array of quarters within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval + * @param options - An object with options + * + * @returns The array with starts of quarters from the quarter of the interval start to the quarter of the interval end + * + * @example + * // Each quarter within interval 6 February 2014 - 10 August 2014: + * const result = eachQuarterOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2014, 7, 10), + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Tue Apr 01 2014 00:00:00, + * // Tue Jul 01 2014 00:00:00, + * // ] + */ +export function eachQuarterOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +startOfQuarter(start) : +startOfQuarter(end); + let date = reversed ? startOfQuarter(end) : startOfQuarter(start); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push(constructFrom(start, date)); + date = addQuarters(date, step); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachQuarterOfInterval; diff --git a/node_modules/date-fns/eachWeekOfInterval.cjs b/node_modules/date-fns/eachWeekOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..84e10ebdfe1ce59a7ead9469af9ea757dfb4c308 --- /dev/null +++ b/node_modules/date-fns/eachWeekOfInterval.cjs @@ -0,0 +1,82 @@ +"use strict"; +exports.eachWeekOfInterval = eachWeekOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./addWeeks.cjs"); +var _index3 = require("./constructFrom.cjs"); +var _index4 = require("./startOfWeek.cjs"); + +/** + * The {@link eachWeekOfInterval} function options. + */ + +/** + * The {@link eachWeekOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the interval start date, + * then the end interval date. If a context function is passed, it uses the context function return type. + */ + +/** + * @name eachWeekOfInterval + * @category Interval Helpers + * @summary Return the array of weeks within the specified time interval. + * + * @description + * Return the array of weeks within the specified time interval. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of weeks from the week of the interval start to the week of the interval end + * + * @example + * // Each week within interval 6 October 2014 - 23 November 2014: + * const result = eachWeekOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 10, 23) + * }) + * //=> [ + * // Sun Oct 05 2014 00:00:00, + * // Sun Oct 12 2014 00:00:00, + * // Sun Oct 19 2014 00:00:00, + * // Sun Oct 26 2014 00:00:00, + * // Sun Nov 02 2014 00:00:00, + * // Sun Nov 09 2014 00:00:00, + * // Sun Nov 16 2014 00:00:00, + * // Sun Nov 23 2014 00:00:00 + * // ] + */ +function eachWeekOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + + let reversed = +start > +end; + const startDateWeek = reversed + ? (0, _index4.startOfWeek)(end, options) + : (0, _index4.startOfWeek)(start, options); + const endDateWeek = reversed + ? (0, _index4.startOfWeek)(start, options) + : (0, _index4.startOfWeek)(end, options); + + startDateWeek.setHours(15); + endDateWeek.setHours(15); + + const endTime = +endDateWeek.getTime(); + let currentDate = startDateWeek; + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+currentDate <= endTime) { + currentDate.setHours(0); + dates.push((0, _index3.constructFrom)(start, currentDate)); + currentDate = (0, _index2.addWeeks)(currentDate, step); + currentDate.setHours(15); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachWeekOfInterval.d.cts b/node_modules/date-fns/eachWeekOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..1f3fcceaf139e4a890ba307b338e5702f83d4ad9 --- /dev/null +++ b/node_modules/date-fns/eachWeekOfInterval.d.cts @@ -0,0 +1,69 @@ +import type { + ContextOptions, + Interval, + LocalizedOptions, + StepOptions, + WeekOptions, +} from "./types.ts"; +/** + * The {@link eachWeekOfInterval} function options. + */ +export interface EachWeekOfIntervalOptions + extends StepOptions, + WeekOptions, + LocalizedOptions<"options">, + ContextOptions {} +/** + * The {@link eachWeekOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the interval start date, + * then the end interval date. If a context function is passed, it uses the context function return type. + */ +export type EachWeekOfIntervalResult< + IntervalType extends Interval, + Options extends EachWeekOfIntervalOptions | undefined, +> = Array< + Options extends EachWeekOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachWeekOfInterval + * @category Interval Helpers + * @summary Return the array of weeks within the specified time interval. + * + * @description + * Return the array of weeks within the specified time interval. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of weeks from the week of the interval start to the week of the interval end + * + * @example + * // Each week within interval 6 October 2014 - 23 November 2014: + * const result = eachWeekOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 10, 23) + * }) + * //=> [ + * // Sun Oct 05 2014 00:00:00, + * // Sun Oct 12 2014 00:00:00, + * // Sun Oct 19 2014 00:00:00, + * // Sun Oct 26 2014 00:00:00, + * // Sun Nov 02 2014 00:00:00, + * // Sun Nov 09 2014 00:00:00, + * // Sun Nov 16 2014 00:00:00, + * // Sun Nov 23 2014 00:00:00 + * // ] + */ +export declare function eachWeekOfInterval< + IntervalType extends Interval, + Options extends EachWeekOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachWeekOfIntervalResult; diff --git a/node_modules/date-fns/eachWeekOfInterval.d.ts b/node_modules/date-fns/eachWeekOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f3fcceaf139e4a890ba307b338e5702f83d4ad9 --- /dev/null +++ b/node_modules/date-fns/eachWeekOfInterval.d.ts @@ -0,0 +1,69 @@ +import type { + ContextOptions, + Interval, + LocalizedOptions, + StepOptions, + WeekOptions, +} from "./types.ts"; +/** + * The {@link eachWeekOfInterval} function options. + */ +export interface EachWeekOfIntervalOptions + extends StepOptions, + WeekOptions, + LocalizedOptions<"options">, + ContextOptions {} +/** + * The {@link eachWeekOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the interval start date, + * then the end interval date. If a context function is passed, it uses the context function return type. + */ +export type EachWeekOfIntervalResult< + IntervalType extends Interval, + Options extends EachWeekOfIntervalOptions | undefined, +> = Array< + Options extends EachWeekOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachWeekOfInterval + * @category Interval Helpers + * @summary Return the array of weeks within the specified time interval. + * + * @description + * Return the array of weeks within the specified time interval. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of weeks from the week of the interval start to the week of the interval end + * + * @example + * // Each week within interval 6 October 2014 - 23 November 2014: + * const result = eachWeekOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 10, 23) + * }) + * //=> [ + * // Sun Oct 05 2014 00:00:00, + * // Sun Oct 12 2014 00:00:00, + * // Sun Oct 19 2014 00:00:00, + * // Sun Oct 26 2014 00:00:00, + * // Sun Nov 02 2014 00:00:00, + * // Sun Nov 09 2014 00:00:00, + * // Sun Nov 16 2014 00:00:00, + * // Sun Nov 23 2014 00:00:00 + * // ] + */ +export declare function eachWeekOfInterval< + IntervalType extends Interval, + Options extends EachWeekOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachWeekOfIntervalResult; diff --git a/node_modules/date-fns/eachWeekOfInterval.js b/node_modules/date-fns/eachWeekOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..ffc0073b89ca3c362cc425b5727cd283186c5f0a --- /dev/null +++ b/node_modules/date-fns/eachWeekOfInterval.js @@ -0,0 +1,83 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { addWeeks } from "./addWeeks.js"; +import { constructFrom } from "./constructFrom.js"; +import { startOfWeek } from "./startOfWeek.js"; + +/** + * The {@link eachWeekOfInterval} function options. + */ + +/** + * The {@link eachWeekOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the interval start date, + * then the end interval date. If a context function is passed, it uses the context function return type. + */ + +/** + * @name eachWeekOfInterval + * @category Interval Helpers + * @summary Return the array of weeks within the specified time interval. + * + * @description + * Return the array of weeks within the specified time interval. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of weeks from the week of the interval start to the week of the interval end + * + * @example + * // Each week within interval 6 October 2014 - 23 November 2014: + * const result = eachWeekOfInterval({ + * start: new Date(2014, 9, 6), + * end: new Date(2014, 10, 23) + * }) + * //=> [ + * // Sun Oct 05 2014 00:00:00, + * // Sun Oct 12 2014 00:00:00, + * // Sun Oct 19 2014 00:00:00, + * // Sun Oct 26 2014 00:00:00, + * // Sun Nov 02 2014 00:00:00, + * // Sun Nov 09 2014 00:00:00, + * // Sun Nov 16 2014 00:00:00, + * // Sun Nov 23 2014 00:00:00 + * // ] + */ +export function eachWeekOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + + let reversed = +start > +end; + const startDateWeek = reversed + ? startOfWeek(end, options) + : startOfWeek(start, options); + const endDateWeek = reversed + ? startOfWeek(start, options) + : startOfWeek(end, options); + + startDateWeek.setHours(15); + endDateWeek.setHours(15); + + const endTime = +endDateWeek.getTime(); + let currentDate = startDateWeek; + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+currentDate <= endTime) { + currentDate.setHours(0); + dates.push(constructFrom(start, currentDate)); + currentDate = addWeeks(currentDate, step); + currentDate.setHours(15); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachWeekOfInterval; diff --git a/node_modules/date-fns/eachWeekendOfInterval.cjs b/node_modules/date-fns/eachWeekendOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..4f75e0644d1e32e407fc39b14154d6b48cde5041 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfInterval.cjs @@ -0,0 +1,56 @@ +"use strict"; +exports.eachWeekendOfInterval = eachWeekendOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./constructFrom.cjs"); +var _index3 = require("./eachDayOfInterval.cjs"); +var _index4 = require("./isWeekend.cjs"); + +/** + * The {@link eachWeekendOfInterval} function options. + */ + +/** + * The {@link eachWeekendOfInterval} function result type. + */ + +/** + * @name eachWeekendOfInterval + * @category Interval Helpers + * @summary List all the Saturdays and Sundays in the given date interval. + * + * @description + * Get all the Saturdays and Sundays in the given date interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The given interval + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given date interval + * const result = eachWeekendOfInterval({ + * start: new Date(2018, 8, 17), + * end: new Date(2018, 8, 30) + * }) + * //=> [ + * // Sat Sep 22 2018 00:00:00, + * // Sun Sep 23 2018 00:00:00, + * // Sat Sep 29 2018 00:00:00, + * // Sun Sep 30 2018 00:00:00 + * // ] + */ +function eachWeekendOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + const dateInterval = (0, _index3.eachDayOfInterval)({ start, end }, options); + const weekends = []; + let index = 0; + while (index < dateInterval.length) { + const date = dateInterval[index++]; + if ((0, _index4.isWeekend)(date)) + weekends.push((0, _index2.constructFrom)(start, date)); + } + return weekends; +} diff --git a/node_modules/date-fns/eachWeekendOfInterval.d.cts b/node_modules/date-fns/eachWeekendOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..ff4049476ee6d32a899081af7ce53d802969f380 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfInterval.d.cts @@ -0,0 +1,57 @@ +import type { ContextOptions, Interval } from "./types.ts"; +/** + * The {@link eachWeekendOfInterval} function options. + */ +export interface EachWeekendOfIntervalOptions + extends ContextOptions {} +/** + * The {@link eachWeekendOfInterval} function result type. + */ +export type EachWeekendOfIntervalResult< + IntervalType extends Interval, + Options extends EachWeekendOfIntervalOptions | undefined, +> = Array< + Options extends EachWeekendOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachWeekendOfInterval + * @category Interval Helpers + * @summary List all the Saturdays and Sundays in the given date interval. + * + * @description + * Get all the Saturdays and Sundays in the given date interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The given interval + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given date interval + * const result = eachWeekendOfInterval({ + * start: new Date(2018, 8, 17), + * end: new Date(2018, 8, 30) + * }) + * //=> [ + * // Sat Sep 22 2018 00:00:00, + * // Sun Sep 23 2018 00:00:00, + * // Sat Sep 29 2018 00:00:00, + * // Sun Sep 30 2018 00:00:00 + * // ] + */ +export declare function eachWeekendOfInterval< + IntervalType extends Interval, + Options extends EachWeekendOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachWeekendOfIntervalResult; diff --git a/node_modules/date-fns/eachWeekendOfInterval.d.ts b/node_modules/date-fns/eachWeekendOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ff4049476ee6d32a899081af7ce53d802969f380 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfInterval.d.ts @@ -0,0 +1,57 @@ +import type { ContextOptions, Interval } from "./types.ts"; +/** + * The {@link eachWeekendOfInterval} function options. + */ +export interface EachWeekendOfIntervalOptions + extends ContextOptions {} +/** + * The {@link eachWeekendOfInterval} function result type. + */ +export type EachWeekendOfIntervalResult< + IntervalType extends Interval, + Options extends EachWeekendOfIntervalOptions | undefined, +> = Array< + Options extends EachWeekendOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachWeekendOfInterval + * @category Interval Helpers + * @summary List all the Saturdays and Sundays in the given date interval. + * + * @description + * Get all the Saturdays and Sundays in the given date interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The given interval + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given date interval + * const result = eachWeekendOfInterval({ + * start: new Date(2018, 8, 17), + * end: new Date(2018, 8, 30) + * }) + * //=> [ + * // Sat Sep 22 2018 00:00:00, + * // Sun Sep 23 2018 00:00:00, + * // Sat Sep 29 2018 00:00:00, + * // Sun Sep 30 2018 00:00:00 + * // ] + */ +export declare function eachWeekendOfInterval< + IntervalType extends Interval, + Options extends EachWeekendOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachWeekendOfIntervalResult; diff --git a/node_modules/date-fns/eachWeekendOfInterval.js b/node_modules/date-fns/eachWeekendOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..e91afbc61cc79afa32a9b8ffe75069b2a22b532a --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfInterval.js @@ -0,0 +1,56 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { constructFrom } from "./constructFrom.js"; +import { eachDayOfInterval } from "./eachDayOfInterval.js"; +import { isWeekend } from "./isWeekend.js"; + +/** + * The {@link eachWeekendOfInterval} function options. + */ + +/** + * The {@link eachWeekendOfInterval} function result type. + */ + +/** + * @name eachWeekendOfInterval + * @category Interval Helpers + * @summary List all the Saturdays and Sundays in the given date interval. + * + * @description + * Get all the Saturdays and Sundays in the given date interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The given interval + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given date interval + * const result = eachWeekendOfInterval({ + * start: new Date(2018, 8, 17), + * end: new Date(2018, 8, 30) + * }) + * //=> [ + * // Sat Sep 22 2018 00:00:00, + * // Sun Sep 23 2018 00:00:00, + * // Sat Sep 29 2018 00:00:00, + * // Sun Sep 30 2018 00:00:00 + * // ] + */ +export function eachWeekendOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + const dateInterval = eachDayOfInterval({ start, end }, options); + const weekends = []; + let index = 0; + while (index < dateInterval.length) { + const date = dateInterval[index++]; + if (isWeekend(date)) weekends.push(constructFrom(start, date)); + } + return weekends; +} + +// Fallback for modularized imports: +export default eachWeekendOfInterval; diff --git a/node_modules/date-fns/eachWeekendOfMonth.cjs b/node_modules/date-fns/eachWeekendOfMonth.cjs new file mode 100644 index 0000000000000000000000000000000000000000..8b05eb52cec339ed3b1a76df414500503e86e1e9 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfMonth.cjs @@ -0,0 +1,45 @@ +"use strict"; +exports.eachWeekendOfMonth = eachWeekendOfMonth; +var _index = require("./eachWeekendOfInterval.cjs"); +var _index2 = require("./endOfMonth.cjs"); +var _index3 = require("./startOfMonth.cjs"); + +/** + * The {@link eachWeekendOfMonth} function options. + */ + +/** + * @name eachWeekendOfMonth + * @category Month Helpers + * @summary List all the Saturdays and Sundays in the given month. + * + * @description + * Get all the Saturdays and Sundays in the given month. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given month + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given month + * const result = eachWeekendOfMonth(new Date(2022, 1, 1)) + * //=> [ + * // Sat Feb 05 2022 00:00:00, + * // Sun Feb 06 2022 00:00:00, + * // Sat Feb 12 2022 00:00:00, + * // Sun Feb 13 2022 00:00:00, + * // Sat Feb 19 2022 00:00:00, + * // Sun Feb 20 2022 00:00:00, + * // Sat Feb 26 2022 00:00:00, + * // Sun Feb 27 2022 00:00:00 + * // ] + */ +function eachWeekendOfMonth(date, options) { + const start = (0, _index3.startOfMonth)(date, options); + const end = (0, _index2.endOfMonth)(date, options); + return (0, _index.eachWeekendOfInterval)({ start, end }, options); +} diff --git a/node_modules/date-fns/eachWeekendOfMonth.d.cts b/node_modules/date-fns/eachWeekendOfMonth.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..68a6a38b8cc7bd175ecb7fdd74868d36bf1a1a32 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfMonth.d.cts @@ -0,0 +1,43 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link eachWeekendOfMonth} function options. + */ +export interface EachWeekendOfMonthOptions + extends ContextOptions {} +/** + * @name eachWeekendOfMonth + * @category Month Helpers + * @summary List all the Saturdays and Sundays in the given month. + * + * @description + * Get all the Saturdays and Sundays in the given month. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given month + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given month + * const result = eachWeekendOfMonth(new Date(2022, 1, 1)) + * //=> [ + * // Sat Feb 05 2022 00:00:00, + * // Sun Feb 06 2022 00:00:00, + * // Sat Feb 12 2022 00:00:00, + * // Sun Feb 13 2022 00:00:00, + * // Sat Feb 19 2022 00:00:00, + * // Sun Feb 20 2022 00:00:00, + * // Sat Feb 26 2022 00:00:00, + * // Sun Feb 27 2022 00:00:00 + * // ] + */ +export declare function eachWeekendOfMonth< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EachWeekendOfMonthOptions, +): ResultDate[]; diff --git a/node_modules/date-fns/eachWeekendOfMonth.d.ts b/node_modules/date-fns/eachWeekendOfMonth.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..68a6a38b8cc7bd175ecb7fdd74868d36bf1a1a32 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfMonth.d.ts @@ -0,0 +1,43 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link eachWeekendOfMonth} function options. + */ +export interface EachWeekendOfMonthOptions + extends ContextOptions {} +/** + * @name eachWeekendOfMonth + * @category Month Helpers + * @summary List all the Saturdays and Sundays in the given month. + * + * @description + * Get all the Saturdays and Sundays in the given month. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given month + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given month + * const result = eachWeekendOfMonth(new Date(2022, 1, 1)) + * //=> [ + * // Sat Feb 05 2022 00:00:00, + * // Sun Feb 06 2022 00:00:00, + * // Sat Feb 12 2022 00:00:00, + * // Sun Feb 13 2022 00:00:00, + * // Sat Feb 19 2022 00:00:00, + * // Sun Feb 20 2022 00:00:00, + * // Sat Feb 26 2022 00:00:00, + * // Sun Feb 27 2022 00:00:00 + * // ] + */ +export declare function eachWeekendOfMonth< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EachWeekendOfMonthOptions, +): ResultDate[]; diff --git a/node_modules/date-fns/eachWeekendOfMonth.js b/node_modules/date-fns/eachWeekendOfMonth.js new file mode 100644 index 0000000000000000000000000000000000000000..c0d14267c9f9bcaa6e5fcd271e77316c331c946e --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfMonth.js @@ -0,0 +1,46 @@ +import { eachWeekendOfInterval } from "./eachWeekendOfInterval.js"; +import { endOfMonth } from "./endOfMonth.js"; +import { startOfMonth } from "./startOfMonth.js"; + +/** + * The {@link eachWeekendOfMonth} function options. + */ + +/** + * @name eachWeekendOfMonth + * @category Month Helpers + * @summary List all the Saturdays and Sundays in the given month. + * + * @description + * Get all the Saturdays and Sundays in the given month. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given month + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the given month + * const result = eachWeekendOfMonth(new Date(2022, 1, 1)) + * //=> [ + * // Sat Feb 05 2022 00:00:00, + * // Sun Feb 06 2022 00:00:00, + * // Sat Feb 12 2022 00:00:00, + * // Sun Feb 13 2022 00:00:00, + * // Sat Feb 19 2022 00:00:00, + * // Sun Feb 20 2022 00:00:00, + * // Sat Feb 26 2022 00:00:00, + * // Sun Feb 27 2022 00:00:00 + * // ] + */ +export function eachWeekendOfMonth(date, options) { + const start = startOfMonth(date, options); + const end = endOfMonth(date, options); + return eachWeekendOfInterval({ start, end }, options); +} + +// Fallback for modularized imports: +export default eachWeekendOfMonth; diff --git a/node_modules/date-fns/eachWeekendOfYear.cjs b/node_modules/date-fns/eachWeekendOfYear.cjs new file mode 100644 index 0000000000000000000000000000000000000000..823ad56dc59e00403b92597fa28c2511574e6fbe --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfYear.cjs @@ -0,0 +1,42 @@ +"use strict"; +exports.eachWeekendOfYear = eachWeekendOfYear; +var _index = require("./eachWeekendOfInterval.cjs"); +var _index2 = require("./endOfYear.cjs"); +var _index3 = require("./startOfYear.cjs"); + +/** + * The {@link eachWeekendOfYear} function options. + */ + +/** + * @name eachWeekendOfYear + * @category Year Helpers + * @summary List all the Saturdays and Sundays in the year. + * + * @description + * Get all the Saturdays and Sundays in the year. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given year + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the year + * const result = eachWeekendOfYear(new Date(2020, 1, 1)) + * //=> [ + * // Sat Jan 03 2020 00:00:00, + * // Sun Jan 04 2020 00:00:00, + * // ... + * // Sun Dec 27 2020 00:00:00 + * // ] + * ] + */ +function eachWeekendOfYear(date, options) { + const start = (0, _index3.startOfYear)(date, options); + const end = (0, _index2.endOfYear)(date, options); + return (0, _index.eachWeekendOfInterval)({ start, end }, options); +} diff --git a/node_modules/date-fns/eachWeekendOfYear.d.cts b/node_modules/date-fns/eachWeekendOfYear.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..74832edf7e997fe031294d9cf23385e1f73b7069 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfYear.d.cts @@ -0,0 +1,40 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link eachWeekendOfYear} function options. + */ +export interface EachWeekendOfYearOptions + extends ContextOptions {} +/** + * @name eachWeekendOfYear + * @category Year Helpers + * @summary List all the Saturdays and Sundays in the year. + * + * @description + * Get all the Saturdays and Sundays in the year. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given year + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the year + * const result = eachWeekendOfYear(new Date(2020, 1, 1)) + * //=> [ + * // Sat Jan 03 2020 00:00:00, + * // Sun Jan 04 2020 00:00:00, + * // ... + * // Sun Dec 27 2020 00:00:00 + * // ] + * ] + */ +export declare function eachWeekendOfYear< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EachWeekendOfYearOptions, +): ResultDate[]; diff --git a/node_modules/date-fns/eachWeekendOfYear.d.ts b/node_modules/date-fns/eachWeekendOfYear.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74832edf7e997fe031294d9cf23385e1f73b7069 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfYear.d.ts @@ -0,0 +1,40 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link eachWeekendOfYear} function options. + */ +export interface EachWeekendOfYearOptions + extends ContextOptions {} +/** + * @name eachWeekendOfYear + * @category Year Helpers + * @summary List all the Saturdays and Sundays in the year. + * + * @description + * Get all the Saturdays and Sundays in the year. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given year + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the year + * const result = eachWeekendOfYear(new Date(2020, 1, 1)) + * //=> [ + * // Sat Jan 03 2020 00:00:00, + * // Sun Jan 04 2020 00:00:00, + * // ... + * // Sun Dec 27 2020 00:00:00 + * // ] + * ] + */ +export declare function eachWeekendOfYear< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EachWeekendOfYearOptions, +): ResultDate[]; diff --git a/node_modules/date-fns/eachWeekendOfYear.js b/node_modules/date-fns/eachWeekendOfYear.js new file mode 100644 index 0000000000000000000000000000000000000000..901cf9f8e36d16eed93324e0d60e5131cac62761 --- /dev/null +++ b/node_modules/date-fns/eachWeekendOfYear.js @@ -0,0 +1,43 @@ +import { eachWeekendOfInterval } from "./eachWeekendOfInterval.js"; +import { endOfYear } from "./endOfYear.js"; +import { startOfYear } from "./startOfYear.js"; + +/** + * The {@link eachWeekendOfYear} function options. + */ + +/** + * @name eachWeekendOfYear + * @category Year Helpers + * @summary List all the Saturdays and Sundays in the year. + * + * @description + * Get all the Saturdays and Sundays in the year. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The given year + * @param options - An object with options + * + * @returns An array containing all the Saturdays and Sundays + * + * @example + * // Lists all Saturdays and Sundays in the year + * const result = eachWeekendOfYear(new Date(2020, 1, 1)) + * //=> [ + * // Sat Jan 03 2020 00:00:00, + * // Sun Jan 04 2020 00:00:00, + * // ... + * // Sun Dec 27 2020 00:00:00 + * // ] + * ] + */ +export function eachWeekendOfYear(date, options) { + const start = startOfYear(date, options); + const end = endOfYear(date, options); + return eachWeekendOfInterval({ start, end }, options); +} + +// Fallback for modularized imports: +export default eachWeekendOfYear; diff --git a/node_modules/date-fns/eachYearOfInterval.cjs b/node_modules/date-fns/eachYearOfInterval.cjs new file mode 100644 index 0000000000000000000000000000000000000000..9984fe27792cdda741ac8402af66d928df14319f --- /dev/null +++ b/node_modules/date-fns/eachYearOfInterval.cjs @@ -0,0 +1,70 @@ +"use strict"; +exports.eachYearOfInterval = eachYearOfInterval; +var _index = require("./_lib/normalizeInterval.cjs"); +var _index2 = require("./constructFrom.cjs"); + +/** + * The {@link eachYearOfInterval} function options. + */ + +/** + * The {@link eachYearOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachYearOfInterval + * @category Interval Helpers + * @summary Return the array of yearly timestamps within the specified time interval. + * + * @description + * Return the array of yearly timestamps within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of yearly timestamps from the month of the interval start to the month of the interval end + * + * @example + * // Each year between 6 February 2014 and 10 August 2017: + * const result = eachYearOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2017, 7, 10) + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Thu Jan 01 2015 00:00:00, + * // Fri Jan 01 2016 00:00:00, + * // Sun Jan 01 2017 00:00:00 + * // ] + */ +function eachYearOfInterval(interval, options) { + const { start, end } = (0, _index.normalizeInterval)(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setHours(0, 0, 0, 0); + date.setMonth(0, 1); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push((0, _index2.constructFrom)(start, date)); + date.setFullYear(date.getFullYear() + step); + } + + return reversed ? dates.reverse() : dates; +} diff --git a/node_modules/date-fns/eachYearOfInterval.d.cts b/node_modules/date-fns/eachYearOfInterval.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..a91ae49e680c0f548ad056a06baa1d55eeac7cc8 --- /dev/null +++ b/node_modules/date-fns/eachYearOfInterval.d.cts @@ -0,0 +1,61 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachYearOfInterval} function options. + */ +export interface EachYearOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachYearOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachYearOfIntervalResult< + IntervalType extends Interval, + Options extends EachYearOfIntervalOptions | undefined, +> = Array< + Options extends EachYearOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachYearOfInterval + * @category Interval Helpers + * @summary Return the array of yearly timestamps within the specified time interval. + * + * @description + * Return the array of yearly timestamps within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of yearly timestamps from the month of the interval start to the month of the interval end + * + * @example + * // Each year between 6 February 2014 and 10 August 2017: + * const result = eachYearOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2017, 7, 10) + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Thu Jan 01 2015 00:00:00, + * // Fri Jan 01 2016 00:00:00, + * // Sun Jan 01 2017 00:00:00 + * // ] + */ +export declare function eachYearOfInterval< + IntervalType extends Interval, + Options extends EachYearOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachYearOfIntervalResult; diff --git a/node_modules/date-fns/eachYearOfInterval.d.ts b/node_modules/date-fns/eachYearOfInterval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a91ae49e680c0f548ad056a06baa1d55eeac7cc8 --- /dev/null +++ b/node_modules/date-fns/eachYearOfInterval.d.ts @@ -0,0 +1,61 @@ +import type { ContextOptions, Interval, StepOptions } from "./types.ts"; +/** + * The {@link eachYearOfInterval} function options. + */ +export interface EachYearOfIntervalOptions + extends StepOptions, + ContextOptions {} +/** + * The {@link eachYearOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ +export type EachYearOfIntervalResult< + IntervalType extends Interval, + Options extends EachYearOfIntervalOptions | undefined, +> = Array< + Options extends EachYearOfIntervalOptions + ? DateType + : IntervalType["start"] extends Date + ? IntervalType["start"] + : IntervalType["end"] extends Date + ? IntervalType["end"] + : Date +>; +/** + * @name eachYearOfInterval + * @category Interval Helpers + * @summary Return the array of yearly timestamps within the specified time interval. + * + * @description + * Return the array of yearly timestamps within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of yearly timestamps from the month of the interval start to the month of the interval end + * + * @example + * // Each year between 6 February 2014 and 10 August 2017: + * const result = eachYearOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2017, 7, 10) + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Thu Jan 01 2015 00:00:00, + * // Fri Jan 01 2016 00:00:00, + * // Sun Jan 01 2017 00:00:00 + * // ] + */ +export declare function eachYearOfInterval< + IntervalType extends Interval, + Options extends EachYearOfIntervalOptions | undefined = undefined, +>( + interval: IntervalType, + options?: Options, +): EachYearOfIntervalResult; diff --git a/node_modules/date-fns/eachYearOfInterval.js b/node_modules/date-fns/eachYearOfInterval.js new file mode 100644 index 0000000000000000000000000000000000000000..667ae6c15ae28be33943f63377e14e1b8edaa54e --- /dev/null +++ b/node_modules/date-fns/eachYearOfInterval.js @@ -0,0 +1,71 @@ +import { normalizeInterval } from "./_lib/normalizeInterval.js"; +import { constructFrom } from "./constructFrom.js"; + +/** + * The {@link eachYearOfInterval} function options. + */ + +/** + * The {@link eachYearOfInterval} function result type. It resolves the proper data type. + * It uses the first argument date object type, starting from the date argument, + * then the start interval date, and finally the end interval date. If + * a context function is passed, it uses the context function return type. + */ + +/** + * @name eachYearOfInterval + * @category Interval Helpers + * @summary Return the array of yearly timestamps within the specified time interval. + * + * @description + * Return the array of yearly timestamps within the specified time interval. + * + * @typeParam IntervalType - Interval type. + * @typeParam Options - Options type. + * + * @param interval - The interval. + * @param options - An object with options. + * + * @returns The array with starts of yearly timestamps from the month of the interval start to the month of the interval end + * + * @example + * // Each year between 6 February 2014 and 10 August 2017: + * const result = eachYearOfInterval({ + * start: new Date(2014, 1, 6), + * end: new Date(2017, 7, 10) + * }) + * //=> [ + * // Wed Jan 01 2014 00:00:00, + * // Thu Jan 01 2015 00:00:00, + * // Fri Jan 01 2016 00:00:00, + * // Sun Jan 01 2017 00:00:00 + * // ] + */ +export function eachYearOfInterval(interval, options) { + const { start, end } = normalizeInterval(options?.in, interval); + + let reversed = +start > +end; + const endTime = reversed ? +start : +end; + const date = reversed ? end : start; + date.setHours(0, 0, 0, 0); + date.setMonth(0, 1); + + let step = options?.step ?? 1; + if (!step) return []; + if (step < 0) { + step = -step; + reversed = !reversed; + } + + const dates = []; + + while (+date <= endTime) { + dates.push(constructFrom(start, date)); + date.setFullYear(date.getFullYear() + step); + } + + return reversed ? dates.reverse() : dates; +} + +// Fallback for modularized imports: +export default eachYearOfInterval; diff --git a/node_modules/date-fns/endOfDay.cjs b/node_modules/date-fns/endOfDay.cjs new file mode 100644 index 0000000000000000000000000000000000000000..187550a3946d90237370d50a52197bcd6a418a1c --- /dev/null +++ b/node_modules/date-fns/endOfDay.cjs @@ -0,0 +1,35 @@ +"use strict"; +exports.endOfDay = endOfDay; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfDay} function options. + */ + +/** + * @name endOfDay + * @category Day Helpers + * @summary Return the end of a day for the given date. + * + * @description + * Return the end of a day for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a day + * + * @example + * // The end of a day for 2 September 2014 11:55:00: + * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 23:59:59.999 + */ +function endOfDay(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + _date.setHours(23, 59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfDay.d.cts b/node_modules/date-fns/endOfDay.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..ea7af041e6601df1eeeeb8dff0d3dc6bacd17f6a --- /dev/null +++ b/node_modules/date-fns/endOfDay.d.cts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfDay} function options. + */ +export interface EndOfDayOptions + extends ContextOptions {} +/** + * @name endOfDay + * @category Day Helpers + * @summary Return the end of a day for the given date. + * + * @description + * Return the end of a day for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a day + * + * @example + * // The end of a day for 2 September 2014 11:55:00: + * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 23:59:59.999 + */ +export declare function endOfDay< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfDayOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfDay.d.ts b/node_modules/date-fns/endOfDay.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea7af041e6601df1eeeeb8dff0d3dc6bacd17f6a --- /dev/null +++ b/node_modules/date-fns/endOfDay.d.ts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfDay} function options. + */ +export interface EndOfDayOptions + extends ContextOptions {} +/** + * @name endOfDay + * @category Day Helpers + * @summary Return the end of a day for the given date. + * + * @description + * Return the end of a day for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a day + * + * @example + * // The end of a day for 2 September 2014 11:55:00: + * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 23:59:59.999 + */ +export declare function endOfDay< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfDayOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfDay.js b/node_modules/date-fns/endOfDay.js new file mode 100644 index 0000000000000000000000000000000000000000..1d70ab0712d74cb7e8e189c7ec5d3c6215ee9da9 --- /dev/null +++ b/node_modules/date-fns/endOfDay.js @@ -0,0 +1,36 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfDay} function options. + */ + +/** + * @name endOfDay + * @category Day Helpers + * @summary Return the end of a day for the given date. + * + * @description + * Return the end of a day for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a day + * + * @example + * // The end of a day for 2 September 2014 11:55:00: + * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 23:59:59.999 + */ +export function endOfDay(date, options) { + const _date = toDate(date, options?.in); + _date.setHours(23, 59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfDay; diff --git a/node_modules/date-fns/endOfDecade.cjs b/node_modules/date-fns/endOfDecade.cjs new file mode 100644 index 0000000000000000000000000000000000000000..42260a441be3f1ed76686181edac3779d82cce35 --- /dev/null +++ b/node_modules/date-fns/endOfDecade.cjs @@ -0,0 +1,40 @@ +"use strict"; +exports.endOfDecade = endOfDecade; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfDecade} function options. + */ + +/** + * @name endOfDecade + * @category Decade Helpers + * @summary Return the end of a decade for the given date. + * + * @description + * Return the end of a decade for the given date. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a decade + * + * @example + * // The end of a decade for 12 May 1984 00:00:00: + * const result = endOfDecade(new Date(1984, 4, 12, 00, 00, 00)) + * //=> Dec 31 1989 23:59:59.999 + */ +function endOfDecade(date, options) { + // TODO: Switch to more technical definition in of decades that start with 1 + // end with 0. I.e. 2001-2010 instead of current 2000-2009. It's a breaking + // change, so it can only be done in 4.0. + const _date = (0, _index.toDate)(date, options?.in); + const year = _date.getFullYear(); + const decade = 9 + Math.floor(year / 10) * 10; + _date.setFullYear(decade, 11, 31); + _date.setHours(23, 59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfDecade.d.cts b/node_modules/date-fns/endOfDecade.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..6c2919a78da7d948047bb3a6d29c3ea7d7e4edb4 --- /dev/null +++ b/node_modules/date-fns/endOfDecade.d.cts @@ -0,0 +1,34 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfDecade} function options. + */ +export interface EndOfDecadeOptions + extends ContextOptions {} +/** + * @name endOfDecade + * @category Decade Helpers + * @summary Return the end of a decade for the given date. + * + * @description + * Return the end of a decade for the given date. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a decade + * + * @example + * // The end of a decade for 12 May 1984 00:00:00: + * const result = endOfDecade(new Date(1984, 4, 12, 00, 00, 00)) + * //=> Dec 31 1989 23:59:59.999 + */ +export declare function endOfDecade< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfDecadeOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfDecade.d.ts b/node_modules/date-fns/endOfDecade.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c2919a78da7d948047bb3a6d29c3ea7d7e4edb4 --- /dev/null +++ b/node_modules/date-fns/endOfDecade.d.ts @@ -0,0 +1,34 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfDecade} function options. + */ +export interface EndOfDecadeOptions + extends ContextOptions {} +/** + * @name endOfDecade + * @category Decade Helpers + * @summary Return the end of a decade for the given date. + * + * @description + * Return the end of a decade for the given date. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a decade + * + * @example + * // The end of a decade for 12 May 1984 00:00:00: + * const result = endOfDecade(new Date(1984, 4, 12, 00, 00, 00)) + * //=> Dec 31 1989 23:59:59.999 + */ +export declare function endOfDecade< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfDecadeOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfDecade.js b/node_modules/date-fns/endOfDecade.js new file mode 100644 index 0000000000000000000000000000000000000000..539a6a6d66e7c99f239e2a775bd32eda1f332ffa --- /dev/null +++ b/node_modules/date-fns/endOfDecade.js @@ -0,0 +1,41 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfDecade} function options. + */ + +/** + * @name endOfDecade + * @category Decade Helpers + * @summary Return the end of a decade for the given date. + * + * @description + * Return the end of a decade for the given date. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a decade + * + * @example + * // The end of a decade for 12 May 1984 00:00:00: + * const result = endOfDecade(new Date(1984, 4, 12, 00, 00, 00)) + * //=> Dec 31 1989 23:59:59.999 + */ +export function endOfDecade(date, options) { + // TODO: Switch to more technical definition in of decades that start with 1 + // end with 0. I.e. 2001-2010 instead of current 2000-2009. It's a breaking + // change, so it can only be done in 4.0. + const _date = toDate(date, options?.in); + const year = _date.getFullYear(); + const decade = 9 + Math.floor(year / 10) * 10; + _date.setFullYear(decade, 11, 31); + _date.setHours(23, 59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfDecade; diff --git a/node_modules/date-fns/endOfHour.cjs b/node_modules/date-fns/endOfHour.cjs new file mode 100644 index 0000000000000000000000000000000000000000..1b6e0fa006ad5dd5ef44bada64235e12506272c4 --- /dev/null +++ b/node_modules/date-fns/endOfHour.cjs @@ -0,0 +1,35 @@ +"use strict"; +exports.endOfHour = endOfHour; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfHour} function options. + */ + +/** + * @name endOfHour + * @category Hour Helpers + * @summary Return the end of an hour for the given date. + * + * @description + * Return the end of an hour for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an hour + * + * @example + * // The end of an hour for 2 September 2014 11:55:00: + * const result = endOfHour(new Date(2014, 8, 2, 11, 55)) + * //=> Tue Sep 02 2014 11:59:59.999 + */ +function endOfHour(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + _date.setMinutes(59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfHour.d.cts b/node_modules/date-fns/endOfHour.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..8b37ba56e5fb31325ebe008309475c126431b39c --- /dev/null +++ b/node_modules/date-fns/endOfHour.d.cts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfHour} function options. + */ +export interface EndOfHourOptions + extends ContextOptions {} +/** + * @name endOfHour + * @category Hour Helpers + * @summary Return the end of an hour for the given date. + * + * @description + * Return the end of an hour for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an hour + * + * @example + * // The end of an hour for 2 September 2014 11:55:00: + * const result = endOfHour(new Date(2014, 8, 2, 11, 55)) + * //=> Tue Sep 02 2014 11:59:59.999 + */ +export declare function endOfHour< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfHourOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfHour.d.ts b/node_modules/date-fns/endOfHour.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b37ba56e5fb31325ebe008309475c126431b39c --- /dev/null +++ b/node_modules/date-fns/endOfHour.d.ts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfHour} function options. + */ +export interface EndOfHourOptions + extends ContextOptions {} +/** + * @name endOfHour + * @category Hour Helpers + * @summary Return the end of an hour for the given date. + * + * @description + * Return the end of an hour for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an hour + * + * @example + * // The end of an hour for 2 September 2014 11:55:00: + * const result = endOfHour(new Date(2014, 8, 2, 11, 55)) + * //=> Tue Sep 02 2014 11:59:59.999 + */ +export declare function endOfHour< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfHourOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfHour.js b/node_modules/date-fns/endOfHour.js new file mode 100644 index 0000000000000000000000000000000000000000..ad0826bfda349e52356f6e9b201750a01c7cc3ce --- /dev/null +++ b/node_modules/date-fns/endOfHour.js @@ -0,0 +1,36 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfHour} function options. + */ + +/** + * @name endOfHour + * @category Hour Helpers + * @summary Return the end of an hour for the given date. + * + * @description + * Return the end of an hour for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an hour + * + * @example + * // The end of an hour for 2 September 2014 11:55:00: + * const result = endOfHour(new Date(2014, 8, 2, 11, 55)) + * //=> Tue Sep 02 2014 11:59:59.999 + */ +export function endOfHour(date, options) { + const _date = toDate(date, options?.in); + _date.setMinutes(59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfHour; diff --git a/node_modules/date-fns/endOfISOWeek.cjs b/node_modules/date-fns/endOfISOWeek.cjs new file mode 100644 index 0000000000000000000000000000000000000000..f43d50f036ee33f12d7cb8c2960ddc2f6d5c6a6a --- /dev/null +++ b/node_modules/date-fns/endOfISOWeek.cjs @@ -0,0 +1,35 @@ +"use strict"; +exports.endOfISOWeek = endOfISOWeek; +var _index = require("./endOfWeek.cjs"); + +/** + * The {@link endOfISOWeek} function options. + */ + +/** + * @name endOfISOWeek + * @category ISO Week Helpers + * @summary Return the end of an ISO week for the given date. + * + * @description + * Return the end of an ISO week for the given date. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an ISO week + * + * @example + * // The end of an ISO week for 2 September 2014 11:55:00: + * const result = endOfISOWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +function endOfISOWeek(date, options) { + return (0, _index.endOfWeek)(date, { ...options, weekStartsOn: 1 }); +} diff --git a/node_modules/date-fns/endOfISOWeek.d.cts b/node_modules/date-fns/endOfISOWeek.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..ba36616f7611aa5da9771dde49750eca0c16bd3e --- /dev/null +++ b/node_modules/date-fns/endOfISOWeek.d.cts @@ -0,0 +1,37 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfISOWeek} function options. + */ +export interface EndOfISOWeekOptions + extends ContextOptions {} +/** + * @name endOfISOWeek + * @category ISO Week Helpers + * @summary Return the end of an ISO week for the given date. + * + * @description + * Return the end of an ISO week for the given date. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an ISO week + * + * @example + * // The end of an ISO week for 2 September 2014 11:55:00: + * const result = endOfISOWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +export declare function endOfISOWeek< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfISOWeekOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfISOWeek.d.ts b/node_modules/date-fns/endOfISOWeek.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba36616f7611aa5da9771dde49750eca0c16bd3e --- /dev/null +++ b/node_modules/date-fns/endOfISOWeek.d.ts @@ -0,0 +1,37 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfISOWeek} function options. + */ +export interface EndOfISOWeekOptions + extends ContextOptions {} +/** + * @name endOfISOWeek + * @category ISO Week Helpers + * @summary Return the end of an ISO week for the given date. + * + * @description + * Return the end of an ISO week for the given date. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an ISO week + * + * @example + * // The end of an ISO week for 2 September 2014 11:55:00: + * const result = endOfISOWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +export declare function endOfISOWeek< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfISOWeekOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfISOWeek.js b/node_modules/date-fns/endOfISOWeek.js new file mode 100644 index 0000000000000000000000000000000000000000..c885a1dd17ef8dc34fa4ae7ab71f980bc9b4f0c4 --- /dev/null +++ b/node_modules/date-fns/endOfISOWeek.js @@ -0,0 +1,36 @@ +import { endOfWeek } from "./endOfWeek.js"; + +/** + * The {@link endOfISOWeek} function options. + */ + +/** + * @name endOfISOWeek + * @category ISO Week Helpers + * @summary Return the end of an ISO week for the given date. + * + * @description + * Return the end of an ISO week for the given date. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of an ISO week + * + * @example + * // The end of an ISO week for 2 September 2014 11:55:00: + * const result = endOfISOWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +export function endOfISOWeek(date, options) { + return endOfWeek(date, { ...options, weekStartsOn: 1 }); +} + +// Fallback for modularized imports: +export default endOfISOWeek; diff --git a/node_modules/date-fns/endOfISOWeekYear.cjs b/node_modules/date-fns/endOfISOWeekYear.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c5e7a5a863d8f1de43638c6b2c5fdecee3caf31d --- /dev/null +++ b/node_modules/date-fns/endOfISOWeekYear.cjs @@ -0,0 +1,47 @@ +"use strict"; +exports.endOfISOWeekYear = endOfISOWeekYear; +var _index = require("./constructFrom.cjs"); +var _index2 = require("./getISOWeekYear.cjs"); +var _index3 = require("./startOfISOWeek.cjs"); + +/** + * The {@link endOfISOWeekYear} function options. + */ + +/** + * @name endOfISOWeekYear + * @category ISO Week-Numbering Year Helpers + * @summary Return the end of an ISO week-numbering year for the given date. + * + * @description + * Return the end of an ISO week-numbering year, + * which always starts 3 days before the year's first Thursday. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ContextDate - The `Date` type of the context function. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of an ISO week-numbering year + * + * @example + * // The end of an ISO week-numbering year for 2 July 2005: + * const result = endOfISOWeekYear(new Date(2005, 6, 2)) + * //=> Sun Jan 01 2006 23:59:59.999 + */ +function endOfISOWeekYear(date, options) { + const year = (0, _index2.getISOWeekYear)(date, options); + const fourthOfJanuaryOfNextYear = (0, _index.constructFrom)( + options?.in || date, + 0, + ); + fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); + const _date = (0, _index3.startOfISOWeek)(fourthOfJanuaryOfNextYear, options); + _date.setMilliseconds(_date.getMilliseconds() - 1); + return _date; +} diff --git a/node_modules/date-fns/endOfISOWeekYear.d.cts b/node_modules/date-fns/endOfISOWeekYear.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2083de13a8077a0e3f1a6761a68bde682e1b63fc --- /dev/null +++ b/node_modules/date-fns/endOfISOWeekYear.d.cts @@ -0,0 +1,38 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfISOWeekYear} function options. + */ +export interface EndOfISOWeekYearOptions + extends ContextOptions {} +/** + * @name endOfISOWeekYear + * @category ISO Week-Numbering Year Helpers + * @summary Return the end of an ISO week-numbering year for the given date. + * + * @description + * Return the end of an ISO week-numbering year, + * which always starts 3 days before the year's first Thursday. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ContextDate - The `Date` type of the context function. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of an ISO week-numbering year + * + * @example + * // The end of an ISO week-numbering year for 2 July 2005: + * const result = endOfISOWeekYear(new Date(2005, 6, 2)) + * //=> Sun Jan 01 2006 23:59:59.999 + */ +export declare function endOfISOWeekYear< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfISOWeekYearOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfISOWeekYear.d.ts b/node_modules/date-fns/endOfISOWeekYear.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2083de13a8077a0e3f1a6761a68bde682e1b63fc --- /dev/null +++ b/node_modules/date-fns/endOfISOWeekYear.d.ts @@ -0,0 +1,38 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfISOWeekYear} function options. + */ +export interface EndOfISOWeekYearOptions + extends ContextOptions {} +/** + * @name endOfISOWeekYear + * @category ISO Week-Numbering Year Helpers + * @summary Return the end of an ISO week-numbering year for the given date. + * + * @description + * Return the end of an ISO week-numbering year, + * which always starts 3 days before the year's first Thursday. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ContextDate - The `Date` type of the context function. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of an ISO week-numbering year + * + * @example + * // The end of an ISO week-numbering year for 2 July 2005: + * const result = endOfISOWeekYear(new Date(2005, 6, 2)) + * //=> Sun Jan 01 2006 23:59:59.999 + */ +export declare function endOfISOWeekYear< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfISOWeekYearOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfISOWeekYear.js b/node_modules/date-fns/endOfISOWeekYear.js new file mode 100644 index 0000000000000000000000000000000000000000..54bddd4913cddaa8914a79cde109b0d646b8e2c7 --- /dev/null +++ b/node_modules/date-fns/endOfISOWeekYear.js @@ -0,0 +1,45 @@ +import { constructFrom } from "./constructFrom.js"; +import { getISOWeekYear } from "./getISOWeekYear.js"; +import { startOfISOWeek } from "./startOfISOWeek.js"; + +/** + * The {@link endOfISOWeekYear} function options. + */ + +/** + * @name endOfISOWeekYear + * @category ISO Week-Numbering Year Helpers + * @summary Return the end of an ISO week-numbering year for the given date. + * + * @description + * Return the end of an ISO week-numbering year, + * which always starts 3 days before the year's first Thursday. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @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). + * @typeParam ContextDate - The `Date` type of the context function. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of an ISO week-numbering year + * + * @example + * // The end of an ISO week-numbering year for 2 July 2005: + * const result = endOfISOWeekYear(new Date(2005, 6, 2)) + * //=> Sun Jan 01 2006 23:59:59.999 + */ +export function endOfISOWeekYear(date, options) { + const year = getISOWeekYear(date, options); + const fourthOfJanuaryOfNextYear = constructFrom(options?.in || date, 0); + fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); + const _date = startOfISOWeek(fourthOfJanuaryOfNextYear, options); + _date.setMilliseconds(_date.getMilliseconds() - 1); + return _date; +} + +// Fallback for modularized imports: +export default endOfISOWeekYear; diff --git a/node_modules/date-fns/endOfMinute.cjs b/node_modules/date-fns/endOfMinute.cjs new file mode 100644 index 0000000000000000000000000000000000000000..aca6b63fe008067f6ada0340d3588afe6330e97e --- /dev/null +++ b/node_modules/date-fns/endOfMinute.cjs @@ -0,0 +1,35 @@ +"use strict"; +exports.endOfMinute = endOfMinute; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfMinute} function options. + */ + +/** + * @name endOfMinute + * @category Minute Helpers + * @summary Return the end of a minute for the given date. + * + * @description + * Return the end of a minute for the given date. + * The result will be in the local timezone or the provided context. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a minute + * + * @example + * // The end of a minute for 1 December 2014 22:15:45.400: + * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:59.999 + */ +function endOfMinute(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + _date.setSeconds(59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfMinute.d.cts b/node_modules/date-fns/endOfMinute.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..337496e85d9a54f423e1660ce7c2f87bfd3fbab8 --- /dev/null +++ b/node_modules/date-fns/endOfMinute.d.cts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfMinute} function options. + */ +export interface EndOfMinuteOptions + extends ContextOptions {} +/** + * @name endOfMinute + * @category Minute Helpers + * @summary Return the end of a minute for the given date. + * + * @description + * Return the end of a minute for the given date. + * The result will be in the local timezone or the provided context. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a minute + * + * @example + * // The end of a minute for 1 December 2014 22:15:45.400: + * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:59.999 + */ +export declare function endOfMinute< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfMinuteOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfMinute.d.ts b/node_modules/date-fns/endOfMinute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..337496e85d9a54f423e1660ce7c2f87bfd3fbab8 --- /dev/null +++ b/node_modules/date-fns/endOfMinute.d.ts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfMinute} function options. + */ +export interface EndOfMinuteOptions + extends ContextOptions {} +/** + * @name endOfMinute + * @category Minute Helpers + * @summary Return the end of a minute for the given date. + * + * @description + * Return the end of a minute for the given date. + * The result will be in the local timezone or the provided context. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a minute + * + * @example + * // The end of a minute for 1 December 2014 22:15:45.400: + * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:59.999 + */ +export declare function endOfMinute< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfMinuteOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfMinute.js b/node_modules/date-fns/endOfMinute.js new file mode 100644 index 0000000000000000000000000000000000000000..24699a2a36cc85e430875d217a36f72ecc965fa9 --- /dev/null +++ b/node_modules/date-fns/endOfMinute.js @@ -0,0 +1,36 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfMinute} function options. + */ + +/** + * @name endOfMinute + * @category Minute Helpers + * @summary Return the end of a minute for the given date. + * + * @description + * Return the end of a minute for the given date. + * The result will be in the local timezone or the provided context. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a minute + * + * @example + * // The end of a minute for 1 December 2014 22:15:45.400: + * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:59.999 + */ +export function endOfMinute(date, options) { + const _date = toDate(date, options?.in); + _date.setSeconds(59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfMinute; diff --git a/node_modules/date-fns/endOfMonth.cjs b/node_modules/date-fns/endOfMonth.cjs new file mode 100644 index 0000000000000000000000000000000000000000..891f850f602f07e3dd61ca91e98652506aaed4bc --- /dev/null +++ b/node_modules/date-fns/endOfMonth.cjs @@ -0,0 +1,37 @@ +"use strict"; +exports.endOfMonth = endOfMonth; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfMonth} function options. + */ + +/** + * @name endOfMonth + * @category Month Helpers + * @summary Return the end of a month for the given date. + * + * @description + * Return the end of a month for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a month + * + * @example + * // The end of a month for 2 September 2014 11:55:00: + * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +function endOfMonth(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + const month = _date.getMonth(); + _date.setFullYear(_date.getFullYear(), month + 1, 0); + _date.setHours(23, 59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfMonth.d.cts b/node_modules/date-fns/endOfMonth.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..14d39250d0a48cb3cdee3d29c75178cabb466ae2 --- /dev/null +++ b/node_modules/date-fns/endOfMonth.d.cts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfMonth} function options. + */ +export interface EndOfMonthOptions + extends ContextOptions {} +/** + * @name endOfMonth + * @category Month Helpers + * @summary Return the end of a month for the given date. + * + * @description + * Return the end of a month for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a month + * + * @example + * // The end of a month for 2 September 2014 11:55:00: + * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +export declare function endOfMonth< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfMonthOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfMonth.d.ts b/node_modules/date-fns/endOfMonth.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14d39250d0a48cb3cdee3d29c75178cabb466ae2 --- /dev/null +++ b/node_modules/date-fns/endOfMonth.d.ts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfMonth} function options. + */ +export interface EndOfMonthOptions + extends ContextOptions {} +/** + * @name endOfMonth + * @category Month Helpers + * @summary Return the end of a month for the given date. + * + * @description + * Return the end of a month for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a month + * + * @example + * // The end of a month for 2 September 2014 11:55:00: + * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +export declare function endOfMonth< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfMonthOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfMonth.js b/node_modules/date-fns/endOfMonth.js new file mode 100644 index 0000000000000000000000000000000000000000..bfbabfa5e98042a82ab22488a2959cb94e0cf5cd --- /dev/null +++ b/node_modules/date-fns/endOfMonth.js @@ -0,0 +1,38 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfMonth} function options. + */ + +/** + * @name endOfMonth + * @category Month Helpers + * @summary Return the end of a month for the given date. + * + * @description + * Return the end of a month for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a month + * + * @example + * // The end of a month for 2 September 2014 11:55:00: + * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +export function endOfMonth(date, options) { + const _date = toDate(date, options?.in); + const month = _date.getMonth(); + _date.setFullYear(_date.getFullYear(), month + 1, 0); + _date.setHours(23, 59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfMonth; diff --git a/node_modules/date-fns/endOfQuarter.cjs b/node_modules/date-fns/endOfQuarter.cjs new file mode 100644 index 0000000000000000000000000000000000000000..f2f642cee73812d596bc71bcdd3a987b42c70912 --- /dev/null +++ b/node_modules/date-fns/endOfQuarter.cjs @@ -0,0 +1,38 @@ +"use strict"; +exports.endOfQuarter = endOfQuarter; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfQuarter} function options. + */ + +/** + * @name endOfQuarter + * @category Quarter Helpers + * @summary Return the end of a year quarter for the given date. + * + * @description + * Return the end of a year quarter for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a quarter + * + * @example + * // The end of a quarter for 2 September 2014 11:55:00: + * const result = endOfQuarter(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +function endOfQuarter(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + const currentMonth = _date.getMonth(); + const month = currentMonth - (currentMonth % 3) + 3; + _date.setMonth(month, 0); + _date.setHours(23, 59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfQuarter.d.cts b/node_modules/date-fns/endOfQuarter.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..1d8fd1ae9b8e5e4304a05cffda5de840a1556086 --- /dev/null +++ b/node_modules/date-fns/endOfQuarter.d.cts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfQuarter} function options. + */ +export interface EndOfQuarterOptions + extends ContextOptions {} +/** + * @name endOfQuarter + * @category Quarter Helpers + * @summary Return the end of a year quarter for the given date. + * + * @description + * Return the end of a year quarter for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a quarter + * + * @example + * // The end of a quarter for 2 September 2014 11:55:00: + * const result = endOfQuarter(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +export declare function endOfQuarter< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfQuarterOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfQuarter.d.ts b/node_modules/date-fns/endOfQuarter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d8fd1ae9b8e5e4304a05cffda5de840a1556086 --- /dev/null +++ b/node_modules/date-fns/endOfQuarter.d.ts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfQuarter} function options. + */ +export interface EndOfQuarterOptions + extends ContextOptions {} +/** + * @name endOfQuarter + * @category Quarter Helpers + * @summary Return the end of a year quarter for the given date. + * + * @description + * Return the end of a year quarter for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a quarter + * + * @example + * // The end of a quarter for 2 September 2014 11:55:00: + * const result = endOfQuarter(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +export declare function endOfQuarter< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfQuarterOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfQuarter.js b/node_modules/date-fns/endOfQuarter.js new file mode 100644 index 0000000000000000000000000000000000000000..a891b6a394c6bb94b516605e9964c30066ca35f6 --- /dev/null +++ b/node_modules/date-fns/endOfQuarter.js @@ -0,0 +1,39 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfQuarter} function options. + */ + +/** + * @name endOfQuarter + * @category Quarter Helpers + * @summary Return the end of a year quarter for the given date. + * + * @description + * Return the end of a year quarter for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a quarter + * + * @example + * // The end of a quarter for 2 September 2014 11:55:00: + * const result = endOfQuarter(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 30 2014 23:59:59.999 + */ +export function endOfQuarter(date, options) { + const _date = toDate(date, options?.in); + const currentMonth = _date.getMonth(); + const month = currentMonth - (currentMonth % 3) + 3; + _date.setMonth(month, 0); + _date.setHours(23, 59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfQuarter; diff --git a/node_modules/date-fns/endOfSecond.cjs b/node_modules/date-fns/endOfSecond.cjs new file mode 100644 index 0000000000000000000000000000000000000000..98f26eb74fae8ab91685190aa22418757a481888 --- /dev/null +++ b/node_modules/date-fns/endOfSecond.cjs @@ -0,0 +1,35 @@ +"use strict"; +exports.endOfSecond = endOfSecond; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfSecond} function options. + */ + +/** + * @name endOfSecond + * @category Second Helpers + * @summary Return the end of a second for the given date. + * + * @description + * Return the end of a second for the given date. + * The result will be in the local timezone if no `in` option is specified. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a second + * + * @example + * // The end of a second for 1 December 2014 22:15:45.400: + * const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:45.999 + */ +function endOfSecond(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + _date.setMilliseconds(999); + return _date; +} diff --git a/node_modules/date-fns/endOfSecond.d.cts b/node_modules/date-fns/endOfSecond.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..5fd48893e9b90e219fd39c819591b1b5dab45d31 --- /dev/null +++ b/node_modules/date-fns/endOfSecond.d.cts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfSecond} function options. + */ +export interface EndOfSecondOptions + extends ContextOptions {} +/** + * @name endOfSecond + * @category Second Helpers + * @summary Return the end of a second for the given date. + * + * @description + * Return the end of a second for the given date. + * The result will be in the local timezone if no `in` option is specified. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a second + * + * @example + * // The end of a second for 1 December 2014 22:15:45.400: + * const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:45.999 + */ +export declare function endOfSecond< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfSecondOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfSecond.d.ts b/node_modules/date-fns/endOfSecond.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5fd48893e9b90e219fd39c819591b1b5dab45d31 --- /dev/null +++ b/node_modules/date-fns/endOfSecond.d.ts @@ -0,0 +1,35 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfSecond} function options. + */ +export interface EndOfSecondOptions + extends ContextOptions {} +/** + * @name endOfSecond + * @category Second Helpers + * @summary Return the end of a second for the given date. + * + * @description + * Return the end of a second for the given date. + * The result will be in the local timezone if no `in` option is specified. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a second + * + * @example + * // The end of a second for 1 December 2014 22:15:45.400: + * const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:45.999 + */ +export declare function endOfSecond< + DateType extends Date, + ResultDate extends Date = DateType, +>( + date: DateArg, + options?: EndOfSecondOptions | undefined, +): ResultDate; diff --git a/node_modules/date-fns/endOfSecond.js b/node_modules/date-fns/endOfSecond.js new file mode 100644 index 0000000000000000000000000000000000000000..92f64cfcda91be9c3d69c2c3a71f75f2c5bb1445 --- /dev/null +++ b/node_modules/date-fns/endOfSecond.js @@ -0,0 +1,36 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfSecond} function options. + */ + +/** + * @name endOfSecond + * @category Second Helpers + * @summary Return the end of a second for the given date. + * + * @description + * Return the end of a second for the given date. + * The result will be in the local timezone if no `in` option is specified. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a second + * + * @example + * // The end of a second for 1 December 2014 22:15:45.400: + * const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400)) + * //=> Mon Dec 01 2014 22:15:45.999 + */ +export function endOfSecond(date, options) { + const _date = toDate(date, options?.in); + _date.setMilliseconds(999); + return _date; +} + +// Fallback for modularized imports: +export default endOfSecond; diff --git a/node_modules/date-fns/endOfToday.cjs b/node_modules/date-fns/endOfToday.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c856ce47dde96c6bad3e6c444e6c4c422035b3e3 --- /dev/null +++ b/node_modules/date-fns/endOfToday.cjs @@ -0,0 +1,32 @@ +"use strict"; +exports.endOfToday = endOfToday; +var _index = require("./endOfDay.cjs"); + +/** + * The {@link endOfToday} function options. + */ + +/** + * @name endOfToday + * @category Day Helpers + * @summary Return the end of today. + * @pure false + * + * @description + * Return the end of today. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * + * @returns The end of today + * + * @example + * // If today is 6 October 2014: + * const result = endOfToday() + * //=> Mon Oct 6 2014 23:59:59.999 + */ +function endOfToday(options) { + return (0, _index.endOfDay)(Date.now(), options); +} diff --git a/node_modules/date-fns/endOfToday.d.cts b/node_modules/date-fns/endOfToday.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..b5d51a7a700ff5987c10c8309b680cfa88581f15 --- /dev/null +++ b/node_modules/date-fns/endOfToday.d.cts @@ -0,0 +1,30 @@ +import type { ContextOptions } from "./types.ts"; +/** + * The {@link endOfToday} function options. + */ +export interface EndOfTodayOptions + extends ContextOptions {} +/** + * @name endOfToday + * @category Day Helpers + * @summary Return the end of today. + * @pure false + * + * @description + * Return the end of today. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * + * @returns The end of today + * + * @example + * // If today is 6 October 2014: + * const result = endOfToday() + * //=> Mon Oct 6 2014 23:59:59.999 + */ +export declare function endOfToday( + options?: EndOfTodayOptions, +): ResultDate; diff --git a/node_modules/date-fns/endOfToday.d.ts b/node_modules/date-fns/endOfToday.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5d51a7a700ff5987c10c8309b680cfa88581f15 --- /dev/null +++ b/node_modules/date-fns/endOfToday.d.ts @@ -0,0 +1,30 @@ +import type { ContextOptions } from "./types.ts"; +/** + * The {@link endOfToday} function options. + */ +export interface EndOfTodayOptions + extends ContextOptions {} +/** + * @name endOfToday + * @category Day Helpers + * @summary Return the end of today. + * @pure false + * + * @description + * Return the end of today. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * + * @returns The end of today + * + * @example + * // If today is 6 October 2014: + * const result = endOfToday() + * //=> Mon Oct 6 2014 23:59:59.999 + */ +export declare function endOfToday( + options?: EndOfTodayOptions, +): ResultDate; diff --git a/node_modules/date-fns/endOfToday.js b/node_modules/date-fns/endOfToday.js new file mode 100644 index 0000000000000000000000000000000000000000..fcf29e958ea7b82123d46885f6f43e083d78cc92 --- /dev/null +++ b/node_modules/date-fns/endOfToday.js @@ -0,0 +1,33 @@ +import { endOfDay } from "./endOfDay.js"; + +/** + * The {@link endOfToday} function options. + */ + +/** + * @name endOfToday + * @category Day Helpers + * @summary Return the end of today. + * @pure false + * + * @description + * Return the end of today. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * + * @returns The end of today + * + * @example + * // If today is 6 October 2014: + * const result = endOfToday() + * //=> Mon Oct 6 2014 23:59:59.999 + */ +export function endOfToday(options) { + return endOfDay(Date.now(), options); +} + +// Fallback for modularized imports: +export default endOfToday; diff --git a/node_modules/date-fns/endOfTomorrow.cjs b/node_modules/date-fns/endOfTomorrow.cjs new file mode 100644 index 0000000000000000000000000000000000000000..bc9bb83e71a2cbc98f591aa292e86f60710d1a4d --- /dev/null +++ b/node_modules/date-fns/endOfTomorrow.cjs @@ -0,0 +1,39 @@ +"use strict"; +exports.endOfTomorrow = endOfTomorrow; +var _index = require("./constructNow.cjs"); + +/** + * The {@link endOfTomorrow} function options. + */ + +/** + * @name endOfTomorrow + * @category Day Helpers + * @summary Return the end of tomorrow. + * @pure false + * + * @description + * Return the end of tomorrow. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * @returns The end of tomorrow + * + * @example + * // If today is 6 October 2014: + * const result = endOfTomorrow() + * //=> Tue Oct 7 2014 23:59:59.999 + */ +function endOfTomorrow(options) { + const now = (0, _index.constructNow)(options?.in); + const year = now.getFullYear(); + const month = now.getMonth(); + const day = now.getDate(); + + const date = (0, _index.constructNow)(options?.in); + date.setFullYear(year, month, day + 1); + date.setHours(23, 59, 59, 999); + return options?.in ? options.in(date) : date; +} diff --git a/node_modules/date-fns/endOfTomorrow.d.cts b/node_modules/date-fns/endOfTomorrow.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2fe1964f3912ab3949808f5bb122891ea97f3290 --- /dev/null +++ b/node_modules/date-fns/endOfTomorrow.d.cts @@ -0,0 +1,30 @@ +import type { ContextOptions } from "./types.ts"; +/** + * The {@link endOfTomorrow} function options. + */ +export interface EndOfTomorrowOptions + extends ContextOptions {} +/** + * @name endOfTomorrow + * @category Day Helpers + * @summary Return the end of tomorrow. + * @pure false + * + * @description + * Return the end of tomorrow. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * @returns The end of tomorrow + * + * @example + * // If today is 6 October 2014: + * const result = endOfTomorrow() + * //=> Tue Oct 7 2014 23:59:59.999 + */ +export declare function endOfTomorrow< + DateType extends Date, + ResultDate extends Date = DateType, +>(options?: EndOfTomorrowOptions | undefined): ResultDate; diff --git a/node_modules/date-fns/endOfTomorrow.d.ts b/node_modules/date-fns/endOfTomorrow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fe1964f3912ab3949808f5bb122891ea97f3290 --- /dev/null +++ b/node_modules/date-fns/endOfTomorrow.d.ts @@ -0,0 +1,30 @@ +import type { ContextOptions } from "./types.ts"; +/** + * The {@link endOfTomorrow} function options. + */ +export interface EndOfTomorrowOptions + extends ContextOptions {} +/** + * @name endOfTomorrow + * @category Day Helpers + * @summary Return the end of tomorrow. + * @pure false + * + * @description + * Return the end of tomorrow. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * @returns The end of tomorrow + * + * @example + * // If today is 6 October 2014: + * const result = endOfTomorrow() + * //=> Tue Oct 7 2014 23:59:59.999 + */ +export declare function endOfTomorrow< + DateType extends Date, + ResultDate extends Date = DateType, +>(options?: EndOfTomorrowOptions | undefined): ResultDate; diff --git a/node_modules/date-fns/endOfTomorrow.js b/node_modules/date-fns/endOfTomorrow.js new file mode 100644 index 0000000000000000000000000000000000000000..e27a4fb78c510d2608060e4bc933b33a2409f0fc --- /dev/null +++ b/node_modules/date-fns/endOfTomorrow.js @@ -0,0 +1,40 @@ +import { constructNow } from "./constructNow.js"; + +/** + * The {@link endOfTomorrow} function options. + */ + +/** + * @name endOfTomorrow + * @category Day Helpers + * @summary Return the end of tomorrow. + * @pure false + * + * @description + * Return the end of tomorrow. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param options - The options + * @returns The end of tomorrow + * + * @example + * // If today is 6 October 2014: + * const result = endOfTomorrow() + * //=> Tue Oct 7 2014 23:59:59.999 + */ +export function endOfTomorrow(options) { + const now = constructNow(options?.in); + const year = now.getFullYear(); + const month = now.getMonth(); + const day = now.getDate(); + + const date = constructNow(options?.in); + date.setFullYear(year, month, day + 1); + date.setHours(23, 59, 59, 999); + return options?.in ? options.in(date) : date; +} + +// Fallback for modularized imports: +export default endOfTomorrow; diff --git a/node_modules/date-fns/endOfWeek.cjs b/node_modules/date-fns/endOfWeek.cjs new file mode 100644 index 0000000000000000000000000000000000000000..407b656b25b56370d1ae4f33e3d0d1a1483948db --- /dev/null +++ b/node_modules/date-fns/endOfWeek.cjs @@ -0,0 +1,53 @@ +"use strict"; +exports.endOfWeek = endOfWeek; +var _index = require("./_lib/defaultOptions.cjs"); +var _index2 = require("./toDate.cjs"); + +/** + * The {@link endOfWeek} function options. + */ + +/** + * @name endOfWeek + * @category Week Helpers + * @summary Return the end of a week for the given date. + * + * @description + * Return the end of a week for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a week + * + * @example + * // The end of a week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sat Sep 06 2014 23:59:59.999 + * + * @example + * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 }) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +function endOfWeek(date, options) { + const defaultOptions = (0, _index.getDefaultOptions)(); + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const _date = (0, _index2.toDate)(date, options?.in); + const day = _date.getDay(); + const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn); + + _date.setDate(_date.getDate() + diff); + _date.setHours(23, 59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfWeek.d.cts b/node_modules/date-fns/endOfWeek.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..0bb3919bf17e603c1e1afd9d695fd67f3fb636f6 --- /dev/null +++ b/node_modules/date-fns/endOfWeek.d.cts @@ -0,0 +1,44 @@ +import type { + ContextOptions, + DateArg, + LocalizedOptions, + WeekOptions, +} from "./types.ts"; +/** + * The {@link endOfWeek} function options. + */ +export interface EndOfWeekOptions + extends WeekOptions, + LocalizedOptions<"options">, + ContextOptions {} +/** + * @name endOfWeek + * @category Week Helpers + * @summary Return the end of a week for the given date. + * + * @description + * Return the end of a week for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a week + * + * @example + * // The end of a week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sat Sep 06 2014 23:59:59.999 + * + * @example + * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 }) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +export declare function endOfWeek< + DateType extends Date, + ResultDate extends Date = DateType, +>(date: DateArg, options?: EndOfWeekOptions): ResultDate; diff --git a/node_modules/date-fns/endOfWeek.d.ts b/node_modules/date-fns/endOfWeek.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0bb3919bf17e603c1e1afd9d695fd67f3fb636f6 --- /dev/null +++ b/node_modules/date-fns/endOfWeek.d.ts @@ -0,0 +1,44 @@ +import type { + ContextOptions, + DateArg, + LocalizedOptions, + WeekOptions, +} from "./types.ts"; +/** + * The {@link endOfWeek} function options. + */ +export interface EndOfWeekOptions + extends WeekOptions, + LocalizedOptions<"options">, + ContextOptions {} +/** + * @name endOfWeek + * @category Week Helpers + * @summary Return the end of a week for the given date. + * + * @description + * Return the end of a week for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a week + * + * @example + * // The end of a week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sat Sep 06 2014 23:59:59.999 + * + * @example + * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 }) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +export declare function endOfWeek< + DateType extends Date, + ResultDate extends Date = DateType, +>(date: DateArg, options?: EndOfWeekOptions): ResultDate; diff --git a/node_modules/date-fns/endOfWeek.js b/node_modules/date-fns/endOfWeek.js new file mode 100644 index 0000000000000000000000000000000000000000..1e6155d2ec1b3a377e3f3c761c1c646e7779c503 --- /dev/null +++ b/node_modules/date-fns/endOfWeek.js @@ -0,0 +1,54 @@ +import { getDefaultOptions } from "./_lib/defaultOptions.js"; +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfWeek} function options. + */ + +/** + * @name endOfWeek + * @category Week Helpers + * @summary Return the end of a week for the given date. + * + * @description + * Return the end of a week for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - An object with options + * + * @returns The end of a week + * + * @example + * // The end of a week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sat Sep 06 2014 23:59:59.999 + * + * @example + * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00: + * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 }) + * //=> Sun Sep 07 2014 23:59:59.999 + */ +export function endOfWeek(date, options) { + const defaultOptions = getDefaultOptions(); + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const _date = toDate(date, options?.in); + const day = _date.getDay(); + const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn); + + _date.setDate(_date.getDate() + diff); + _date.setHours(23, 59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfWeek; diff --git a/node_modules/date-fns/endOfYear.cjs b/node_modules/date-fns/endOfYear.cjs new file mode 100644 index 0000000000000000000000000000000000000000..3ab2265355c1e303b9e392edcc5740ec7ba43bd5 --- /dev/null +++ b/node_modules/date-fns/endOfYear.cjs @@ -0,0 +1,37 @@ +"use strict"; +exports.endOfYear = endOfYear; +var _index = require("./toDate.cjs"); + +/** + * The {@link endOfYear} function options. + */ + +/** + * @name endOfYear + * @category Year Helpers + * @summary Return the end of a year for the given date. + * + * @description + * Return the end of a year for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of a year + * + * @example + * // The end of a year for 2 September 2014 11:55:00: + * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Wed Dec 31 2014 23:59:59.999 + */ +function endOfYear(date, options) { + const _date = (0, _index.toDate)(date, options?.in); + const year = _date.getFullYear(); + _date.setFullYear(year + 1, 0, 0); + _date.setHours(23, 59, 59, 999); + return _date; +} diff --git a/node_modules/date-fns/endOfYear.d.cts b/node_modules/date-fns/endOfYear.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..a8829509c5daaf2554cebcd5fbc60cd7b9e3fcbb --- /dev/null +++ b/node_modules/date-fns/endOfYear.d.cts @@ -0,0 +1,32 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfYear} function options. + */ +export interface EndOfYearOptions + extends ContextOptions {} +/** + * @name endOfYear + * @category Year Helpers + * @summary Return the end of a year for the given date. + * + * @description + * Return the end of a year for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of a year + * + * @example + * // The end of a year for 2 September 2014 11:55:00: + * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Wed Dec 31 2014 23:59:59.999 + */ +export declare function endOfYear< + DateType extends Date, + ResultDate extends Date = DateType, +>(date: DateArg, options?: EndOfYearOptions): ResultDate; diff --git a/node_modules/date-fns/endOfYear.d.ts b/node_modules/date-fns/endOfYear.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8829509c5daaf2554cebcd5fbc60cd7b9e3fcbb --- /dev/null +++ b/node_modules/date-fns/endOfYear.d.ts @@ -0,0 +1,32 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link endOfYear} function options. + */ +export interface EndOfYearOptions + extends ContextOptions {} +/** + * @name endOfYear + * @category Year Helpers + * @summary Return the end of a year for the given date. + * + * @description + * Return the end of a year for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of a year + * + * @example + * // The end of a year for 2 September 2014 11:55:00: + * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Wed Dec 31 2014 23:59:59.999 + */ +export declare function endOfYear< + DateType extends Date, + ResultDate extends Date = DateType, +>(date: DateArg, options?: EndOfYearOptions): ResultDate; diff --git a/node_modules/date-fns/endOfYear.js b/node_modules/date-fns/endOfYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f437ae92fd6cd93d30e72d9dad11d2fa0074a019 --- /dev/null +++ b/node_modules/date-fns/endOfYear.js @@ -0,0 +1,38 @@ +import { toDate } from "./toDate.js"; + +/** + * The {@link endOfYear} function options. + */ + +/** + * @name endOfYear + * @category Year Helpers + * @summary Return the end of a year for the given date. + * + * @description + * Return the end of a year for the given date. + * The result will be in the local timezone. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param date - The original date + * @param options - The options + * + * @returns The end of a year + * + * @example + * // The end of a year for 2 September 2014 11:55:00: + * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Wed Dec 31 2014 23:59:59.999 + */ +export function endOfYear(date, options) { + const _date = toDate(date, options?.in); + const year = _date.getFullYear(); + _date.setFullYear(year + 1, 0, 0); + _date.setHours(23, 59, 59, 999); + return _date; +} + +// Fallback for modularized imports: +export default endOfYear; diff --git a/node_modules/date-fns/endOfYesterday.cjs b/node_modules/date-fns/endOfYesterday.cjs new file mode 100644 index 0000000000000000000000000000000000000000..b4a24727af0747d1ae898a66c9f783cd7fa0cd3d --- /dev/null +++ b/node_modules/date-fns/endOfYesterday.cjs @@ -0,0 +1,35 @@ +"use strict"; +exports.endOfYesterday = endOfYesterday; +var _index = require("./constructFrom.cjs"); +var _index2 = require("./constructNow.cjs"); + +/** + * The {@link endOfYesterday} function options. + */ + +/** + * @name endOfYesterday + * @category Day Helpers + * @summary Return the end of yesterday. + * @pure false + * + * @description + * Return the end of yesterday. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @returns The end of yesterday + * + * @example + * // If today is 6 October 2014: + * const result = endOfYesterday() + * //=> Sun Oct 5 2014 23:59:59.999 + */ +function endOfYesterday(options) { + const now = (0, _index2.constructNow)(options?.in); + const date = (0, _index.constructFrom)(options?.in, 0); + date.setFullYear(now.getFullYear(), now.getMonth(), now.getDate() - 1); + date.setHours(23, 59, 59, 999); + return date; +} diff --git a/node_modules/date-fns/endOfYesterday.d.cts b/node_modules/date-fns/endOfYesterday.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..0d9b83575b5d54d758a969c67794666179652615 --- /dev/null +++ b/node_modules/date-fns/endOfYesterday.d.cts @@ -0,0 +1,29 @@ +import type { ContextOptions } from "./types.ts"; +/** + * The {@link endOfYesterday} function options. + */ +export interface EndOfYesterdayOptions + extends ContextOptions {} +/** + * @name endOfYesterday + * @category Day Helpers + * @summary Return the end of yesterday. + * @pure false + * + * @description + * Return the end of yesterday. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @returns The end of yesterday + * + * @example + * // If today is 6 October 2014: + * const result = endOfYesterday() + * //=> Sun Oct 5 2014 23:59:59.999 + */ +export declare function endOfYesterday< + DateType extends Date, + ResultDate extends Date = DateType, +>(options?: EndOfYesterdayOptions | undefined): ResultDate; diff --git a/node_modules/date-fns/endOfYesterday.d.ts b/node_modules/date-fns/endOfYesterday.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d9b83575b5d54d758a969c67794666179652615 --- /dev/null +++ b/node_modules/date-fns/endOfYesterday.d.ts @@ -0,0 +1,29 @@ +import type { ContextOptions } from "./types.ts"; +/** + * The {@link endOfYesterday} function options. + */ +export interface EndOfYesterdayOptions + extends ContextOptions {} +/** + * @name endOfYesterday + * @category Day Helpers + * @summary Return the end of yesterday. + * @pure false + * + * @description + * Return the end of yesterday. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @returns The end of yesterday + * + * @example + * // If today is 6 October 2014: + * const result = endOfYesterday() + * //=> Sun Oct 5 2014 23:59:59.999 + */ +export declare function endOfYesterday< + DateType extends Date, + ResultDate extends Date = DateType, +>(options?: EndOfYesterdayOptions | undefined): ResultDate; diff --git a/node_modules/date-fns/endOfYesterday.js b/node_modules/date-fns/endOfYesterday.js new file mode 100644 index 0000000000000000000000000000000000000000..e9d1cfb6580344575f06dd6b27ba8c95a7bee1a8 --- /dev/null +++ b/node_modules/date-fns/endOfYesterday.js @@ -0,0 +1,36 @@ +import { constructFrom } from "./constructFrom.js"; +import { constructNow } from "./constructNow.js"; + +/** + * The {@link endOfYesterday} function options. + */ + +/** + * @name endOfYesterday + * @category Day Helpers + * @summary Return the end of yesterday. + * @pure false + * + * @description + * Return the end of yesterday. + * + * @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). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @returns The end of yesterday + * + * @example + * // If today is 6 October 2014: + * const result = endOfYesterday() + * //=> Sun Oct 5 2014 23:59:59.999 + */ +export function endOfYesterday(options) { + const now = constructNow(options?.in); + const date = constructFrom(options?.in, 0); + date.setFullYear(now.getFullYear(), now.getMonth(), now.getDate() - 1); + date.setHours(23, 59, 59, 999); + return date; +} + +// Fallback for modularized imports: +export default endOfYesterday; diff --git a/node_modules/date-fns/format.cjs b/node_modules/date-fns/format.cjs new file mode 100644 index 0000000000000000000000000000000000000000..3bd77de742789e29cfbc9adc3589b8db5790c6f7 --- /dev/null +++ b/node_modules/date-fns/format.cjs @@ -0,0 +1,440 @@ +"use strict"; +exports.format = exports.formatDate = format; +Object.defineProperty(exports, "formatters", { + enumerable: true, + get: function () { + return _index3.formatters; + }, +}); +Object.defineProperty(exports, "longFormatters", { + enumerable: true, + get: function () { + return _index4.longFormatters; + }, +}); +var _index = require("./_lib/defaultLocale.cjs"); +var _index2 = require("./_lib/defaultOptions.cjs"); +var _index3 = require("./_lib/format/formatters.cjs"); +var _index4 = require("./_lib/format/longFormatters.cjs"); +var _index5 = require("./_lib/protectedTokens.cjs"); + +var _index6 = require("./isValid.cjs"); +var _index7 = require("./toDate.cjs"); + +// Rexports of internal for libraries to use. +// See: https://github.com/date-fns/date-fns/issues/3638#issuecomment-1877082874 + +// This RegExp consists of three parts separated by `|`: +// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token +// (one of the certain letters followed by `o`) +// - (\w)\1* matches any sequences of the same letter +// - '' matches two quote characters in a row +// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('), +// except a single quote symbol, which ends the sequence. +// Two quote characters do not end the sequence. +// If there is no matching single quote +// then the sequence will continue until the end of the string. +// - . matches any single character unmatched by previous parts of the RegExps +const formattingTokensRegExp = + /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; + +// This RegExp catches symbols escaped by quotes, and also +// sequences of symbols P, p, and the combinations like `PPPPPPPppppp` +const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; + +const escapedStringRegExp = /^'([^]*?)'?$/; +const doubleQuoteRegExp = /''/g; +const unescapedLatinCharacterRegExp = /[a-zA-Z]/; + +/** + * The {@link format} function options. + */ + +/** + * @name format + * @alias formatDate + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. The result may vary by locale. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * The characters wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * (see the last example) + * + * Format of the string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 7 below the table). + * + * Accepted patterns: + * | Unit | Pattern | Result examples | Notes | + * |---------------------------------|---------|-----------------------------------|-------| + * | Era | G..GGG | AD, BC | | + * | | GGGG | Anno Domini, Before Christ | 2 | + * | | GGGGG | A, B | | + * | Calendar year | y | 44, 1, 1900, 2017 | 5 | + * | | yo | 44th, 1st, 0th, 17th | 5,7 | + * | | yy | 44, 01, 00, 17 | 5 | + * | | yyy | 044, 001, 1900, 2017 | 5 | + * | | yyyy | 0044, 0001, 1900, 2017 | 5 | + * | | yyyyy | ... | 3,5 | + * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | + * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | + * | | YY | 44, 01, 00, 17 | 5,8 | + * | | YYY | 044, 001, 1900, 2017 | 5 | + * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | + * | | YYYYY | ... | 3,5 | + * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | + * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | + * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | + * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | + * | | RRRRR | ... | 3,5,7 | + * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | + * | | uu | -43, 01, 1900, 2017 | 5 | + * | | uuu | -043, 001, 1900, 2017 | 5 | + * | | uuuu | -0043, 0001, 1900, 2017 | 5 | + * | | uuuuu | ... | 3,5 | + * | Quarter (formatting) | Q | 1, 2, 3, 4 | | + * | | Qo | 1st, 2nd, 3rd, 4th | 7 | + * | | QQ | 01, 02, 03, 04 | | + * | | QQQ | Q1, Q2, Q3, Q4 | | + * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | + * | | qo | 1st, 2nd, 3rd, 4th | 7 | + * | | qq | 01, 02, 03, 04 | | + * | | qqq | Q1, Q2, Q3, Q4 | | + * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | qqqqq | 1, 2, 3, 4 | 4 | + * | Month (formatting) | M | 1, 2, ..., 12 | | + * | | Mo | 1st, 2nd, ..., 12th | 7 | + * | | MM | 01, 02, ..., 12 | | + * | | MMM | Jan, Feb, ..., Dec | | + * | | MMMM | January, February, ..., December | 2 | + * | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | L | 1, 2, ..., 12 | | + * | | Lo | 1st, 2nd, ..., 12th | 7 | + * | | LL | 01, 02, ..., 12 | | + * | | LLL | Jan, Feb, ..., Dec | | + * | | LLLL | January, February, ..., December | 2 | + * | | LLLLL | J, F, ..., D | | + * | Local week of year | w | 1, 2, ..., 53 | | + * | | wo | 1st, 2nd, ..., 53th | 7 | + * | | ww | 01, 02, ..., 53 | | + * | ISO week of year | I | 1, 2, ..., 53 | 7 | + * | | Io | 1st, 2nd, ..., 53th | 7 | + * | | II | 01, 02, ..., 53 | 7 | + * | Day of month | d | 1, 2, ..., 31 | | + * | | do | 1st, 2nd, ..., 31st | 7 | + * | | dd | 01, 02, ..., 31 | | + * | Day of year | D | 1, 2, ..., 365, 366 | 9 | + * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | + * | | DD | 01, 02, ..., 365, 366 | 9 | + * | | DDD | 001, 002, ..., 365, 366 | | + * | | DDDD | ... | 3 | + * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | EEEEE | M, T, W, T, F, S, S | | + * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | + * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | + * | | io | 1st, 2nd, ..., 7th | 7 | + * | | ii | 01, 02, ..., 07 | 7 | + * | | iii | Mon, Tue, Wed, ..., Sun | 7 | + * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | + * | | iiiii | M, T, W, T, F, S, S | 7 | + * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 | + * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | + * | | eo | 2nd, 3rd, ..., 1st | 7 | + * | | ee | 02, 03, ..., 01 | | + * | | eee | Mon, Tue, Wed, ..., Sun | | + * | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | eeeee | M, T, W, T, F, S, S | | + * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | + * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | + * | | co | 2nd, 3rd, ..., 1st | 7 | + * | | cc | 02, 03, ..., 01 | | + * | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | ccccc | M, T, W, T, F, S, S | | + * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | + * | AM, PM | a..aa | AM, PM | | + * | | aaa | am, pm | | + * | | aaaa | a.m., p.m. | 2 | + * | | aaaaa | a, p | | + * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | + * | | bbb | am, pm, noon, midnight | | + * | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | bbbbb | a, p, n, mi | | + * | Flexible day period | B..BBB | at night, in the morning, ... | | + * | | BBBB | at night, in the morning, ... | 2 | + * | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | + * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | + * | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | + * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | + * | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | + * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | + * | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | + * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | + * | | kk | 24, 01, 02, ..., 23 | | + * | Minute | m | 0, 1, ..., 59 | | + * | | mo | 0th, 1st, ..., 59th | 7 | + * | | mm | 00, 01, ..., 59 | | + * | Second | s | 0, 1, ..., 59 | | + * | | so | 0th, 1st, ..., 59th | 7 | + * | | ss | 00, 01, ..., 59 | | + * | Fraction of second | S | 0, 1, ..., 9 | | + * | | SS | 00, 01, ..., 99 | | + * | | SSS | 000, 001, ..., 999 | | + * | | SSSS | ... | 3 | + * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | + * | | XX | -0800, +0530, Z | | + * | | XXX | -08:00, +05:30, Z | | + * | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | + * | | xx | -0800, +0530, +0000 | | + * | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | xxxx | -0800, +0530, +0000, +123456 | | + * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | + * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | + * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | + * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | + * | Seconds timestamp | t | 512969520 | 7 | + * | | tt | ... | 3,7 | + * | Milliseconds timestamp | T | 512969520900 | 7 | + * | | TT | ... | 3,7 | + * | Long localized date | P | 04/29/1453 | 7 | + * | | PP | Apr 29, 1453 | 7 | + * | | PPP | April 29th, 1453 | 7 | + * | | PPPP | Friday, April 29th, 1453 | 2,7 | + * | Long localized time | p | 12:00 AM | 7 | + * | | pp | 12:00:00 AM | 7 | + * | | ppp | 12:00:00 AM GMT+2 | 7 | + * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | + * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | + * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | + * | | PPPppp | April 29th, 1453 at ... | 7 | + * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) + * the output will be the same as default pattern for this unit, usually + * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units + * are marked with "2" in the last column of the table. + * + * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` + * + * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` + * + * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` + * + * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). + * The output will be padded with zeros to match the length of the pattern. + * + * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` + * + * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 5. The main difference between `y` and `u` patterns are B.C. years: + * + * | Year | `y` | `u` | + * |------|-----|-----| + * | AC 1 | 1 | 1 | + * | BC 1 | 1 | 0 | + * | BC 2 | 2 | -1 | + * + * Also `yy` always returns the last two digits of a year, + * while `uu` pads single digit years to 2 characters and returns other years unchanged: + * + * | Year | `yy` | `uu` | + * |------|------|------| + * | 1 | 01 | 01 | + * | 14 | 14 | 14 | + * | 376 | 76 | 376 | + * | 1453 | 53 | 1453 | + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear) + * and [getWeekYear](https://date-fns.org/docs/getWeekYear)). + * + * 6. Specific non-location timezones are currently unavailable in `date-fns`, + * so right now these tokens fall back to GMT timezones. + * + * 7. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `t`: seconds timestamp + * - `T`: milliseconds timestamp + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. + * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month. + * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * @param date - The original date + * @param format - The string of tokens + * @param options - An object with options + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @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 + * @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 + * @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 + * @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 + * @throws format string contains an unescaped latin alphabet character + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * import { eoLocale } from 'date-fns/locale/eo' + * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { + * locale: eoLocale + * }) + * //=> '2-a de julio 2014' + * + * @example + * // Escape string by single quote characters: + * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") + * //=> "3 o'clock" + */ +function format(date, formatStr, options) { + const defaultOptions = (0, _index2.getDefaultOptions)(); + const locale = + options?.locale ?? defaultOptions.locale ?? _index.defaultLocale; + + const firstWeekContainsDate = + options?.firstWeekContainsDate ?? + options?.locale?.options?.firstWeekContainsDate ?? + defaultOptions.firstWeekContainsDate ?? + defaultOptions.locale?.options?.firstWeekContainsDate ?? + 1; + + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const originalDate = (0, _index7.toDate)(date, options?.in); + + if (!(0, _index6.isValid)(originalDate)) { + throw new RangeError("Invalid time value"); + } + + let parts = formatStr + .match(longFormattingTokensRegExp) + .map((substring) => { + const firstCharacter = substring[0]; + if (firstCharacter === "p" || firstCharacter === "P") { + const longFormatter = _index4.longFormatters[firstCharacter]; + return longFormatter(substring, locale.formatLong); + } + return substring; + }) + .join("") + .match(formattingTokensRegExp) + .map((substring) => { + // Replace two single quote characters with one single quote character + if (substring === "''") { + return { isToken: false, value: "'" }; + } + + const firstCharacter = substring[0]; + if (firstCharacter === "'") { + return { isToken: false, value: cleanEscapedString(substring) }; + } + + if (_index3.formatters[firstCharacter]) { + return { isToken: true, value: substring }; + } + + if (firstCharacter.match(unescapedLatinCharacterRegExp)) { + throw new RangeError( + "Format string contains an unescaped latin alphabet character `" + + firstCharacter + + "`", + ); + } + + return { isToken: false, value: substring }; + }); + + // invoke localize preprocessor (only for french locales at the moment) + if (locale.localize.preprocessor) { + parts = locale.localize.preprocessor(originalDate, parts); + } + + const formatterOptions = { + firstWeekContainsDate, + weekStartsOn, + locale, + }; + + return parts + .map((part) => { + if (!part.isToken) return part.value; + + const token = part.value; + + if ( + (!options?.useAdditionalWeekYearTokens && + (0, _index5.isProtectedWeekYearToken)(token)) || + (!options?.useAdditionalDayOfYearTokens && + (0, _index5.isProtectedDayOfYearToken)(token)) + ) { + (0, _index5.warnOrThrowProtectedError)(token, formatStr, String(date)); + } + + const formatter = _index3.formatters[token[0]]; + return formatter(originalDate, token, locale.localize, formatterOptions); + }) + .join(""); +} + +function cleanEscapedString(input) { + const matched = input.match(escapedStringRegExp); + + if (!matched) { + return input; + } + + return matched[1].replace(doubleQuoteRegExp, "'"); +} diff --git a/node_modules/date-fns/format.d.cts b/node_modules/date-fns/format.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..f832adf552be8a21ddad7b400fe7a3e1918ceac5 --- /dev/null +++ b/node_modules/date-fns/format.d.cts @@ -0,0 +1,311 @@ +import { formatters } from "./_lib/format/formatters.ts"; +import { longFormatters } from "./_lib/format/longFormatters.ts"; +import type { + AdditionalTokensOptions, + ContextOptions, + DateArg, + FirstWeekContainsDateOptions, + LocalizedOptions, + WeekOptions, +} from "./types.ts"; +export { formatters, longFormatters }; +export { format as formatDate }; +export type { FormatOptions as FormatDateOptions }; +/** + * The {@link format} function options. + */ +export interface FormatOptions + extends LocalizedOptions<"options" | "localize" | "formatLong">, + WeekOptions, + FirstWeekContainsDateOptions, + AdditionalTokensOptions, + ContextOptions {} +/** + * @name format + * @alias formatDate + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. The result may vary by locale. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * The characters wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * (see the last example) + * + * Format of the string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 7 below the table). + * + * Accepted patterns: + * | Unit | Pattern | Result examples | Notes | + * |---------------------------------|---------|-----------------------------------|-------| + * | Era | G..GGG | AD, BC | | + * | | GGGG | Anno Domini, Before Christ | 2 | + * | | GGGGG | A, B | | + * | Calendar year | y | 44, 1, 1900, 2017 | 5 | + * | | yo | 44th, 1st, 0th, 17th | 5,7 | + * | | yy | 44, 01, 00, 17 | 5 | + * | | yyy | 044, 001, 1900, 2017 | 5 | + * | | yyyy | 0044, 0001, 1900, 2017 | 5 | + * | | yyyyy | ... | 3,5 | + * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | + * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | + * | | YY | 44, 01, 00, 17 | 5,8 | + * | | YYY | 044, 001, 1900, 2017 | 5 | + * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | + * | | YYYYY | ... | 3,5 | + * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | + * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | + * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | + * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | + * | | RRRRR | ... | 3,5,7 | + * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | + * | | uu | -43, 01, 1900, 2017 | 5 | + * | | uuu | -043, 001, 1900, 2017 | 5 | + * | | uuuu | -0043, 0001, 1900, 2017 | 5 | + * | | uuuuu | ... | 3,5 | + * | Quarter (formatting) | Q | 1, 2, 3, 4 | | + * | | Qo | 1st, 2nd, 3rd, 4th | 7 | + * | | QQ | 01, 02, 03, 04 | | + * | | QQQ | Q1, Q2, Q3, Q4 | | + * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | + * | | qo | 1st, 2nd, 3rd, 4th | 7 | + * | | qq | 01, 02, 03, 04 | | + * | | qqq | Q1, Q2, Q3, Q4 | | + * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | qqqqq | 1, 2, 3, 4 | 4 | + * | Month (formatting) | M | 1, 2, ..., 12 | | + * | | Mo | 1st, 2nd, ..., 12th | 7 | + * | | MM | 01, 02, ..., 12 | | + * | | MMM | Jan, Feb, ..., Dec | | + * | | MMMM | January, February, ..., December | 2 | + * | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | L | 1, 2, ..., 12 | | + * | | Lo | 1st, 2nd, ..., 12th | 7 | + * | | LL | 01, 02, ..., 12 | | + * | | LLL | Jan, Feb, ..., Dec | | + * | | LLLL | January, February, ..., December | 2 | + * | | LLLLL | J, F, ..., D | | + * | Local week of year | w | 1, 2, ..., 53 | | + * | | wo | 1st, 2nd, ..., 53th | 7 | + * | | ww | 01, 02, ..., 53 | | + * | ISO week of year | I | 1, 2, ..., 53 | 7 | + * | | Io | 1st, 2nd, ..., 53th | 7 | + * | | II | 01, 02, ..., 53 | 7 | + * | Day of month | d | 1, 2, ..., 31 | | + * | | do | 1st, 2nd, ..., 31st | 7 | + * | | dd | 01, 02, ..., 31 | | + * | Day of year | D | 1, 2, ..., 365, 366 | 9 | + * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | + * | | DD | 01, 02, ..., 365, 366 | 9 | + * | | DDD | 001, 002, ..., 365, 366 | | + * | | DDDD | ... | 3 | + * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | EEEEE | M, T, W, T, F, S, S | | + * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | + * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | + * | | io | 1st, 2nd, ..., 7th | 7 | + * | | ii | 01, 02, ..., 07 | 7 | + * | | iii | Mon, Tue, Wed, ..., Sun | 7 | + * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | + * | | iiiii | M, T, W, T, F, S, S | 7 | + * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 | + * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | + * | | eo | 2nd, 3rd, ..., 1st | 7 | + * | | ee | 02, 03, ..., 01 | | + * | | eee | Mon, Tue, Wed, ..., Sun | | + * | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | eeeee | M, T, W, T, F, S, S | | + * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | + * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | + * | | co | 2nd, 3rd, ..., 1st | 7 | + * | | cc | 02, 03, ..., 01 | | + * | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | ccccc | M, T, W, T, F, S, S | | + * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | + * | AM, PM | a..aa | AM, PM | | + * | | aaa | am, pm | | + * | | aaaa | a.m., p.m. | 2 | + * | | aaaaa | a, p | | + * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | + * | | bbb | am, pm, noon, midnight | | + * | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | bbbbb | a, p, n, mi | | + * | Flexible day period | B..BBB | at night, in the morning, ... | | + * | | BBBB | at night, in the morning, ... | 2 | + * | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | + * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | + * | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | + * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | + * | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | + * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | + * | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | + * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | + * | | kk | 24, 01, 02, ..., 23 | | + * | Minute | m | 0, 1, ..., 59 | | + * | | mo | 0th, 1st, ..., 59th | 7 | + * | | mm | 00, 01, ..., 59 | | + * | Second | s | 0, 1, ..., 59 | | + * | | so | 0th, 1st, ..., 59th | 7 | + * | | ss | 00, 01, ..., 59 | | + * | Fraction of second | S | 0, 1, ..., 9 | | + * | | SS | 00, 01, ..., 99 | | + * | | SSS | 000, 001, ..., 999 | | + * | | SSSS | ... | 3 | + * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | + * | | XX | -0800, +0530, Z | | + * | | XXX | -08:00, +05:30, Z | | + * | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | + * | | xx | -0800, +0530, +0000 | | + * | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | xxxx | -0800, +0530, +0000, +123456 | | + * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | + * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | + * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | + * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | + * | Seconds timestamp | t | 512969520 | 7 | + * | | tt | ... | 3,7 | + * | Milliseconds timestamp | T | 512969520900 | 7 | + * | | TT | ... | 3,7 | + * | Long localized date | P | 04/29/1453 | 7 | + * | | PP | Apr 29, 1453 | 7 | + * | | PPP | April 29th, 1453 | 7 | + * | | PPPP | Friday, April 29th, 1453 | 2,7 | + * | Long localized time | p | 12:00 AM | 7 | + * | | pp | 12:00:00 AM | 7 | + * | | ppp | 12:00:00 AM GMT+2 | 7 | + * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | + * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | + * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | + * | | PPPppp | April 29th, 1453 at ... | 7 | + * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) + * the output will be the same as default pattern for this unit, usually + * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units + * are marked with "2" in the last column of the table. + * + * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` + * + * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` + * + * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` + * + * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). + * The output will be padded with zeros to match the length of the pattern. + * + * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` + * + * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 5. The main difference between `y` and `u` patterns are B.C. years: + * + * | Year | `y` | `u` | + * |------|-----|-----| + * | AC 1 | 1 | 1 | + * | BC 1 | 1 | 0 | + * | BC 2 | 2 | -1 | + * + * Also `yy` always returns the last two digits of a year, + * while `uu` pads single digit years to 2 characters and returns other years unchanged: + * + * | Year | `yy` | `uu` | + * |------|------|------| + * | 1 | 01 | 01 | + * | 14 | 14 | 14 | + * | 376 | 76 | 376 | + * | 1453 | 53 | 1453 | + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear) + * and [getWeekYear](https://date-fns.org/docs/getWeekYear)). + * + * 6. Specific non-location timezones are currently unavailable in `date-fns`, + * so right now these tokens fall back to GMT timezones. + * + * 7. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `t`: seconds timestamp + * - `T`: milliseconds timestamp + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. + * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month. + * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * @param date - The original date + * @param format - The string of tokens + * @param options - An object with options + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @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 + * @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 + * @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 + * @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 + * @throws format string contains an unescaped latin alphabet character + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * import { eoLocale } from 'date-fns/locale/eo' + * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { + * locale: eoLocale + * }) + * //=> '2-a de julio 2014' + * + * @example + * // Escape string by single quote characters: + * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") + * //=> "3 o'clock" + */ +export declare function format( + date: DateArg & {}, + formatStr: string, + options?: FormatOptions, +): string; diff --git a/node_modules/date-fns/format.d.ts b/node_modules/date-fns/format.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f832adf552be8a21ddad7b400fe7a3e1918ceac5 --- /dev/null +++ b/node_modules/date-fns/format.d.ts @@ -0,0 +1,311 @@ +import { formatters } from "./_lib/format/formatters.ts"; +import { longFormatters } from "./_lib/format/longFormatters.ts"; +import type { + AdditionalTokensOptions, + ContextOptions, + DateArg, + FirstWeekContainsDateOptions, + LocalizedOptions, + WeekOptions, +} from "./types.ts"; +export { formatters, longFormatters }; +export { format as formatDate }; +export type { FormatOptions as FormatDateOptions }; +/** + * The {@link format} function options. + */ +export interface FormatOptions + extends LocalizedOptions<"options" | "localize" | "formatLong">, + WeekOptions, + FirstWeekContainsDateOptions, + AdditionalTokensOptions, + ContextOptions {} +/** + * @name format + * @alias formatDate + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. The result may vary by locale. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * The characters wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * (see the last example) + * + * Format of the string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 7 below the table). + * + * Accepted patterns: + * | Unit | Pattern | Result examples | Notes | + * |---------------------------------|---------|-----------------------------------|-------| + * | Era | G..GGG | AD, BC | | + * | | GGGG | Anno Domini, Before Christ | 2 | + * | | GGGGG | A, B | | + * | Calendar year | y | 44, 1, 1900, 2017 | 5 | + * | | yo | 44th, 1st, 0th, 17th | 5,7 | + * | | yy | 44, 01, 00, 17 | 5 | + * | | yyy | 044, 001, 1900, 2017 | 5 | + * | | yyyy | 0044, 0001, 1900, 2017 | 5 | + * | | yyyyy | ... | 3,5 | + * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | + * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | + * | | YY | 44, 01, 00, 17 | 5,8 | + * | | YYY | 044, 001, 1900, 2017 | 5 | + * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | + * | | YYYYY | ... | 3,5 | + * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | + * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | + * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | + * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | + * | | RRRRR | ... | 3,5,7 | + * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | + * | | uu | -43, 01, 1900, 2017 | 5 | + * | | uuu | -043, 001, 1900, 2017 | 5 | + * | | uuuu | -0043, 0001, 1900, 2017 | 5 | + * | | uuuuu | ... | 3,5 | + * | Quarter (formatting) | Q | 1, 2, 3, 4 | | + * | | Qo | 1st, 2nd, 3rd, 4th | 7 | + * | | QQ | 01, 02, 03, 04 | | + * | | QQQ | Q1, Q2, Q3, Q4 | | + * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | + * | | qo | 1st, 2nd, 3rd, 4th | 7 | + * | | qq | 01, 02, 03, 04 | | + * | | qqq | Q1, Q2, Q3, Q4 | | + * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | qqqqq | 1, 2, 3, 4 | 4 | + * | Month (formatting) | M | 1, 2, ..., 12 | | + * | | Mo | 1st, 2nd, ..., 12th | 7 | + * | | MM | 01, 02, ..., 12 | | + * | | MMM | Jan, Feb, ..., Dec | | + * | | MMMM | January, February, ..., December | 2 | + * | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | L | 1, 2, ..., 12 | | + * | | Lo | 1st, 2nd, ..., 12th | 7 | + * | | LL | 01, 02, ..., 12 | | + * | | LLL | Jan, Feb, ..., Dec | | + * | | LLLL | January, February, ..., December | 2 | + * | | LLLLL | J, F, ..., D | | + * | Local week of year | w | 1, 2, ..., 53 | | + * | | wo | 1st, 2nd, ..., 53th | 7 | + * | | ww | 01, 02, ..., 53 | | + * | ISO week of year | I | 1, 2, ..., 53 | 7 | + * | | Io | 1st, 2nd, ..., 53th | 7 | + * | | II | 01, 02, ..., 53 | 7 | + * | Day of month | d | 1, 2, ..., 31 | | + * | | do | 1st, 2nd, ..., 31st | 7 | + * | | dd | 01, 02, ..., 31 | | + * | Day of year | D | 1, 2, ..., 365, 366 | 9 | + * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | + * | | DD | 01, 02, ..., 365, 366 | 9 | + * | | DDD | 001, 002, ..., 365, 366 | | + * | | DDDD | ... | 3 | + * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | EEEEE | M, T, W, T, F, S, S | | + * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | + * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | + * | | io | 1st, 2nd, ..., 7th | 7 | + * | | ii | 01, 02, ..., 07 | 7 | + * | | iii | Mon, Tue, Wed, ..., Sun | 7 | + * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | + * | | iiiii | M, T, W, T, F, S, S | 7 | + * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 | + * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | + * | | eo | 2nd, 3rd, ..., 1st | 7 | + * | | ee | 02, 03, ..., 01 | | + * | | eee | Mon, Tue, Wed, ..., Sun | | + * | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | eeeee | M, T, W, T, F, S, S | | + * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | + * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | + * | | co | 2nd, 3rd, ..., 1st | 7 | + * | | cc | 02, 03, ..., 01 | | + * | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | ccccc | M, T, W, T, F, S, S | | + * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | + * | AM, PM | a..aa | AM, PM | | + * | | aaa | am, pm | | + * | | aaaa | a.m., p.m. | 2 | + * | | aaaaa | a, p | | + * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | + * | | bbb | am, pm, noon, midnight | | + * | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | bbbbb | a, p, n, mi | | + * | Flexible day period | B..BBB | at night, in the morning, ... | | + * | | BBBB | at night, in the morning, ... | 2 | + * | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | + * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | + * | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | + * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | + * | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | + * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | + * | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | + * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | + * | | kk | 24, 01, 02, ..., 23 | | + * | Minute | m | 0, 1, ..., 59 | | + * | | mo | 0th, 1st, ..., 59th | 7 | + * | | mm | 00, 01, ..., 59 | | + * | Second | s | 0, 1, ..., 59 | | + * | | so | 0th, 1st, ..., 59th | 7 | + * | | ss | 00, 01, ..., 59 | | + * | Fraction of second | S | 0, 1, ..., 9 | | + * | | SS | 00, 01, ..., 99 | | + * | | SSS | 000, 001, ..., 999 | | + * | | SSSS | ... | 3 | + * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | + * | | XX | -0800, +0530, Z | | + * | | XXX | -08:00, +05:30, Z | | + * | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | + * | | xx | -0800, +0530, +0000 | | + * | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | xxxx | -0800, +0530, +0000, +123456 | | + * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | + * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | + * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | + * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | + * | Seconds timestamp | t | 512969520 | 7 | + * | | tt | ... | 3,7 | + * | Milliseconds timestamp | T | 512969520900 | 7 | + * | | TT | ... | 3,7 | + * | Long localized date | P | 04/29/1453 | 7 | + * | | PP | Apr 29, 1453 | 7 | + * | | PPP | April 29th, 1453 | 7 | + * | | PPPP | Friday, April 29th, 1453 | 2,7 | + * | Long localized time | p | 12:00 AM | 7 | + * | | pp | 12:00:00 AM | 7 | + * | | ppp | 12:00:00 AM GMT+2 | 7 | + * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | + * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | + * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | + * | | PPPppp | April 29th, 1453 at ... | 7 | + * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) + * the output will be the same as default pattern for this unit, usually + * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units + * are marked with "2" in the last column of the table. + * + * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` + * + * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` + * + * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` + * + * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). + * The output will be padded with zeros to match the length of the pattern. + * + * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` + * + * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 5. The main difference between `y` and `u` patterns are B.C. years: + * + * | Year | `y` | `u` | + * |------|-----|-----| + * | AC 1 | 1 | 1 | + * | BC 1 | 1 | 0 | + * | BC 2 | 2 | -1 | + * + * Also `yy` always returns the last two digits of a year, + * while `uu` pads single digit years to 2 characters and returns other years unchanged: + * + * | Year | `yy` | `uu` | + * |------|------|------| + * | 1 | 01 | 01 | + * | 14 | 14 | 14 | + * | 376 | 76 | 376 | + * | 1453 | 53 | 1453 | + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear) + * and [getWeekYear](https://date-fns.org/docs/getWeekYear)). + * + * 6. Specific non-location timezones are currently unavailable in `date-fns`, + * so right now these tokens fall back to GMT timezones. + * + * 7. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `t`: seconds timestamp + * - `T`: milliseconds timestamp + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. + * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month. + * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * @param date - The original date + * @param format - The string of tokens + * @param options - An object with options + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @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 + * @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 + * @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 + * @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 + * @throws format string contains an unescaped latin alphabet character + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * import { eoLocale } from 'date-fns/locale/eo' + * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { + * locale: eoLocale + * }) + * //=> '2-a de julio 2014' + * + * @example + * // Escape string by single quote characters: + * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") + * //=> "3 o'clock" + */ +export declare function format( + date: DateArg & {}, + formatStr: string, + options?: FormatOptions, +): string; diff --git a/node_modules/date-fns/format.js b/node_modules/date-fns/format.js new file mode 100644 index 0000000000000000000000000000000000000000..0c0acbc61d6a4e5731dd18cfc1a097bb99195fb1 --- /dev/null +++ b/node_modules/date-fns/format.js @@ -0,0 +1,434 @@ +import { defaultLocale } from "./_lib/defaultLocale.js"; +import { getDefaultOptions } from "./_lib/defaultOptions.js"; +import { formatters } from "./_lib/format/formatters.js"; +import { longFormatters } from "./_lib/format/longFormatters.js"; +import { + isProtectedDayOfYearToken, + isProtectedWeekYearToken, + warnOrThrowProtectedError, +} from "./_lib/protectedTokens.js"; +import { isValid } from "./isValid.js"; +import { toDate } from "./toDate.js"; + +// Rexports of internal for libraries to use. +// See: https://github.com/date-fns/date-fns/issues/3638#issuecomment-1877082874 +export { formatters, longFormatters }; + +// This RegExp consists of three parts separated by `|`: +// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token +// (one of the certain letters followed by `o`) +// - (\w)\1* matches any sequences of the same letter +// - '' matches two quote characters in a row +// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('), +// except a single quote symbol, which ends the sequence. +// Two quote characters do not end the sequence. +// If there is no matching single quote +// then the sequence will continue until the end of the string. +// - . matches any single character unmatched by previous parts of the RegExps +const formattingTokensRegExp = + /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; + +// This RegExp catches symbols escaped by quotes, and also +// sequences of symbols P, p, and the combinations like `PPPPPPPppppp` +const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; + +const escapedStringRegExp = /^'([^]*?)'?$/; +const doubleQuoteRegExp = /''/g; +const unescapedLatinCharacterRegExp = /[a-zA-Z]/; + +export { format as formatDate }; + +/** + * The {@link format} function options. + */ + +/** + * @name format + * @alias formatDate + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. The result may vary by locale. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * The characters wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * (see the last example) + * + * Format of the string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 7 below the table). + * + * Accepted patterns: + * | Unit | Pattern | Result examples | Notes | + * |---------------------------------|---------|-----------------------------------|-------| + * | Era | G..GGG | AD, BC | | + * | | GGGG | Anno Domini, Before Christ | 2 | + * | | GGGGG | A, B | | + * | Calendar year | y | 44, 1, 1900, 2017 | 5 | + * | | yo | 44th, 1st, 0th, 17th | 5,7 | + * | | yy | 44, 01, 00, 17 | 5 | + * | | yyy | 044, 001, 1900, 2017 | 5 | + * | | yyyy | 0044, 0001, 1900, 2017 | 5 | + * | | yyyyy | ... | 3,5 | + * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 | + * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 | + * | | YY | 44, 01, 00, 17 | 5,8 | + * | | YYY | 044, 001, 1900, 2017 | 5 | + * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 | + * | | YYYYY | ... | 3,5 | + * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 | + * | | RR | -43, 00, 01, 1900, 2017 | 5,7 | + * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 | + * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 | + * | | RRRRR | ... | 3,5,7 | + * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 | + * | | uu | -43, 01, 1900, 2017 | 5 | + * | | uuu | -043, 001, 1900, 2017 | 5 | + * | | uuuu | -0043, 0001, 1900, 2017 | 5 | + * | | uuuuu | ... | 3,5 | + * | Quarter (formatting) | Q | 1, 2, 3, 4 | | + * | | Qo | 1st, 2nd, 3rd, 4th | 7 | + * | | QQ | 01, 02, 03, 04 | | + * | | QQQ | Q1, Q2, Q3, Q4 | | + * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | q | 1, 2, 3, 4 | | + * | | qo | 1st, 2nd, 3rd, 4th | 7 | + * | | qq | 01, 02, 03, 04 | | + * | | qqq | Q1, Q2, Q3, Q4 | | + * | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | qqqqq | 1, 2, 3, 4 | 4 | + * | Month (formatting) | M | 1, 2, ..., 12 | | + * | | Mo | 1st, 2nd, ..., 12th | 7 | + * | | MM | 01, 02, ..., 12 | | + * | | MMM | Jan, Feb, ..., Dec | | + * | | MMMM | January, February, ..., December | 2 | + * | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | L | 1, 2, ..., 12 | | + * | | Lo | 1st, 2nd, ..., 12th | 7 | + * | | LL | 01, 02, ..., 12 | | + * | | LLL | Jan, Feb, ..., Dec | | + * | | LLLL | January, February, ..., December | 2 | + * | | LLLLL | J, F, ..., D | | + * | Local week of year | w | 1, 2, ..., 53 | | + * | | wo | 1st, 2nd, ..., 53th | 7 | + * | | ww | 01, 02, ..., 53 | | + * | ISO week of year | I | 1, 2, ..., 53 | 7 | + * | | Io | 1st, 2nd, ..., 53th | 7 | + * | | II | 01, 02, ..., 53 | 7 | + * | Day of month | d | 1, 2, ..., 31 | | + * | | do | 1st, 2nd, ..., 31st | 7 | + * | | dd | 01, 02, ..., 31 | | + * | Day of year | D | 1, 2, ..., 365, 366 | 9 | + * | | Do | 1st, 2nd, ..., 365th, 366th | 7 | + * | | DD | 01, 02, ..., 365, 366 | 9 | + * | | DDD | 001, 002, ..., 365, 366 | | + * | | DDDD | ... | 3 | + * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | EEEEE | M, T, W, T, F, S, S | | + * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | + * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 | + * | | io | 1st, 2nd, ..., 7th | 7 | + * | | ii | 01, 02, ..., 07 | 7 | + * | | iii | Mon, Tue, Wed, ..., Sun | 7 | + * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 | + * | | iiiii | M, T, W, T, F, S, S | 7 | + * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 | + * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | | + * | | eo | 2nd, 3rd, ..., 1st | 7 | + * | | ee | 02, 03, ..., 01 | | + * | | eee | Mon, Tue, Wed, ..., Sun | | + * | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | eeeee | M, T, W, T, F, S, S | | + * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | + * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | | + * | | co | 2nd, 3rd, ..., 1st | 7 | + * | | cc | 02, 03, ..., 01 | | + * | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | ccccc | M, T, W, T, F, S, S | | + * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | + * | AM, PM | a..aa | AM, PM | | + * | | aaa | am, pm | | + * | | aaaa | a.m., p.m. | 2 | + * | | aaaaa | a, p | | + * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | | + * | | bbb | am, pm, noon, midnight | | + * | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | bbbbb | a, p, n, mi | | + * | Flexible day period | B..BBB | at night, in the morning, ... | | + * | | BBBB | at night, in the morning, ... | 2 | + * | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | h | 1, 2, ..., 11, 12 | | + * | | ho | 1st, 2nd, ..., 11th, 12th | 7 | + * | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | H | 0, 1, 2, ..., 23 | | + * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 | + * | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | K | 1, 2, ..., 11, 0 | | + * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 | + * | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | k | 24, 1, 2, ..., 23 | | + * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 | + * | | kk | 24, 01, 02, ..., 23 | | + * | Minute | m | 0, 1, ..., 59 | | + * | | mo | 0th, 1st, ..., 59th | 7 | + * | | mm | 00, 01, ..., 59 | | + * | Second | s | 0, 1, ..., 59 | | + * | | so | 0th, 1st, ..., 59th | 7 | + * | | ss | 00, 01, ..., 59 | | + * | Fraction of second | S | 0, 1, ..., 9 | | + * | | SS | 00, 01, ..., 99 | | + * | | SSS | 000, 001, ..., 999 | | + * | | SSSS | ... | 3 | + * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | | + * | | XX | -0800, +0530, Z | | + * | | XXX | -08:00, +05:30, Z | | + * | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | | + * | | xx | -0800, +0530, +0000 | | + * | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | xxxx | -0800, +0530, +0000, +123456 | | + * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | | + * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 | + * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 | + * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 | + * | Seconds timestamp | t | 512969520 | 7 | + * | | tt | ... | 3,7 | + * | Milliseconds timestamp | T | 512969520900 | 7 | + * | | TT | ... | 3,7 | + * | Long localized date | P | 04/29/1453 | 7 | + * | | PP | Apr 29, 1453 | 7 | + * | | PPP | April 29th, 1453 | 7 | + * | | PPPP | Friday, April 29th, 1453 | 2,7 | + * | Long localized time | p | 12:00 AM | 7 | + * | | pp | 12:00:00 AM | 7 | + * | | ppp | 12:00:00 AM GMT+2 | 7 | + * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 | + * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 | + * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 | + * | | PPPppp | April 29th, 1453 at ... | 7 | + * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`) + * the output will be the same as default pattern for this unit, usually + * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units + * are marked with "2" in the last column of the table. + * + * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'` + * + * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'` + * + * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'` + * + * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'` + * + * 3. Some patterns could be unlimited length (such as `yyyyyyyy`). + * The output will be padded with zeros to match the length of the pattern. + * + * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'` + * + * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 5. The main difference between `y` and `u` patterns are B.C. years: + * + * | Year | `y` | `u` | + * |------|-----|-----| + * | AC 1 | 1 | 1 | + * | BC 1 | 1 | 0 | + * | BC 2 | 2 | -1 | + * + * Also `yy` always returns the last two digits of a year, + * while `uu` pads single digit years to 2 characters and returns other years unchanged: + * + * | Year | `yy` | `uu` | + * |------|------|------| + * | 1 | 01 | 01 | + * | 14 | 14 | 14 | + * | 376 | 76 | 376 | + * | 1453 | 53 | 1453 | + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear) + * and [getWeekYear](https://date-fns.org/docs/getWeekYear)). + * + * 6. Specific non-location timezones are currently unavailable in `date-fns`, + * so right now these tokens fall back to GMT timezones. + * + * 7. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `t`: seconds timestamp + * - `T`: milliseconds timestamp + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years. + * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month. + * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * @param date - The original date + * @param format - The string of tokens + * @param options - An object with options + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @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 + * @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 + * @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 + * @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 + * @throws format string contains an unescaped latin alphabet character + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy') + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * import { eoLocale } from 'date-fns/locale/eo' + * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", { + * locale: eoLocale + * }) + * //=> '2-a de julio 2014' + * + * @example + * // Escape string by single quote characters: + * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'") + * //=> "3 o'clock" + */ +export function format(date, formatStr, options) { + const defaultOptions = getDefaultOptions(); + const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale; + + const firstWeekContainsDate = + options?.firstWeekContainsDate ?? + options?.locale?.options?.firstWeekContainsDate ?? + defaultOptions.firstWeekContainsDate ?? + defaultOptions.locale?.options?.firstWeekContainsDate ?? + 1; + + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const originalDate = toDate(date, options?.in); + + if (!isValid(originalDate)) { + throw new RangeError("Invalid time value"); + } + + let parts = formatStr + .match(longFormattingTokensRegExp) + .map((substring) => { + const firstCharacter = substring[0]; + if (firstCharacter === "p" || firstCharacter === "P") { + const longFormatter = longFormatters[firstCharacter]; + return longFormatter(substring, locale.formatLong); + } + return substring; + }) + .join("") + .match(formattingTokensRegExp) + .map((substring) => { + // Replace two single quote characters with one single quote character + if (substring === "''") { + return { isToken: false, value: "'" }; + } + + const firstCharacter = substring[0]; + if (firstCharacter === "'") { + return { isToken: false, value: cleanEscapedString(substring) }; + } + + if (formatters[firstCharacter]) { + return { isToken: true, value: substring }; + } + + if (firstCharacter.match(unescapedLatinCharacterRegExp)) { + throw new RangeError( + "Format string contains an unescaped latin alphabet character `" + + firstCharacter + + "`", + ); + } + + return { isToken: false, value: substring }; + }); + + // invoke localize preprocessor (only for french locales at the moment) + if (locale.localize.preprocessor) { + parts = locale.localize.preprocessor(originalDate, parts); + } + + const formatterOptions = { + firstWeekContainsDate, + weekStartsOn, + locale, + }; + + return parts + .map((part) => { + if (!part.isToken) return part.value; + + const token = part.value; + + if ( + (!options?.useAdditionalWeekYearTokens && + isProtectedWeekYearToken(token)) || + (!options?.useAdditionalDayOfYearTokens && + isProtectedDayOfYearToken(token)) + ) { + warnOrThrowProtectedError(token, formatStr, String(date)); + } + + const formatter = formatters[token[0]]; + return formatter(originalDate, token, locale.localize, formatterOptions); + }) + .join(""); +} + +function cleanEscapedString(input) { + const matched = input.match(escapedStringRegExp); + + if (!matched) { + return input; + } + + return matched[1].replace(doubleQuoteRegExp, "'"); +} + +// Fallback for modularized imports: +export default format; diff --git a/node_modules/date-fns/formatDistance.cjs b/node_modules/date-fns/formatDistance.cjs new file mode 100644 index 0000000000000000000000000000000000000000..b3c39e89012dfe8e1bf5d102bc28bf400c8d4a02 --- /dev/null +++ b/node_modules/date-fns/formatDistance.cjs @@ -0,0 +1,199 @@ +"use strict"; +exports.formatDistance = formatDistance; +var _index = require("./_lib/defaultLocale.cjs"); +var _index2 = require("./_lib/defaultOptions.cjs"); +var _index3 = require("./_lib/getTimezoneOffsetInMilliseconds.cjs"); +var _index4 = require("./_lib/normalizeDates.cjs"); +var _index5 = require("./compareAsc.cjs"); +var _index6 = require("./constants.cjs"); +var _index7 = require("./differenceInMonths.cjs"); +var _index8 = require("./differenceInSeconds.cjs"); + +/** + * The {@link formatDistance} function options. + */ + +/** + * @name formatDistance + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words. + * + * | Distance between dates | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance between dates | Result | + * |------------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00, including seconds? + * const result = formatDistance( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0), + * { includeSeconds: true } + * ) + * //=> 'less than 20 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> 'about 1 year ago' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> 'pli ol 1 jaro' + */ +function formatDistance(laterDate, earlierDate, options) { + const defaultOptions = (0, _index2.getDefaultOptions)(); + const locale = + options?.locale ?? defaultOptions.locale ?? _index.defaultLocale; + const minutesInAlmostTwoDays = 2520; + + const comparison = (0, _index5.compareAsc)(laterDate, earlierDate); + + if (isNaN(comparison)) throw new RangeError("Invalid time value"); + + const localizeOptions = Object.assign({}, options, { + addSuffix: options?.addSuffix, + comparison: comparison, + }); + + const [laterDate_, earlierDate_] = (0, _index4.normalizeDates)( + options?.in, + ...(comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]), + ); + + const seconds = (0, _index8.differenceInSeconds)(earlierDate_, laterDate_); + const offsetInSeconds = + ((0, _index3.getTimezoneOffsetInMilliseconds)(earlierDate_) - + (0, _index3.getTimezoneOffsetInMilliseconds)(laterDate_)) / + 1000; + const minutes = Math.round((seconds - offsetInSeconds) / 60); + let months; + + // 0 up to 2 mins + if (minutes < 2) { + if (options?.includeSeconds) { + if (seconds < 5) { + return locale.formatDistance("lessThanXSeconds", 5, localizeOptions); + } else if (seconds < 10) { + return locale.formatDistance("lessThanXSeconds", 10, localizeOptions); + } else if (seconds < 20) { + return locale.formatDistance("lessThanXSeconds", 20, localizeOptions); + } else if (seconds < 40) { + return locale.formatDistance("halfAMinute", 0, localizeOptions); + } else if (seconds < 60) { + return locale.formatDistance("lessThanXMinutes", 1, localizeOptions); + } else { + return locale.formatDistance("xMinutes", 1, localizeOptions); + } + } else { + if (minutes === 0) { + return locale.formatDistance("lessThanXMinutes", 1, localizeOptions); + } else { + return locale.formatDistance("xMinutes", minutes, localizeOptions); + } + } + + // 2 mins up to 0.75 hrs + } else if (minutes < 45) { + return locale.formatDistance("xMinutes", minutes, localizeOptions); + + // 0.75 hrs up to 1.5 hrs + } else if (minutes < 90) { + return locale.formatDistance("aboutXHours", 1, localizeOptions); + + // 1.5 hrs up to 24 hrs + } else if (minutes < _index6.minutesInDay) { + const hours = Math.round(minutes / 60); + return locale.formatDistance("aboutXHours", hours, localizeOptions); + + // 1 day up to 1.75 days + } else if (minutes < minutesInAlmostTwoDays) { + return locale.formatDistance("xDays", 1, localizeOptions); + + // 1.75 days up to 30 days + } else if (minutes < _index6.minutesInMonth) { + const days = Math.round(minutes / _index6.minutesInDay); + return locale.formatDistance("xDays", days, localizeOptions); + + // 1 month up to 2 months + } else if (minutes < _index6.minutesInMonth * 2) { + months = Math.round(minutes / _index6.minutesInMonth); + return locale.formatDistance("aboutXMonths", months, localizeOptions); + } + + months = (0, _index7.differenceInMonths)(earlierDate_, laterDate_); + + // 2 months up to 12 months + if (months < 12) { + const nearestMonth = Math.round(minutes / _index6.minutesInMonth); + return locale.formatDistance("xMonths", nearestMonth, localizeOptions); + + // 1 year up to max Date + } else { + const monthsSinceStartOfYear = months % 12; + const years = Math.trunc(months / 12); + + // N years up to 1 years 3 months + if (monthsSinceStartOfYear < 3) { + return locale.formatDistance("aboutXYears", years, localizeOptions); + + // N years 3 months up to N years 9 months + } else if (monthsSinceStartOfYear < 9) { + return locale.formatDistance("overXYears", years, localizeOptions); + + // N years 9 months up to N year 12 months + } else { + return locale.formatDistance("almostXYears", years + 1, localizeOptions); + } + } +} diff --git a/node_modules/date-fns/formatDistance.d.cts b/node_modules/date-fns/formatDistance.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..bd1d53d632c1e9baedd838a672d9f79ee5f5ac93 --- /dev/null +++ b/node_modules/date-fns/formatDistance.d.cts @@ -0,0 +1,95 @@ +import type { ContextOptions, DateArg, LocalizedOptions } from "./types.ts"; +/** + * The {@link formatDistance} function options. + */ +export interface FormatDistanceOptions + extends LocalizedOptions<"formatDistance">, + ContextOptions { + /** Distances less than a minute are more detailed */ + includeSeconds?: boolean; + /** Add "X ago"/"in X" in the locale language */ + addSuffix?: boolean; +} +/** + * @name formatDistance + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words. + * + * | Distance between dates | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance between dates | Result | + * |------------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00, including seconds? + * const result = formatDistance( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0), + * { includeSeconds: true } + * ) + * //=> 'less than 20 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> 'about 1 year ago' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> 'pli ol 1 jaro' + */ +export declare function formatDistance( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: FormatDistanceOptions, +): string; diff --git a/node_modules/date-fns/formatDistance.d.ts b/node_modules/date-fns/formatDistance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd1d53d632c1e9baedd838a672d9f79ee5f5ac93 --- /dev/null +++ b/node_modules/date-fns/formatDistance.d.ts @@ -0,0 +1,95 @@ +import type { ContextOptions, DateArg, LocalizedOptions } from "./types.ts"; +/** + * The {@link formatDistance} function options. + */ +export interface FormatDistanceOptions + extends LocalizedOptions<"formatDistance">, + ContextOptions { + /** Distances less than a minute are more detailed */ + includeSeconds?: boolean; + /** Add "X ago"/"in X" in the locale language */ + addSuffix?: boolean; +} +/** + * @name formatDistance + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words. + * + * | Distance between dates | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance between dates | Result | + * |------------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00, including seconds? + * const result = formatDistance( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0), + * { includeSeconds: true } + * ) + * //=> 'less than 20 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> 'about 1 year ago' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> 'pli ol 1 jaro' + */ +export declare function formatDistance( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: FormatDistanceOptions, +): string; diff --git a/node_modules/date-fns/formatDistance.js b/node_modules/date-fns/formatDistance.js new file mode 100644 index 0000000000000000000000000000000000000000..fcba1111732056b9c13295db1acd60595a3448e7 --- /dev/null +++ b/node_modules/date-fns/formatDistance.js @@ -0,0 +1,199 @@ +import { defaultLocale } from "./_lib/defaultLocale.js"; +import { getDefaultOptions } from "./_lib/defaultOptions.js"; +import { getTimezoneOffsetInMilliseconds } from "./_lib/getTimezoneOffsetInMilliseconds.js"; +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { compareAsc } from "./compareAsc.js"; +import { minutesInDay, minutesInMonth } from "./constants.js"; +import { differenceInMonths } from "./differenceInMonths.js"; +import { differenceInSeconds } from "./differenceInSeconds.js"; + +/** + * The {@link formatDistance} function options. + */ + +/** + * @name formatDistance + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words. + * + * | Distance between dates | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance between dates | Result | + * |------------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00, including seconds? + * const result = formatDistance( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0), + * { includeSeconds: true } + * ) + * //=> 'less than 20 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> 'about 1 year ago' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> 'pli ol 1 jaro' + */ +export function formatDistance(laterDate, earlierDate, options) { + const defaultOptions = getDefaultOptions(); + const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale; + const minutesInAlmostTwoDays = 2520; + + const comparison = compareAsc(laterDate, earlierDate); + + if (isNaN(comparison)) throw new RangeError("Invalid time value"); + + const localizeOptions = Object.assign({}, options, { + addSuffix: options?.addSuffix, + comparison: comparison, + }); + + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + ...(comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]), + ); + + const seconds = differenceInSeconds(earlierDate_, laterDate_); + const offsetInSeconds = + (getTimezoneOffsetInMilliseconds(earlierDate_) - + getTimezoneOffsetInMilliseconds(laterDate_)) / + 1000; + const minutes = Math.round((seconds - offsetInSeconds) / 60); + let months; + + // 0 up to 2 mins + if (minutes < 2) { + if (options?.includeSeconds) { + if (seconds < 5) { + return locale.formatDistance("lessThanXSeconds", 5, localizeOptions); + } else if (seconds < 10) { + return locale.formatDistance("lessThanXSeconds", 10, localizeOptions); + } else if (seconds < 20) { + return locale.formatDistance("lessThanXSeconds", 20, localizeOptions); + } else if (seconds < 40) { + return locale.formatDistance("halfAMinute", 0, localizeOptions); + } else if (seconds < 60) { + return locale.formatDistance("lessThanXMinutes", 1, localizeOptions); + } else { + return locale.formatDistance("xMinutes", 1, localizeOptions); + } + } else { + if (minutes === 0) { + return locale.formatDistance("lessThanXMinutes", 1, localizeOptions); + } else { + return locale.formatDistance("xMinutes", minutes, localizeOptions); + } + } + + // 2 mins up to 0.75 hrs + } else if (minutes < 45) { + return locale.formatDistance("xMinutes", minutes, localizeOptions); + + // 0.75 hrs up to 1.5 hrs + } else if (minutes < 90) { + return locale.formatDistance("aboutXHours", 1, localizeOptions); + + // 1.5 hrs up to 24 hrs + } else if (minutes < minutesInDay) { + const hours = Math.round(minutes / 60); + return locale.formatDistance("aboutXHours", hours, localizeOptions); + + // 1 day up to 1.75 days + } else if (minutes < minutesInAlmostTwoDays) { + return locale.formatDistance("xDays", 1, localizeOptions); + + // 1.75 days up to 30 days + } else if (minutes < minutesInMonth) { + const days = Math.round(minutes / minutesInDay); + return locale.formatDistance("xDays", days, localizeOptions); + + // 1 month up to 2 months + } else if (minutes < minutesInMonth * 2) { + months = Math.round(minutes / minutesInMonth); + return locale.formatDistance("aboutXMonths", months, localizeOptions); + } + + months = differenceInMonths(earlierDate_, laterDate_); + + // 2 months up to 12 months + if (months < 12) { + const nearestMonth = Math.round(minutes / minutesInMonth); + return locale.formatDistance("xMonths", nearestMonth, localizeOptions); + + // 1 year up to max Date + } else { + const monthsSinceStartOfYear = months % 12; + const years = Math.trunc(months / 12); + + // N years up to 1 years 3 months + if (monthsSinceStartOfYear < 3) { + return locale.formatDistance("aboutXYears", years, localizeOptions); + + // N years 3 months up to N years 9 months + } else if (monthsSinceStartOfYear < 9) { + return locale.formatDistance("overXYears", years, localizeOptions); + + // N years 9 months up to N year 12 months + } else { + return locale.formatDistance("almostXYears", years + 1, localizeOptions); + } + } +} + +// Fallback for modularized imports: +export default formatDistance; diff --git a/node_modules/date-fns/formatDistanceStrict.cjs b/node_modules/date-fns/formatDistanceStrict.cjs new file mode 100644 index 0000000000000000000000000000000000000000..60cdc4b7412542e43e7acbbaae673b9d4267e188 --- /dev/null +++ b/node_modules/date-fns/formatDistanceStrict.cjs @@ -0,0 +1,188 @@ +"use strict"; +exports.formatDistanceStrict = formatDistanceStrict; +var _index = require("./_lib/defaultLocale.cjs"); +var _index2 = require("./_lib/defaultOptions.cjs"); +var _index3 = require("./_lib/getRoundingMethod.cjs"); +var _index4 = require("./_lib/getTimezoneOffsetInMilliseconds.cjs"); +var _index5 = require("./_lib/normalizeDates.cjs"); +var _index6 = require("./compareAsc.cjs"); +var _index7 = require("./constants.cjs"); + +/** + * The {@link formatDistanceStrict} function options. + */ + +/** + * The unit used to format the distance in {@link formatDistanceStrict}. + */ + +/** + * @name formatDistanceStrict + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year' + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00? + * const result = formatDistanceStrict( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0) + * ) + * //=> '15 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> '1 year ago' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, in minutes? + * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), { + * unit: 'minute' + * }) + * //=> '525600 minutes' + * + * @example + * // What is the distance from 1 January 2015 + * // to 28 January 2015, in months, rounded up? + * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> '1 jaro' + */ + +function formatDistanceStrict(laterDate, earlierDate, options) { + const defaultOptions = (0, _index2.getDefaultOptions)(); + const locale = + options?.locale ?? defaultOptions.locale ?? _index.defaultLocale; + + const comparison = (0, _index6.compareAsc)(laterDate, earlierDate); + + if (isNaN(comparison)) { + throw new RangeError("Invalid time value"); + } + + const localizeOptions = Object.assign({}, options, { + addSuffix: options?.addSuffix, + comparison: comparison, + }); + + const [laterDate_, earlierDate_] = (0, _index5.normalizeDates)( + options?.in, + ...(comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]), + ); + + const roundingMethod = (0, _index3.getRoundingMethod)( + options?.roundingMethod ?? "round", + ); + + const milliseconds = earlierDate_.getTime() - laterDate_.getTime(); + const minutes = milliseconds / _index7.millisecondsInMinute; + + const timezoneOffset = + (0, _index4.getTimezoneOffsetInMilliseconds)(earlierDate_) - + (0, _index4.getTimezoneOffsetInMilliseconds)(laterDate_); + + // Use DST-normalized difference in minutes for years, months and days; + // use regular difference in minutes for hours, minutes and seconds. + const dstNormalizedMinutes = + (milliseconds - timezoneOffset) / _index7.millisecondsInMinute; + + const defaultUnit = options?.unit; + let unit; + if (!defaultUnit) { + if (minutes < 1) { + unit = "second"; + } else if (minutes < 60) { + unit = "minute"; + } else if (minutes < _index7.minutesInDay) { + unit = "hour"; + } else if (dstNormalizedMinutes < _index7.minutesInMonth) { + unit = "day"; + } else if (dstNormalizedMinutes < _index7.minutesInYear) { + unit = "month"; + } else { + unit = "year"; + } + } else { + unit = defaultUnit; + } + + // 0 up to 60 seconds + if (unit === "second") { + const seconds = roundingMethod(milliseconds / 1000); + return locale.formatDistance("xSeconds", seconds, localizeOptions); + + // 1 up to 60 mins + } else if (unit === "minute") { + const roundedMinutes = roundingMethod(minutes); + return locale.formatDistance("xMinutes", roundedMinutes, localizeOptions); + + // 1 up to 24 hours + } else if (unit === "hour") { + const hours = roundingMethod(minutes / 60); + return locale.formatDistance("xHours", hours, localizeOptions); + + // 1 up to 30 days + } else if (unit === "day") { + const days = roundingMethod(dstNormalizedMinutes / _index7.minutesInDay); + return locale.formatDistance("xDays", days, localizeOptions); + + // 1 up to 12 months + } else if (unit === "month") { + const months = roundingMethod( + dstNormalizedMinutes / _index7.minutesInMonth, + ); + return months === 12 && defaultUnit !== "month" + ? locale.formatDistance("xYears", 1, localizeOptions) + : locale.formatDistance("xMonths", months, localizeOptions); + + // 1 year up to max Date + } else { + const years = roundingMethod(dstNormalizedMinutes / _index7.minutesInYear); + return locale.formatDistance("xYears", years, localizeOptions); + } +} diff --git a/node_modules/date-fns/formatDistanceStrict.d.cts b/node_modules/date-fns/formatDistanceStrict.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..884aa8de704ed47520f2be18899c648ec5875234 --- /dev/null +++ b/node_modules/date-fns/formatDistanceStrict.d.cts @@ -0,0 +1,110 @@ +import type { + ContextOptions, + DateArg, + LocalizedOptions, + RoundingOptions, +} from "./types.ts"; +/** + * The {@link formatDistanceStrict} function options. + */ +export interface FormatDistanceStrictOptions + extends LocalizedOptions<"formatDistance">, + RoundingOptions, + ContextOptions { + /** Add "X ago"/"in X" in the locale language */ + addSuffix?: boolean; + /** If specified, will force the unit */ + unit?: FormatDistanceStrictUnit; +} +/** + * The unit used to format the distance in {@link formatDistanceStrict}. + */ +export type FormatDistanceStrictUnit = + | "second" + | "minute" + | "hour" + | "day" + | "month" + | "year"; +/** + * @name formatDistanceStrict + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year' + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00? + * const result = formatDistanceStrict( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0) + * ) + * //=> '15 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> '1 year ago' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, in minutes? + * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), { + * unit: 'minute' + * }) + * //=> '525600 minutes' + * + * @example + * // What is the distance from 1 January 2015 + * // to 28 January 2015, in months, rounded up? + * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> '1 jaro' + */ +export declare function formatDistanceStrict( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: FormatDistanceStrictOptions, +): string; diff --git a/node_modules/date-fns/formatDistanceStrict.d.ts b/node_modules/date-fns/formatDistanceStrict.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..884aa8de704ed47520f2be18899c648ec5875234 --- /dev/null +++ b/node_modules/date-fns/formatDistanceStrict.d.ts @@ -0,0 +1,110 @@ +import type { + ContextOptions, + DateArg, + LocalizedOptions, + RoundingOptions, +} from "./types.ts"; +/** + * The {@link formatDistanceStrict} function options. + */ +export interface FormatDistanceStrictOptions + extends LocalizedOptions<"formatDistance">, + RoundingOptions, + ContextOptions { + /** Add "X ago"/"in X" in the locale language */ + addSuffix?: boolean; + /** If specified, will force the unit */ + unit?: FormatDistanceStrictUnit; +} +/** + * The unit used to format the distance in {@link formatDistanceStrict}. + */ +export type FormatDistanceStrictUnit = + | "second" + | "minute" + | "hour" + | "day" + | "month" + | "year"; +/** + * @name formatDistanceStrict + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year' + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00? + * const result = formatDistanceStrict( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0) + * ) + * //=> '15 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> '1 year ago' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, in minutes? + * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), { + * unit: 'minute' + * }) + * //=> '525600 minutes' + * + * @example + * // What is the distance from 1 January 2015 + * // to 28 January 2015, in months, rounded up? + * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> '1 jaro' + */ +export declare function formatDistanceStrict( + laterDate: DateArg & {}, + earlierDate: DateArg & {}, + options?: FormatDistanceStrictOptions, +): string; diff --git a/node_modules/date-fns/formatDistanceStrict.js b/node_modules/date-fns/formatDistanceStrict.js new file mode 100644 index 0000000000000000000000000000000000000000..e4a99cbf5fd69f9b9f695ba1176fcff3c09d34e8 --- /dev/null +++ b/node_modules/date-fns/formatDistanceStrict.js @@ -0,0 +1,189 @@ +import { defaultLocale } from "./_lib/defaultLocale.js"; +import { getDefaultOptions } from "./_lib/defaultOptions.js"; +import { getRoundingMethod } from "./_lib/getRoundingMethod.js"; +import { getTimezoneOffsetInMilliseconds } from "./_lib/getTimezoneOffsetInMilliseconds.js"; +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { compareAsc } from "./compareAsc.js"; +import { + millisecondsInMinute, + minutesInDay, + minutesInMonth, + minutesInYear, +} from "./constants.js"; + +/** + * The {@link formatDistanceStrict} function options. + */ + +/** + * The unit used to format the distance in {@link formatDistanceStrict}. + */ + +/** + * @name formatDistanceStrict + * @category Common Helpers + * @summary Return the distance between the given dates in words. + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param laterDate - The date + * @param earlierDate - The date to compare with + * @param options - An object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year' + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // What is the distance between 2 July 2014 and 1 January 2015? + * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2)) + * //=> '6 months' + * + * @example + * // What is the distance between 1 January 2015 00:00:15 + * // and 1 January 2015 00:00:00? + * const result = formatDistanceStrict( + * new Date(2015, 0, 1, 0, 0, 15), + * new Date(2015, 0, 1, 0, 0, 0) + * ) + * //=> '15 seconds' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, with a suffix? + * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), { + * addSuffix: true + * }) + * //=> '1 year ago' + * + * @example + * // What is the distance from 1 January 2016 + * // to 1 January 2015, in minutes? + * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), { + * unit: 'minute' + * }) + * //=> '525600 minutes' + * + * @example + * // What is the distance from 1 January 2015 + * // to 28 January 2015, in months, rounded up? + * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto? + * import { eoLocale } from 'date-fns/locale/eo' + * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), { + * locale: eoLocale + * }) + * //=> '1 jaro' + */ + +export function formatDistanceStrict(laterDate, earlierDate, options) { + const defaultOptions = getDefaultOptions(); + const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale; + + const comparison = compareAsc(laterDate, earlierDate); + + if (isNaN(comparison)) { + throw new RangeError("Invalid time value"); + } + + const localizeOptions = Object.assign({}, options, { + addSuffix: options?.addSuffix, + comparison: comparison, + }); + + const [laterDate_, earlierDate_] = normalizeDates( + options?.in, + ...(comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]), + ); + + const roundingMethod = getRoundingMethod(options?.roundingMethod ?? "round"); + + const milliseconds = earlierDate_.getTime() - laterDate_.getTime(); + const minutes = milliseconds / millisecondsInMinute; + + const timezoneOffset = + getTimezoneOffsetInMilliseconds(earlierDate_) - + getTimezoneOffsetInMilliseconds(laterDate_); + + // Use DST-normalized difference in minutes for years, months and days; + // use regular difference in minutes for hours, minutes and seconds. + const dstNormalizedMinutes = + (milliseconds - timezoneOffset) / millisecondsInMinute; + + const defaultUnit = options?.unit; + let unit; + if (!defaultUnit) { + if (minutes < 1) { + unit = "second"; + } else if (minutes < 60) { + unit = "minute"; + } else if (minutes < minutesInDay) { + unit = "hour"; + } else if (dstNormalizedMinutes < minutesInMonth) { + unit = "day"; + } else if (dstNormalizedMinutes < minutesInYear) { + unit = "month"; + } else { + unit = "year"; + } + } else { + unit = defaultUnit; + } + + // 0 up to 60 seconds + if (unit === "second") { + const seconds = roundingMethod(milliseconds / 1000); + return locale.formatDistance("xSeconds", seconds, localizeOptions); + + // 1 up to 60 mins + } else if (unit === "minute") { + const roundedMinutes = roundingMethod(minutes); + return locale.formatDistance("xMinutes", roundedMinutes, localizeOptions); + + // 1 up to 24 hours + } else if (unit === "hour") { + const hours = roundingMethod(minutes / 60); + return locale.formatDistance("xHours", hours, localizeOptions); + + // 1 up to 30 days + } else if (unit === "day") { + const days = roundingMethod(dstNormalizedMinutes / minutesInDay); + return locale.formatDistance("xDays", days, localizeOptions); + + // 1 up to 12 months + } else if (unit === "month") { + const months = roundingMethod(dstNormalizedMinutes / minutesInMonth); + return months === 12 && defaultUnit !== "month" + ? locale.formatDistance("xYears", 1, localizeOptions) + : locale.formatDistance("xMonths", months, localizeOptions); + + // 1 year up to max Date + } else { + const years = roundingMethod(dstNormalizedMinutes / minutesInYear); + return locale.formatDistance("xYears", years, localizeOptions); + } +} + +// Fallback for modularized imports: +export default formatDistanceStrict; diff --git a/node_modules/date-fns/formatDistanceToNow.cjs b/node_modules/date-fns/formatDistanceToNow.cjs new file mode 100644 index 0000000000000000000000000000000000000000..810a3914f35690b3382ab2a9c9da3c38a4560eda --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNow.cjs @@ -0,0 +1,98 @@ +"use strict"; +exports.formatDistanceToNow = formatDistanceToNow; +var _index = require("./constructNow.cjs"); + +var _index2 = require("./formatDistance.cjs"); + +/** + * The {@link formatDistanceToNow} function options. + */ + +/** + * @name formatDistanceToNow + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given date and now in words. + * + * | Distance to now | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance to now | Result | + * |---------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param date - The given date + * @param options - The object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNow( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNow( + * new Date(2015, 0, 1, 0, 0, 15), + * {includeSeconds: true} + * ) + * //=> 'less than 20 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNow( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in about 1 year' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 August 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNow( + * new Date(2016, 7, 1), + * {locale: eoLocale} + * ) + * //=> 'pli ol 1 jaro' + */ +function formatDistanceToNow(date, options) { + return (0, _index2.formatDistance)( + date, + (0, _index.constructNow)(date), + options, + ); +} diff --git a/node_modules/date-fns/formatDistanceToNow.d.cts b/node_modules/date-fns/formatDistanceToNow.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..3448fdd5cd112cbf4486723b05a358b5b26ccecd --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNow.d.cts @@ -0,0 +1,93 @@ +import type { FormatDistanceOptions } from "./formatDistance.ts"; +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link formatDistanceToNow} function options. + */ +export interface FormatDistanceToNowOptions + extends FormatDistanceOptions, + ContextOptions {} +/** + * @name formatDistanceToNow + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given date and now in words. + * + * | Distance to now | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance to now | Result | + * |---------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param date - The given date + * @param options - The object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNow( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNow( + * new Date(2015, 0, 1, 0, 0, 15), + * {includeSeconds: true} + * ) + * //=> 'less than 20 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNow( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in about 1 year' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 August 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNow( + * new Date(2016, 7, 1), + * {locale: eoLocale} + * ) + * //=> 'pli ol 1 jaro' + */ +export declare function formatDistanceToNow( + date: DateArg & {}, + options?: FormatDistanceToNowOptions, +): string; diff --git a/node_modules/date-fns/formatDistanceToNow.d.ts b/node_modules/date-fns/formatDistanceToNow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3448fdd5cd112cbf4486723b05a358b5b26ccecd --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNow.d.ts @@ -0,0 +1,93 @@ +import type { FormatDistanceOptions } from "./formatDistance.ts"; +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link formatDistanceToNow} function options. + */ +export interface FormatDistanceToNowOptions + extends FormatDistanceOptions, + ContextOptions {} +/** + * @name formatDistanceToNow + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given date and now in words. + * + * | Distance to now | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance to now | Result | + * |---------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param date - The given date + * @param options - The object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNow( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNow( + * new Date(2015, 0, 1, 0, 0, 15), + * {includeSeconds: true} + * ) + * //=> 'less than 20 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNow( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in about 1 year' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 August 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNow( + * new Date(2016, 7, 1), + * {locale: eoLocale} + * ) + * //=> 'pli ol 1 jaro' + */ +export declare function formatDistanceToNow( + date: DateArg & {}, + options?: FormatDistanceToNowOptions, +): string; diff --git a/node_modules/date-fns/formatDistanceToNow.js b/node_modules/date-fns/formatDistanceToNow.js new file mode 100644 index 0000000000000000000000000000000000000000..85798ac19e870aaa5c44e4b22ee06f9af08bcc24 --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNow.js @@ -0,0 +1,95 @@ +import { constructNow } from "./constructNow.js"; + +import { formatDistance } from "./formatDistance.js"; + +/** + * The {@link formatDistanceToNow} function options. + */ + +/** + * @name formatDistanceToNow + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given date and now in words. + * + * | Distance to now | Result | + * |-------------------------------------------------------------------|---------------------| + * | 0 ... 30 secs | less than a minute | + * | 30 secs ... 1 min 30 secs | 1 minute | + * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes | + * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour | + * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours | + * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day | + * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days | + * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month | + * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months | + * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months | + * | 1 yr ... 1 yr 3 months | about 1 year | + * | 1 yr 3 months ... 1 yr 9 month s | over 1 year | + * | 1 yr 9 months ... 2 yrs | almost 2 years | + * | N yrs ... N yrs 3 months | about N years | + * | N yrs 3 months ... N yrs 9 months | over N years | + * | N yrs 9 months ... N+1 yrs | almost N+1 years | + * + * With `options.includeSeconds == true`: + * | Distance to now | Result | + * |---------------------|----------------------| + * | 0 secs ... 5 secs | less than 5 seconds | + * | 5 secs ... 10 secs | less than 10 seconds | + * | 10 secs ... 20 secs | less than 20 seconds | + * | 20 secs ... 40 secs | half a minute | + * | 40 secs ... 60 secs | less than a minute | + * | 60 secs ... 90 secs | 1 minute | + * + * @param date - The given date + * @param options - The object with options + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNow( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNow( + * new Date(2015, 0, 1, 0, 0, 15), + * {includeSeconds: true} + * ) + * //=> 'less than 20 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNow( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in about 1 year' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 August 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNow( + * new Date(2016, 7, 1), + * {locale: eoLocale} + * ) + * //=> 'pli ol 1 jaro' + */ +export function formatDistanceToNow(date, options) { + return formatDistance(date, constructNow(date), options); +} + +// Fallback for modularized imports: +export default formatDistanceToNow; diff --git a/node_modules/date-fns/formatDistanceToNowStrict.cjs b/node_modules/date-fns/formatDistanceToNowStrict.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c28c62d1511a4fb4f0eb45e61fbd801621e6a6dd --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNowStrict.cjs @@ -0,0 +1,88 @@ +"use strict"; +exports.formatDistanceToNowStrict = formatDistanceToNowStrict; +var _index = require("./constructNow.cjs"); + +var _index2 = require("./formatDistanceStrict.cjs"); + +/** + * The {@link formatDistanceToNowStrict} function options. + */ + +/** + * @name formatDistanceToNowStrict + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param date - The given date + * @param options - An object with options. + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNowStrict( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNowStrict( + * new Date(2015, 0, 1, 0, 0, 15) + * ) + * //=> '15 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in 1 year' + * + * @example + * // If today is 28 January 2015, + * // what is the distance to 1 January 2015, in months, rounded up?? + * const result = formatDistanceToNowStrict(new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {locale: eoLocale} + * ) + * //=> '1 jaro' + */ +function formatDistanceToNowStrict(date, options) { + return (0, _index2.formatDistanceStrict)( + date, + (0, _index.constructNow)(date), + options, + ); +} diff --git a/node_modules/date-fns/formatDistanceToNowStrict.d.cts b/node_modules/date-fns/formatDistanceToNowStrict.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..a3910b5bffb7a5e407a88430687a2b6f10b6ec69 --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNowStrict.d.cts @@ -0,0 +1,83 @@ +import type { FormatDistanceStrictOptions } from "./formatDistanceStrict.ts"; +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link formatDistanceToNowStrict} function options. + */ +export interface FormatDistanceToNowStrictOptions + extends FormatDistanceStrictOptions, + ContextOptions {} +/** + * @name formatDistanceToNowStrict + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param date - The given date + * @param options - An object with options. + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNowStrict( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNowStrict( + * new Date(2015, 0, 1, 0, 0, 15) + * ) + * //=> '15 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in 1 year' + * + * @example + * // If today is 28 January 2015, + * // what is the distance to 1 January 2015, in months, rounded up?? + * const result = formatDistanceToNowStrict(new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {locale: eoLocale} + * ) + * //=> '1 jaro' + */ +export declare function formatDistanceToNowStrict( + date: DateArg & {}, + options?: FormatDistanceToNowStrictOptions, +): string; diff --git a/node_modules/date-fns/formatDistanceToNowStrict.d.ts b/node_modules/date-fns/formatDistanceToNowStrict.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3910b5bffb7a5e407a88430687a2b6f10b6ec69 --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNowStrict.d.ts @@ -0,0 +1,83 @@ +import type { FormatDistanceStrictOptions } from "./formatDistanceStrict.ts"; +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link formatDistanceToNowStrict} function options. + */ +export interface FormatDistanceToNowStrictOptions + extends FormatDistanceStrictOptions, + ContextOptions {} +/** + * @name formatDistanceToNowStrict + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param date - The given date + * @param options - An object with options. + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNowStrict( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNowStrict( + * new Date(2015, 0, 1, 0, 0, 15) + * ) + * //=> '15 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in 1 year' + * + * @example + * // If today is 28 January 2015, + * // what is the distance to 1 January 2015, in months, rounded up?? + * const result = formatDistanceToNowStrict(new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {locale: eoLocale} + * ) + * //=> '1 jaro' + */ +export declare function formatDistanceToNowStrict( + date: DateArg & {}, + options?: FormatDistanceToNowStrictOptions, +): string; diff --git a/node_modules/date-fns/formatDistanceToNowStrict.js b/node_modules/date-fns/formatDistanceToNowStrict.js new file mode 100644 index 0000000000000000000000000000000000000000..8a1159fb213fd8c24d34c3c70d0d413d93966900 --- /dev/null +++ b/node_modules/date-fns/formatDistanceToNowStrict.js @@ -0,0 +1,85 @@ +import { constructNow } from "./constructNow.js"; + +import { formatDistanceStrict } from "./formatDistanceStrict.js"; + +/** + * The {@link formatDistanceToNowStrict} function options. + */ + +/** + * @name formatDistanceToNowStrict + * @category Common Helpers + * @summary Return the distance between the given date and now in words. + * @pure false + * + * @description + * Return the distance between the given dates in words, using strict units. + * This is like `formatDistance`, but does not use helpers like 'almost', 'over', + * 'less than' and the like. + * + * | Distance between dates | Result | + * |------------------------|---------------------| + * | 0 ... 59 secs | [0..59] seconds | + * | 1 ... 59 mins | [1..59] minutes | + * | 1 ... 23 hrs | [1..23] hours | + * | 1 ... 29 days | [1..29] days | + * | 1 ... 11 months | [1..11] months | + * | 1 ... N years | [1..N] years | + * + * @param date - The given date + * @param options - An object with options. + * + * @returns The distance in words + * + * @throws `date` must not be Invalid Date + * @throws `options.locale` must contain `formatDistance` property + * + * @example + * // If today is 1 January 2015, what is the distance to 2 July 2014? + * const result = formatDistanceToNowStrict( + * new Date(2014, 6, 2) + * ) + * //=> '6 months' + * + * @example + * // If now is 1 January 2015 00:00:00, + * // what is the distance to 1 January 2015 00:00:15, including seconds? + * const result = formatDistanceToNowStrict( + * new Date(2015, 0, 1, 0, 0, 15) + * ) + * //=> '15 seconds' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016, with a suffix? + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {addSuffix: true} + * ) + * //=> 'in 1 year' + * + * @example + * // If today is 28 January 2015, + * // what is the distance to 1 January 2015, in months, rounded up?? + * const result = formatDistanceToNowStrict(new Date(2015, 0, 1), { + * unit: 'month', + * roundingMethod: 'ceil' + * }) + * //=> '1 month' + * + * @example + * // If today is 1 January 2015, + * // what is the distance to 1 January 2016 in Esperanto? + * const eoLocale = require('date-fns/locale/eo') + * const result = formatDistanceToNowStrict( + * new Date(2016, 0, 1), + * {locale: eoLocale} + * ) + * //=> '1 jaro' + */ +export function formatDistanceToNowStrict(date, options) { + return formatDistanceStrict(date, constructNow(date), options); +} + +// Fallback for modularized imports: +export default formatDistanceToNowStrict; diff --git a/node_modules/date-fns/formatDuration.cjs b/node_modules/date-fns/formatDuration.cjs new file mode 100644 index 0000000000000000000000000000000000000000..3935b9c2bcfafbe4eeb8d132c74826a75dc6bbe7 --- /dev/null +++ b/node_modules/date-fns/formatDuration.cjs @@ -0,0 +1,103 @@ +"use strict"; +exports.formatDuration = formatDuration; + +var _index = require("./_lib/defaultLocale.cjs"); +var _index2 = require("./_lib/defaultOptions.cjs"); + +/** + * The {@link formatDuration} function options. + */ + +const defaultFormat = [ + "years", + "months", + "weeks", + "days", + "hours", + "minutes", + "seconds", +]; + +/** + * @name formatDuration + * @category Common Helpers + * @summary Formats a duration in human-readable format + * + * @description + * Return human-readable duration string i.e. "9 months 2 days" + * + * @param duration - The duration to format + * @param options - An object with options. + * + * @returns The formatted date string + * + * @example + * // Format full duration + * formatDuration({ + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }) + * //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds' + * + * @example + * // Format partial duration + * formatDuration({ months: 9, days: 2 }) + * //=> '9 months 2 days' + * + * @example + * // Customize the format + * formatDuration( + * { + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }, + * { format: ['months', 'weeks'] } + * ) === '9 months 1 week' + * + * @example + * // Customize the zeros presence + * formatDuration({ years: 0, months: 9 }) + * //=> '9 months' + * formatDuration({ years: 0, months: 9 }, { zero: true }) + * //=> '0 years 9 months' + * + * @example + * // Customize the delimiter + * formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' }) + * //=> '2 years, 9 months, 3 weeks' + */ +function formatDuration(duration, options) { + const defaultOptions = (0, _index2.getDefaultOptions)(); + const locale = + options?.locale ?? defaultOptions.locale ?? _index.defaultLocale; + const format = options?.format ?? defaultFormat; + const zero = options?.zero ?? false; + const delimiter = options?.delimiter ?? " "; + + if (!locale.formatDistance) { + return ""; + } + + const result = format + .reduce((acc, unit) => { + const token = `x${unit.replace(/(^.)/, (m) => m.toUpperCase())}`; + const value = duration[unit]; + if (value !== undefined && (zero || duration[unit])) { + return acc.concat(locale.formatDistance(token, value)); + } + return acc; + }, []) + .join(delimiter); + + return result; +} diff --git a/node_modules/date-fns/formatDuration.d.cts b/node_modules/date-fns/formatDuration.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..7ad7ed7e67e926516e9a3e1858fc1608cdf53238 --- /dev/null +++ b/node_modules/date-fns/formatDuration.d.cts @@ -0,0 +1,75 @@ +import type { Duration, DurationUnit, LocalizedOptions } from "./types.ts"; +/** + * The {@link formatDuration} function options. + */ +export interface FormatDurationOptions + extends LocalizedOptions<"formatDistance"> { + /** The array of units to format */ + format?: DurationUnit[]; + /** Should be zeros be included in the output? */ + zero?: boolean; + /** The delimiter string to use */ + delimiter?: string; +} +/** + * @name formatDuration + * @category Common Helpers + * @summary Formats a duration in human-readable format + * + * @description + * Return human-readable duration string i.e. "9 months 2 days" + * + * @param duration - The duration to format + * @param options - An object with options. + * + * @returns The formatted date string + * + * @example + * // Format full duration + * formatDuration({ + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }) + * //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds' + * + * @example + * // Format partial duration + * formatDuration({ months: 9, days: 2 }) + * //=> '9 months 2 days' + * + * @example + * // Customize the format + * formatDuration( + * { + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }, + * { format: ['months', 'weeks'] } + * ) === '9 months 1 week' + * + * @example + * // Customize the zeros presence + * formatDuration({ years: 0, months: 9 }) + * //=> '9 months' + * formatDuration({ years: 0, months: 9 }, { zero: true }) + * //=> '0 years 9 months' + * + * @example + * // Customize the delimiter + * formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' }) + * //=> '2 years, 9 months, 3 weeks' + */ +export declare function formatDuration( + duration: Duration, + options?: FormatDurationOptions, +): string; diff --git a/node_modules/date-fns/formatDuration.d.ts b/node_modules/date-fns/formatDuration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ad7ed7e67e926516e9a3e1858fc1608cdf53238 --- /dev/null +++ b/node_modules/date-fns/formatDuration.d.ts @@ -0,0 +1,75 @@ +import type { Duration, DurationUnit, LocalizedOptions } from "./types.ts"; +/** + * The {@link formatDuration} function options. + */ +export interface FormatDurationOptions + extends LocalizedOptions<"formatDistance"> { + /** The array of units to format */ + format?: DurationUnit[]; + /** Should be zeros be included in the output? */ + zero?: boolean; + /** The delimiter string to use */ + delimiter?: string; +} +/** + * @name formatDuration + * @category Common Helpers + * @summary Formats a duration in human-readable format + * + * @description + * Return human-readable duration string i.e. "9 months 2 days" + * + * @param duration - The duration to format + * @param options - An object with options. + * + * @returns The formatted date string + * + * @example + * // Format full duration + * formatDuration({ + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }) + * //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds' + * + * @example + * // Format partial duration + * formatDuration({ months: 9, days: 2 }) + * //=> '9 months 2 days' + * + * @example + * // Customize the format + * formatDuration( + * { + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }, + * { format: ['months', 'weeks'] } + * ) === '9 months 1 week' + * + * @example + * // Customize the zeros presence + * formatDuration({ years: 0, months: 9 }) + * //=> '9 months' + * formatDuration({ years: 0, months: 9 }, { zero: true }) + * //=> '0 years 9 months' + * + * @example + * // Customize the delimiter + * formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' }) + * //=> '2 years, 9 months, 3 weeks' + */ +export declare function formatDuration( + duration: Duration, + options?: FormatDurationOptions, +): string; diff --git a/node_modules/date-fns/formatDuration.js b/node_modules/date-fns/formatDuration.js new file mode 100644 index 0000000000000000000000000000000000000000..dd06f16ebd92e2b4f5abc19d55f18cdfc5f3fc0a --- /dev/null +++ b/node_modules/date-fns/formatDuration.js @@ -0,0 +1,102 @@ +import { defaultLocale } from "./_lib/defaultLocale.js"; +import { getDefaultOptions } from "./_lib/defaultOptions.js"; + +/** + * The {@link formatDuration} function options. + */ + +const defaultFormat = [ + "years", + "months", + "weeks", + "days", + "hours", + "minutes", + "seconds", +]; + +/** + * @name formatDuration + * @category Common Helpers + * @summary Formats a duration in human-readable format + * + * @description + * Return human-readable duration string i.e. "9 months 2 days" + * + * @param duration - The duration to format + * @param options - An object with options. + * + * @returns The formatted date string + * + * @example + * // Format full duration + * formatDuration({ + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }) + * //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds' + * + * @example + * // Format partial duration + * formatDuration({ months: 9, days: 2 }) + * //=> '9 months 2 days' + * + * @example + * // Customize the format + * formatDuration( + * { + * years: 2, + * months: 9, + * weeks: 1, + * days: 7, + * hours: 5, + * minutes: 9, + * seconds: 30 + * }, + * { format: ['months', 'weeks'] } + * ) === '9 months 1 week' + * + * @example + * // Customize the zeros presence + * formatDuration({ years: 0, months: 9 }) + * //=> '9 months' + * formatDuration({ years: 0, months: 9 }, { zero: true }) + * //=> '0 years 9 months' + * + * @example + * // Customize the delimiter + * formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' }) + * //=> '2 years, 9 months, 3 weeks' + */ +export function formatDuration(duration, options) { + const defaultOptions = getDefaultOptions(); + const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale; + const format = options?.format ?? defaultFormat; + const zero = options?.zero ?? false; + const delimiter = options?.delimiter ?? " "; + + if (!locale.formatDistance) { + return ""; + } + + const result = format + .reduce((acc, unit) => { + const token = `x${unit.replace(/(^.)/, (m) => m.toUpperCase())}`; + const value = duration[unit]; + if (value !== undefined && (zero || duration[unit])) { + return acc.concat(locale.formatDistance(token, value)); + } + return acc; + }, []) + .join(delimiter); + + return result; +} + +// Fallback for modularized imports: +export default formatDuration; diff --git a/node_modules/date-fns/formatISO.cjs b/node_modules/date-fns/formatISO.cjs new file mode 100644 index 0000000000000000000000000000000000000000..15c76dddd27d3f733452c8b76c3efeedec355e94 --- /dev/null +++ b/node_modules/date-fns/formatISO.cjs @@ -0,0 +1,106 @@ +"use strict"; +exports.formatISO = formatISO; +var _index = require("./_lib/addLeadingZeros.cjs"); +var _index2 = require("./toDate.cjs"); + +/** + * The {@link formatISO} function options. + */ + +/** + * @name formatISO + * @category Common Helpers + * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm). + * + * @description + * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string (in local time zone) + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918T190052' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, date only: + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52Z' + */ +function formatISO(date, options) { + const date_ = (0, _index2.toDate)(date, options?.in); + + if (isNaN(+date_)) { + throw new RangeError("Invalid time value"); + } + + const format = options?.format ?? "extended"; + const representation = options?.representation ?? "complete"; + + let result = ""; + let tzOffset = ""; + + const dateDelimiter = format === "extended" ? "-" : ""; + const timeDelimiter = format === "extended" ? ":" : ""; + + // Representation is either 'date' or 'complete' + if (representation !== "time") { + const day = (0, _index.addLeadingZeros)(date_.getDate(), 2); + const month = (0, _index.addLeadingZeros)(date_.getMonth() + 1, 2); + const year = (0, _index.addLeadingZeros)(date_.getFullYear(), 4); + + // yyyyMMdd or yyyy-MM-dd. + result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`; + } + + // Representation is either 'time' or 'complete' + if (representation !== "date") { + // Add the timezone. + const offset = date_.getTimezoneOffset(); + + if (offset !== 0) { + const absoluteOffset = Math.abs(offset); + const hourOffset = (0, _index.addLeadingZeros)( + Math.trunc(absoluteOffset / 60), + 2, + ); + const minuteOffset = (0, _index.addLeadingZeros)(absoluteOffset % 60, 2); + // If less than 0, the sign is +, because it is ahead of time. + const sign = offset < 0 ? "+" : "-"; + + tzOffset = `${sign}${hourOffset}:${minuteOffset}`; + } else { + tzOffset = "Z"; + } + + const hour = (0, _index.addLeadingZeros)(date_.getHours(), 2); + const minute = (0, _index.addLeadingZeros)(date_.getMinutes(), 2); + const second = (0, _index.addLeadingZeros)(date_.getSeconds(), 2); + + // If there's also date, separate it with time with 'T' + const separator = result === "" ? "" : "T"; + + // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined. + const time = [hour, minute, second].join(timeDelimiter); + + // HHmmss or HH:mm:ss. + result = `${result}${separator}${time}${tzOffset}`; + } + + return result; +} diff --git a/node_modules/date-fns/formatISO.d.cts b/node_modules/date-fns/formatISO.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..4d20da312a4e84475211bd1f0df6a94d1a24916c --- /dev/null +++ b/node_modules/date-fns/formatISO.d.cts @@ -0,0 +1,46 @@ +import type { ContextOptions, DateArg, ISOFormatOptions } from "./types.ts"; +/** + * The {@link formatISO} function options. + */ +export interface FormatISOOptions + extends ISOFormatOptions, + ContextOptions {} +/** + * @name formatISO + * @category Common Helpers + * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm). + * + * @description + * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string (in local time zone) + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918T190052' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, date only: + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52Z' + */ +export declare function formatISO( + date: DateArg & {}, + options?: FormatISOOptions, +): string; diff --git a/node_modules/date-fns/formatISO.d.ts b/node_modules/date-fns/formatISO.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d20da312a4e84475211bd1f0df6a94d1a24916c --- /dev/null +++ b/node_modules/date-fns/formatISO.d.ts @@ -0,0 +1,46 @@ +import type { ContextOptions, DateArg, ISOFormatOptions } from "./types.ts"; +/** + * The {@link formatISO} function options. + */ +export interface FormatISOOptions + extends ISOFormatOptions, + ContextOptions {} +/** + * @name formatISO + * @category Common Helpers + * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm). + * + * @description + * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string (in local time zone) + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918T190052' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, date only: + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52Z' + */ +export declare function formatISO( + date: DateArg & {}, + options?: FormatISOOptions, +): string; diff --git a/node_modules/date-fns/formatISO.js b/node_modules/date-fns/formatISO.js new file mode 100644 index 0000000000000000000000000000000000000000..e75177df32dce20c27d48ca2eb47665344ddcdbe --- /dev/null +++ b/node_modules/date-fns/formatISO.js @@ -0,0 +1,104 @@ +import { addLeadingZeros } from "./_lib/addLeadingZeros.js"; +import { toDate } from "./toDate.js"; + +/** + * The {@link formatISO} function options. + */ + +/** + * @name formatISO + * @category Common Helpers + * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm). + * + * @description + * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string (in local time zone) + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918T190052' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, date only: + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC): + * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52Z' + */ +export function formatISO(date, options) { + const date_ = toDate(date, options?.in); + + if (isNaN(+date_)) { + throw new RangeError("Invalid time value"); + } + + const format = options?.format ?? "extended"; + const representation = options?.representation ?? "complete"; + + let result = ""; + let tzOffset = ""; + + const dateDelimiter = format === "extended" ? "-" : ""; + const timeDelimiter = format === "extended" ? ":" : ""; + + // Representation is either 'date' or 'complete' + if (representation !== "time") { + const day = addLeadingZeros(date_.getDate(), 2); + const month = addLeadingZeros(date_.getMonth() + 1, 2); + const year = addLeadingZeros(date_.getFullYear(), 4); + + // yyyyMMdd or yyyy-MM-dd. + result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`; + } + + // Representation is either 'time' or 'complete' + if (representation !== "date") { + // Add the timezone. + const offset = date_.getTimezoneOffset(); + + if (offset !== 0) { + const absoluteOffset = Math.abs(offset); + const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2); + const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2); + // If less than 0, the sign is +, because it is ahead of time. + const sign = offset < 0 ? "+" : "-"; + + tzOffset = `${sign}${hourOffset}:${minuteOffset}`; + } else { + tzOffset = "Z"; + } + + const hour = addLeadingZeros(date_.getHours(), 2); + const minute = addLeadingZeros(date_.getMinutes(), 2); + const second = addLeadingZeros(date_.getSeconds(), 2); + + // If there's also date, separate it with time with 'T' + const separator = result === "" ? "" : "T"; + + // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined. + const time = [hour, minute, second].join(timeDelimiter); + + // HHmmss or HH:mm:ss. + result = `${result}${separator}${time}${tzOffset}`; + } + + return result; +} + +// Fallback for modularized imports: +export default formatISO; diff --git a/node_modules/date-fns/formatISO9075.cjs b/node_modules/date-fns/formatISO9075.cjs new file mode 100644 index 0000000000000000000000000000000000000000..41ccb556faaafd53c4076f3a04601f4d1468b001 --- /dev/null +++ b/node_modules/date-fns/formatISO9075.cjs @@ -0,0 +1,85 @@ +"use strict"; +exports.formatISO9075 = formatISO9075; +var _index = require("./_lib/addLeadingZeros.cjs"); +var _index2 = require("./isValid.cjs"); +var _index3 = require("./toDate.cjs"); + +/** + * The {@link formatISO9075} function options. + */ + +/** + * @name formatISO9075 + * @category Common Helpers + * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format). + * + * @description + * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 9075 format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18 19:00:52' + * + * @example + * // Represent 18 September 2019 in ISO 9075, short format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918 190052' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, date only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, time only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52' + */ +function formatISO9075(date, options) { + const date_ = (0, _index3.toDate)(date, options?.in); + + if (!(0, _index2.isValid)(date_)) { + throw new RangeError("Invalid time value"); + } + + const format = options?.format ?? "extended"; + const representation = options?.representation ?? "complete"; + + let result = ""; + + const dateDelimiter = format === "extended" ? "-" : ""; + const timeDelimiter = format === "extended" ? ":" : ""; + + // Representation is either 'date' or 'complete' + if (representation !== "time") { + const day = (0, _index.addLeadingZeros)(date_.getDate(), 2); + const month = (0, _index.addLeadingZeros)(date_.getMonth() + 1, 2); + const year = (0, _index.addLeadingZeros)(date_.getFullYear(), 4); + + // yyyyMMdd or yyyy-MM-dd. + result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`; + } + + // Representation is either 'time' or 'complete' + if (representation !== "date") { + const hour = (0, _index.addLeadingZeros)(date_.getHours(), 2); + const minute = (0, _index.addLeadingZeros)(date_.getMinutes(), 2); + const second = (0, _index.addLeadingZeros)(date_.getSeconds(), 2); + + // If there's also date, separate it with time with a space + const separator = result === "" ? "" : " "; + + // HHmmss or HH:mm:ss. + result = `${result}${separator}${hour}${timeDelimiter}${minute}${timeDelimiter}${second}`; + } + + return result; +} diff --git a/node_modules/date-fns/formatISO9075.d.cts b/node_modules/date-fns/formatISO9075.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..0a1bc8a57879874d0dd917643e4ec66bcbcec7f2 --- /dev/null +++ b/node_modules/date-fns/formatISO9075.d.cts @@ -0,0 +1,46 @@ +import type { ContextOptions, DateArg, ISOFormatOptions } from "./types.ts"; +/** + * The {@link formatISO9075} function options. + */ +export interface FormatISO9075Options + extends ISOFormatOptions, + ContextOptions {} +/** + * @name formatISO9075 + * @category Common Helpers + * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format). + * + * @description + * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 9075 format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18 19:00:52' + * + * @example + * // Represent 18 September 2019 in ISO 9075, short format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918 190052' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, date only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, time only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52' + */ +export declare function formatISO9075( + date: DateArg & {}, + options?: FormatISO9075Options, +): string; diff --git a/node_modules/date-fns/formatISO9075.d.ts b/node_modules/date-fns/formatISO9075.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a1bc8a57879874d0dd917643e4ec66bcbcec7f2 --- /dev/null +++ b/node_modules/date-fns/formatISO9075.d.ts @@ -0,0 +1,46 @@ +import type { ContextOptions, DateArg, ISOFormatOptions } from "./types.ts"; +/** + * The {@link formatISO9075} function options. + */ +export interface FormatISO9075Options + extends ISOFormatOptions, + ContextOptions {} +/** + * @name formatISO9075 + * @category Common Helpers + * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format). + * + * @description + * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 9075 format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18 19:00:52' + * + * @example + * // Represent 18 September 2019 in ISO 9075, short format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918 190052' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, date only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, time only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52' + */ +export declare function formatISO9075( + date: DateArg & {}, + options?: FormatISO9075Options, +): string; diff --git a/node_modules/date-fns/formatISO9075.js b/node_modules/date-fns/formatISO9075.js new file mode 100644 index 0000000000000000000000000000000000000000..cea94539fcafb712a7f883ca80f89fe5e42c3dff --- /dev/null +++ b/node_modules/date-fns/formatISO9075.js @@ -0,0 +1,86 @@ +import { addLeadingZeros } from "./_lib/addLeadingZeros.js"; +import { isValid } from "./isValid.js"; +import { toDate } from "./toDate.js"; + +/** + * The {@link formatISO9075} function options. + */ + +/** + * @name formatISO9075 + * @category Common Helpers + * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format). + * + * @description + * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in ISO 9075 format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18 19:00:52' + * + * @example + * // Represent 18 September 2019 in ISO 9075, short format: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' }) + * //=> '20190918 190052' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, date only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' }) + * //=> '2019-09-18' + * + * @example + * // Represent 18 September 2019 in ISO 9075 format, time only: + * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' }) + * //=> '19:00:52' + */ +export function formatISO9075(date, options) { + const date_ = toDate(date, options?.in); + + if (!isValid(date_)) { + throw new RangeError("Invalid time value"); + } + + const format = options?.format ?? "extended"; + const representation = options?.representation ?? "complete"; + + let result = ""; + + const dateDelimiter = format === "extended" ? "-" : ""; + const timeDelimiter = format === "extended" ? ":" : ""; + + // Representation is either 'date' or 'complete' + if (representation !== "time") { + const day = addLeadingZeros(date_.getDate(), 2); + const month = addLeadingZeros(date_.getMonth() + 1, 2); + const year = addLeadingZeros(date_.getFullYear(), 4); + + // yyyyMMdd or yyyy-MM-dd. + result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`; + } + + // Representation is either 'time' or 'complete' + if (representation !== "date") { + const hour = addLeadingZeros(date_.getHours(), 2); + const minute = addLeadingZeros(date_.getMinutes(), 2); + const second = addLeadingZeros(date_.getSeconds(), 2); + + // If there's also date, separate it with time with a space + const separator = result === "" ? "" : " "; + + // HHmmss or HH:mm:ss. + result = `${result}${separator}${hour}${timeDelimiter}${minute}${timeDelimiter}${second}`; + } + + return result; +} + +// Fallback for modularized imports: +export default formatISO9075; diff --git a/node_modules/date-fns/formatISODuration.cjs b/node_modules/date-fns/formatISODuration.cjs new file mode 100644 index 0000000000000000000000000000000000000000..7220173f09af6dc765f1fc4ca385f085b9b01d16 --- /dev/null +++ b/node_modules/date-fns/formatISODuration.cjs @@ -0,0 +1,39 @@ +"use strict"; +exports.formatISODuration = formatISODuration; + +/** + * @name formatISODuration + * @category Common Helpers + * @summary Format a duration object according as ISO 8601 duration string + * + * @description + * Format a duration object according to the ISO 8601 duration standard (https://www.digi.com/resources/documentation/digidocs//90001488-13/reference/r_iso_8601_duration_format.htm) + * + * @param duration - The duration to format + * + * @returns The ISO 8601 duration string + * + * @example + * // Format the given duration as ISO 8601 string + * const result = formatISODuration({ + * years: 39, + * months: 2, + * days: 20, + * hours: 7, + * minutes: 5, + * seconds: 0 + * }) + * //=> 'P39Y2M20DT0H0M0S' + */ +function formatISODuration(duration) { + const { + years = 0, + months = 0, + days = 0, + hours = 0, + minutes = 0, + seconds = 0, + } = duration; + + return `P${years}Y${months}M${days}DT${hours}H${minutes}M${seconds}S`; +} diff --git a/node_modules/date-fns/formatISODuration.d.cts b/node_modules/date-fns/formatISODuration.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..bbccc73b095ba4094ea1be87ce1a89cbffe083d5 --- /dev/null +++ b/node_modules/date-fns/formatISODuration.d.cts @@ -0,0 +1,26 @@ +import type { Duration } from "./types.ts"; +/** + * @name formatISODuration + * @category Common Helpers + * @summary Format a duration object according as ISO 8601 duration string + * + * @description + * Format a duration object according to the ISO 8601 duration standard (https://www.digi.com/resources/documentation/digidocs//90001488-13/reference/r_iso_8601_duration_format.htm) + * + * @param duration - The duration to format + * + * @returns The ISO 8601 duration string + * + * @example + * // Format the given duration as ISO 8601 string + * const result = formatISODuration({ + * years: 39, + * months: 2, + * days: 20, + * hours: 7, + * minutes: 5, + * seconds: 0 + * }) + * //=> 'P39Y2M20DT0H0M0S' + */ +export declare function formatISODuration(duration: Duration): string; diff --git a/node_modules/date-fns/formatISODuration.d.ts b/node_modules/date-fns/formatISODuration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbccc73b095ba4094ea1be87ce1a89cbffe083d5 --- /dev/null +++ b/node_modules/date-fns/formatISODuration.d.ts @@ -0,0 +1,26 @@ +import type { Duration } from "./types.ts"; +/** + * @name formatISODuration + * @category Common Helpers + * @summary Format a duration object according as ISO 8601 duration string + * + * @description + * Format a duration object according to the ISO 8601 duration standard (https://www.digi.com/resources/documentation/digidocs//90001488-13/reference/r_iso_8601_duration_format.htm) + * + * @param duration - The duration to format + * + * @returns The ISO 8601 duration string + * + * @example + * // Format the given duration as ISO 8601 string + * const result = formatISODuration({ + * years: 39, + * months: 2, + * days: 20, + * hours: 7, + * minutes: 5, + * seconds: 0 + * }) + * //=> 'P39Y2M20DT0H0M0S' + */ +export declare function formatISODuration(duration: Duration): string; diff --git a/node_modules/date-fns/formatISODuration.js b/node_modules/date-fns/formatISODuration.js new file mode 100644 index 0000000000000000000000000000000000000000..e40c538fba0704db0979a68f4f1036073acb5683 --- /dev/null +++ b/node_modules/date-fns/formatISODuration.js @@ -0,0 +1,39 @@ +/** + * @name formatISODuration + * @category Common Helpers + * @summary Format a duration object according as ISO 8601 duration string + * + * @description + * Format a duration object according to the ISO 8601 duration standard (https://www.digi.com/resources/documentation/digidocs//90001488-13/reference/r_iso_8601_duration_format.htm) + * + * @param duration - The duration to format + * + * @returns The ISO 8601 duration string + * + * @example + * // Format the given duration as ISO 8601 string + * const result = formatISODuration({ + * years: 39, + * months: 2, + * days: 20, + * hours: 7, + * minutes: 5, + * seconds: 0 + * }) + * //=> 'P39Y2M20DT0H0M0S' + */ +export function formatISODuration(duration) { + const { + years = 0, + months = 0, + days = 0, + hours = 0, + minutes = 0, + seconds = 0, + } = duration; + + return `P${years}Y${months}M${days}DT${hours}H${minutes}M${seconds}S`; +} + +// Fallback for modularized imports: +export default formatISODuration; diff --git a/node_modules/date-fns/formatRFC3339.cjs b/node_modules/date-fns/formatRFC3339.cjs new file mode 100644 index 0000000000000000000000000000000000000000..264945c961fc82df364b4ebbf0f2f67fcc96be55 --- /dev/null +++ b/node_modules/date-fns/formatRFC3339.cjs @@ -0,0 +1,84 @@ +"use strict"; +exports.formatRFC3339 = formatRFC3339; +var _index = require("./_lib/addLeadingZeros.cjs"); +var _index2 = require("./isValid.cjs"); +var _index3 = require("./toDate.cjs"); + +/** + * The {@link formatRFC3339} function options. + */ + +/** + * @name formatRFC3339 + * @category Common Helpers + * @summary Format the date according to the RFC 3339 standard (https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @description + * Return the formatted date string in RFC 3339 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 3339 format: + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in RFC 3339 format, 3 digits of second fraction + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { + * fractionDigits: 3 + * }) + * //=> '2019-09-18T19:00:52.234Z' + */ +function formatRFC3339(date, options) { + const date_ = (0, _index3.toDate)(date, options?.in); + + if (!(0, _index2.isValid)(date_)) { + throw new RangeError("Invalid time value"); + } + + const fractionDigits = options?.fractionDigits ?? 0; + + const day = (0, _index.addLeadingZeros)(date_.getDate(), 2); + const month = (0, _index.addLeadingZeros)(date_.getMonth() + 1, 2); + const year = date_.getFullYear(); + + const hour = (0, _index.addLeadingZeros)(date_.getHours(), 2); + const minute = (0, _index.addLeadingZeros)(date_.getMinutes(), 2); + const second = (0, _index.addLeadingZeros)(date_.getSeconds(), 2); + + let fractionalSecond = ""; + if (fractionDigits > 0) { + const milliseconds = date_.getMilliseconds(); + const fractionalSeconds = Math.trunc( + milliseconds * Math.pow(10, fractionDigits - 3), + ); + fractionalSecond = + "." + (0, _index.addLeadingZeros)(fractionalSeconds, fractionDigits); + } + + let offset = ""; + const tzOffset = date_.getTimezoneOffset(); + + if (tzOffset !== 0) { + const absoluteOffset = Math.abs(tzOffset); + const hourOffset = (0, _index.addLeadingZeros)( + Math.trunc(absoluteOffset / 60), + 2, + ); + const minuteOffset = (0, _index.addLeadingZeros)(absoluteOffset % 60, 2); + // If less than 0, the sign is +, because it is ahead of time. + const sign = tzOffset < 0 ? "+" : "-"; + + offset = `${sign}${hourOffset}:${minuteOffset}`; + } else { + offset = "Z"; + } + + return `${year}-${month}-${day}T${hour}:${minute}:${second}${fractionalSecond}${offset}`; +} diff --git a/node_modules/date-fns/formatRFC3339.d.cts b/node_modules/date-fns/formatRFC3339.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..ae0d0ba1d18f7c4cf01de524fd9072acb59a3ae0 --- /dev/null +++ b/node_modules/date-fns/formatRFC3339.d.cts @@ -0,0 +1,39 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link formatRFC3339} function options. + */ +export interface FormatRFC3339Options extends ContextOptions { + /** The number of digits after the decimal point after seconds, defaults to 0 */ + fractionDigits?: 0 | 1 | 2 | 3; +} +/** + * @name formatRFC3339 + * @category Common Helpers + * @summary Format the date according to the RFC 3339 standard (https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @description + * Return the formatted date string in RFC 3339 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 3339 format: + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in RFC 3339 format, 3 digits of second fraction + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { + * fractionDigits: 3 + * }) + * //=> '2019-09-18T19:00:52.234Z' + */ +export declare function formatRFC3339( + date: DateArg & {}, + options?: FormatRFC3339Options, +): string; diff --git a/node_modules/date-fns/formatRFC3339.d.ts b/node_modules/date-fns/formatRFC3339.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae0d0ba1d18f7c4cf01de524fd9072acb59a3ae0 --- /dev/null +++ b/node_modules/date-fns/formatRFC3339.d.ts @@ -0,0 +1,39 @@ +import type { ContextOptions, DateArg } from "./types.ts"; +/** + * The {@link formatRFC3339} function options. + */ +export interface FormatRFC3339Options extends ContextOptions { + /** The number of digits after the decimal point after seconds, defaults to 0 */ + fractionDigits?: 0 | 1 | 2 | 3; +} +/** + * @name formatRFC3339 + * @category Common Helpers + * @summary Format the date according to the RFC 3339 standard (https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @description + * Return the formatted date string in RFC 3339 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 3339 format: + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in RFC 3339 format, 3 digits of second fraction + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { + * fractionDigits: 3 + * }) + * //=> '2019-09-18T19:00:52.234Z' + */ +export declare function formatRFC3339( + date: DateArg & {}, + options?: FormatRFC3339Options, +): string; diff --git a/node_modules/date-fns/formatRFC3339.js b/node_modules/date-fns/formatRFC3339.js new file mode 100644 index 0000000000000000000000000000000000000000..0599f9af2f58b3da39464112ae3519ad8763a9a5 --- /dev/null +++ b/node_modules/date-fns/formatRFC3339.js @@ -0,0 +1,81 @@ +import { addLeadingZeros } from "./_lib/addLeadingZeros.js"; +import { isValid } from "./isValid.js"; +import { toDate } from "./toDate.js"; + +/** + * The {@link formatRFC3339} function options. + */ + +/** + * @name formatRFC3339 + * @category Common Helpers + * @summary Format the date according to the RFC 3339 standard (https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @description + * Return the formatted date string in RFC 3339 format. Options may be passed to control the parts and notations of the date. + * + * @param date - The original date + * @param options - An object with options. + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 3339 format: + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52)) + * //=> '2019-09-18T19:00:52Z' + * + * @example + * // Represent 18 September 2019 in RFC 3339 format, 3 digits of second fraction + * formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { + * fractionDigits: 3 + * }) + * //=> '2019-09-18T19:00:52.234Z' + */ +export function formatRFC3339(date, options) { + const date_ = toDate(date, options?.in); + + if (!isValid(date_)) { + throw new RangeError("Invalid time value"); + } + + const fractionDigits = options?.fractionDigits ?? 0; + + const day = addLeadingZeros(date_.getDate(), 2); + const month = addLeadingZeros(date_.getMonth() + 1, 2); + const year = date_.getFullYear(); + + const hour = addLeadingZeros(date_.getHours(), 2); + const minute = addLeadingZeros(date_.getMinutes(), 2); + const second = addLeadingZeros(date_.getSeconds(), 2); + + let fractionalSecond = ""; + if (fractionDigits > 0) { + const milliseconds = date_.getMilliseconds(); + const fractionalSeconds = Math.trunc( + milliseconds * Math.pow(10, fractionDigits - 3), + ); + fractionalSecond = "." + addLeadingZeros(fractionalSeconds, fractionDigits); + } + + let offset = ""; + const tzOffset = date_.getTimezoneOffset(); + + if (tzOffset !== 0) { + const absoluteOffset = Math.abs(tzOffset); + const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2); + const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2); + // If less than 0, the sign is +, because it is ahead of time. + const sign = tzOffset < 0 ? "+" : "-"; + + offset = `${sign}${hourOffset}:${minuteOffset}`; + } else { + offset = "Z"; + } + + return `${year}-${month}-${day}T${hour}:${minute}:${second}${fractionalSecond}${offset}`; +} + +// Fallback for modularized imports: +export default formatRFC3339; diff --git a/node_modules/date-fns/formatRFC7231.cjs b/node_modules/date-fns/formatRFC7231.cjs new file mode 100644 index 0000000000000000000000000000000000000000..8555dd834c2e00476d565851dec0e21b416a35b9 --- /dev/null +++ b/node_modules/date-fns/formatRFC7231.cjs @@ -0,0 +1,62 @@ +"use strict"; +exports.formatRFC7231 = formatRFC7231; +var _index = require("./_lib/addLeadingZeros.cjs"); +var _index2 = require("./isValid.cjs"); +var _index3 = require("./toDate.cjs"); + +const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + +const months = [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", +]; + +/** + * @name formatRFC7231 + * @category Common Helpers + * @summary Format the date according to the RFC 7231 standard (https://tools.ietf.org/html/rfc7231#section-7.1.1.1). + * + * @description + * Return the formatted date string in RFC 7231 format. + * The result will always be in UTC timezone. + * + * @param date - The original date + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 7231 format: + * const result = formatRFC7231(new Date(2019, 8, 18, 19, 0, 52)) + * //=> 'Wed, 18 Sep 2019 19:00:52 GMT' + */ +function formatRFC7231(date) { + const _date = (0, _index3.toDate)(date); + + if (!(0, _index2.isValid)(_date)) { + throw new RangeError("Invalid time value"); + } + + const dayName = days[_date.getUTCDay()]; + const dayOfMonth = (0, _index.addLeadingZeros)(_date.getUTCDate(), 2); + const monthName = months[_date.getUTCMonth()]; + const year = _date.getUTCFullYear(); + + const hour = (0, _index.addLeadingZeros)(_date.getUTCHours(), 2); + const minute = (0, _index.addLeadingZeros)(_date.getUTCMinutes(), 2); + const second = (0, _index.addLeadingZeros)(_date.getUTCSeconds(), 2); + + // Result variables. + return `${dayName}, ${dayOfMonth} ${monthName} ${year} ${hour}:${minute}:${second} GMT`; +} diff --git a/node_modules/date-fns/formatRFC7231.d.cts b/node_modules/date-fns/formatRFC7231.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..e9ea8e208154d32adffc429a494cd8c13b4c91bf --- /dev/null +++ b/node_modules/date-fns/formatRFC7231.d.cts @@ -0,0 +1,22 @@ +import type { DateArg } from "./types.ts"; +/** + * @name formatRFC7231 + * @category Common Helpers + * @summary Format the date according to the RFC 7231 standard (https://tools.ietf.org/html/rfc7231#section-7.1.1.1). + * + * @description + * Return the formatted date string in RFC 7231 format. + * The result will always be in UTC timezone. + * + * @param date - The original date + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 7231 format: + * const result = formatRFC7231(new Date(2019, 8, 18, 19, 0, 52)) + * //=> 'Wed, 18 Sep 2019 19:00:52 GMT' + */ +export declare function formatRFC7231(date: DateArg & {}): string; diff --git a/node_modules/date-fns/formatRFC7231.d.ts b/node_modules/date-fns/formatRFC7231.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9ea8e208154d32adffc429a494cd8c13b4c91bf --- /dev/null +++ b/node_modules/date-fns/formatRFC7231.d.ts @@ -0,0 +1,22 @@ +import type { DateArg } from "./types.ts"; +/** + * @name formatRFC7231 + * @category Common Helpers + * @summary Format the date according to the RFC 7231 standard (https://tools.ietf.org/html/rfc7231#section-7.1.1.1). + * + * @description + * Return the formatted date string in RFC 7231 format. + * The result will always be in UTC timezone. + * + * @param date - The original date + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 7231 format: + * const result = formatRFC7231(new Date(2019, 8, 18, 19, 0, 52)) + * //=> 'Wed, 18 Sep 2019 19:00:52 GMT' + */ +export declare function formatRFC7231(date: DateArg & {}): string; diff --git a/node_modules/date-fns/formatRFC7231.js b/node_modules/date-fns/formatRFC7231.js new file mode 100644 index 0000000000000000000000000000000000000000..e1e1b88132cf14691a34b34915ce4f35dc38a650 --- /dev/null +++ b/node_modules/date-fns/formatRFC7231.js @@ -0,0 +1,63 @@ +import { addLeadingZeros } from "./_lib/addLeadingZeros.js"; +import { isValid } from "./isValid.js"; +import { toDate } from "./toDate.js"; + +const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + +const months = [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", +]; + +/** + * @name formatRFC7231 + * @category Common Helpers + * @summary Format the date according to the RFC 7231 standard (https://tools.ietf.org/html/rfc7231#section-7.1.1.1). + * + * @description + * Return the formatted date string in RFC 7231 format. + * The result will always be in UTC timezone. + * + * @param date - The original date + * + * @returns The formatted date string + * + * @throws `date` must not be Invalid Date + * + * @example + * // Represent 18 September 2019 in RFC 7231 format: + * const result = formatRFC7231(new Date(2019, 8, 18, 19, 0, 52)) + * //=> 'Wed, 18 Sep 2019 19:00:52 GMT' + */ +export function formatRFC7231(date) { + const _date = toDate(date); + + if (!isValid(_date)) { + throw new RangeError("Invalid time value"); + } + + const dayName = days[_date.getUTCDay()]; + const dayOfMonth = addLeadingZeros(_date.getUTCDate(), 2); + const monthName = months[_date.getUTCMonth()]; + const year = _date.getUTCFullYear(); + + const hour = addLeadingZeros(_date.getUTCHours(), 2); + const minute = addLeadingZeros(_date.getUTCMinutes(), 2); + const second = addLeadingZeros(_date.getUTCSeconds(), 2); + + // Result variables. + return `${dayName}, ${dayOfMonth} ${monthName} ${year} ${hour}:${minute}:${second} GMT`; +} + +// Fallback for modularized imports: +export default formatRFC7231; diff --git a/node_modules/date-fns/formatRelative.cjs b/node_modules/date-fns/formatRelative.cjs new file mode 100644 index 0000000000000000000000000000000000000000..8b1512f3096754f935df799f4d78fec441310aad --- /dev/null +++ b/node_modules/date-fns/formatRelative.cjs @@ -0,0 +1,92 @@ +"use strict"; +exports.formatRelative = formatRelative; +var _index = require("./_lib/defaultLocale.cjs"); +var _index2 = require("./_lib/defaultOptions.cjs"); +var _index3 = require("./_lib/normalizeDates.cjs"); +var _index4 = require("./differenceInCalendarDays.cjs"); +var _index5 = require("./format.cjs"); + +/** + * The {@link formatRelative} function options. + */ + +/** + * @name formatRelative + * @category Common Helpers + * @summary Represent the date in words relative to the given base date. + * + * @description + * Represent the date in words relative to the given base date. + * + * | Distance to the base date | Result | + * |---------------------------|---------------------------| + * | Previous 6 days | last Sunday at 04:30 AM | + * | Last day | yesterday at 04:30 AM | + * | Same day | today at 04:30 AM | + * | Next day | tomorrow at 04:30 AM | + * | Next 6 days | Sunday at 04:30 AM | + * | Other | 12/31/2017 | + * + * @param date - The date to format + * @param baseDate - The date to compare with + * @param options - An object with options + * + * @returns The date in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @throws `options.locale` must contain `formatRelative` property + * + * @example + * // Represent the date of 6 days ago in words relative to the given base date. In this example, today is Wednesday + * const result = formatRelative(subDays(new Date(), 6), new Date()) + * //=> "last Thursday at 12:45 AM" + */ +function formatRelative(date, baseDate, options) { + const [date_, baseDate_] = (0, _index3.normalizeDates)( + options?.in, + date, + baseDate, + ); + + const defaultOptions = (0, _index2.getDefaultOptions)(); + const locale = + options?.locale ?? defaultOptions.locale ?? _index.defaultLocale; + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const diff = (0, _index4.differenceInCalendarDays)(date_, baseDate_); + + if (isNaN(diff)) { + throw new RangeError("Invalid time value"); + } + + let token; + if (diff < -6) { + token = "other"; + } else if (diff < -1) { + token = "lastWeek"; + } else if (diff < 0) { + token = "yesterday"; + } else if (diff < 1) { + token = "today"; + } else if (diff < 2) { + token = "tomorrow"; + } else if (diff < 7) { + token = "nextWeek"; + } else { + token = "other"; + } + + const formatStr = locale.formatRelative(token, date_, baseDate_, { + locale, + weekStartsOn, + }); + return (0, _index5.format)(date_, formatStr, { locale, weekStartsOn }); +} diff --git a/node_modules/date-fns/formatRelative.d.cts b/node_modules/date-fns/formatRelative.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2ae84935fbb12acdd641c0b2bc73eead1e96c495 --- /dev/null +++ b/node_modules/date-fns/formatRelative.d.cts @@ -0,0 +1,54 @@ +import type { + ContextOptions, + DateArg, + LocalizedOptions, + WeekOptions, +} from "./types.ts"; +/** + * The {@link formatRelative} function options. + */ +export interface FormatRelativeOptions + extends LocalizedOptions< + "options" | "localize" | "formatLong" | "formatRelative" + >, + WeekOptions, + ContextOptions {} +/** + * @name formatRelative + * @category Common Helpers + * @summary Represent the date in words relative to the given base date. + * + * @description + * Represent the date in words relative to the given base date. + * + * | Distance to the base date | Result | + * |---------------------------|---------------------------| + * | Previous 6 days | last Sunday at 04:30 AM | + * | Last day | yesterday at 04:30 AM | + * | Same day | today at 04:30 AM | + * | Next day | tomorrow at 04:30 AM | + * | Next 6 days | Sunday at 04:30 AM | + * | Other | 12/31/2017 | + * + * @param date - The date to format + * @param baseDate - The date to compare with + * @param options - An object with options + * + * @returns The date in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @throws `options.locale` must contain `formatRelative` property + * + * @example + * // Represent the date of 6 days ago in words relative to the given base date. In this example, today is Wednesday + * const result = formatRelative(subDays(new Date(), 6), new Date()) + * //=> "last Thursday at 12:45 AM" + */ +export declare function formatRelative( + date: DateArg & {}, + baseDate: DateArg & {}, + options?: FormatRelativeOptions, +): string; diff --git a/node_modules/date-fns/formatRelative.d.ts b/node_modules/date-fns/formatRelative.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ae84935fbb12acdd641c0b2bc73eead1e96c495 --- /dev/null +++ b/node_modules/date-fns/formatRelative.d.ts @@ -0,0 +1,54 @@ +import type { + ContextOptions, + DateArg, + LocalizedOptions, + WeekOptions, +} from "./types.ts"; +/** + * The {@link formatRelative} function options. + */ +export interface FormatRelativeOptions + extends LocalizedOptions< + "options" | "localize" | "formatLong" | "formatRelative" + >, + WeekOptions, + ContextOptions {} +/** + * @name formatRelative + * @category Common Helpers + * @summary Represent the date in words relative to the given base date. + * + * @description + * Represent the date in words relative to the given base date. + * + * | Distance to the base date | Result | + * |---------------------------|---------------------------| + * | Previous 6 days | last Sunday at 04:30 AM | + * | Last day | yesterday at 04:30 AM | + * | Same day | today at 04:30 AM | + * | Next day | tomorrow at 04:30 AM | + * | Next 6 days | Sunday at 04:30 AM | + * | Other | 12/31/2017 | + * + * @param date - The date to format + * @param baseDate - The date to compare with + * @param options - An object with options + * + * @returns The date in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @throws `options.locale` must contain `formatRelative` property + * + * @example + * // Represent the date of 6 days ago in words relative to the given base date. In this example, today is Wednesday + * const result = formatRelative(subDays(new Date(), 6), new Date()) + * //=> "last Thursday at 12:45 AM" + */ +export declare function formatRelative( + date: DateArg & {}, + baseDate: DateArg & {}, + options?: FormatRelativeOptions, +): string; diff --git a/node_modules/date-fns/formatRelative.js b/node_modules/date-fns/formatRelative.js new file mode 100644 index 0000000000000000000000000000000000000000..a564b0415e3a665f18bd6a5a7f931080249d8b8c --- /dev/null +++ b/node_modules/date-fns/formatRelative.js @@ -0,0 +1,88 @@ +import { defaultLocale } from "./_lib/defaultLocale.js"; +import { getDefaultOptions } from "./_lib/defaultOptions.js"; +import { normalizeDates } from "./_lib/normalizeDates.js"; +import { differenceInCalendarDays } from "./differenceInCalendarDays.js"; +import { format } from "./format.js"; + +/** + * The {@link formatRelative} function options. + */ + +/** + * @name formatRelative + * @category Common Helpers + * @summary Represent the date in words relative to the given base date. + * + * @description + * Represent the date in words relative to the given base date. + * + * | Distance to the base date | Result | + * |---------------------------|---------------------------| + * | Previous 6 days | last Sunday at 04:30 AM | + * | Last day | yesterday at 04:30 AM | + * | Same day | today at 04:30 AM | + * | Next day | tomorrow at 04:30 AM | + * | Next 6 days | Sunday at 04:30 AM | + * | Other | 12/31/2017 | + * + * @param date - The date to format + * @param baseDate - The date to compare with + * @param options - An object with options + * + * @returns The date in words + * + * @throws `date` must not be Invalid Date + * @throws `baseDate` must not be Invalid Date + * @throws `options.locale` must contain `localize` property + * @throws `options.locale` must contain `formatLong` property + * @throws `options.locale` must contain `formatRelative` property + * + * @example + * // Represent the date of 6 days ago in words relative to the given base date. In this example, today is Wednesday + * const result = formatRelative(subDays(new Date(), 6), new Date()) + * //=> "last Thursday at 12:45 AM" + */ +export function formatRelative(date, baseDate, options) { + const [date_, baseDate_] = normalizeDates(options?.in, date, baseDate); + + const defaultOptions = getDefaultOptions(); + const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale; + const weekStartsOn = + options?.weekStartsOn ?? + options?.locale?.options?.weekStartsOn ?? + defaultOptions.weekStartsOn ?? + defaultOptions.locale?.options?.weekStartsOn ?? + 0; + + const diff = differenceInCalendarDays(date_, baseDate_); + + if (isNaN(diff)) { + throw new RangeError("Invalid time value"); + } + + let token; + if (diff < -6) { + token = "other"; + } else if (diff < -1) { + token = "lastWeek"; + } else if (diff < 0) { + token = "yesterday"; + } else if (diff < 1) { + token = "today"; + } else if (diff < 2) { + token = "tomorrow"; + } else if (diff < 7) { + token = "nextWeek"; + } else { + token = "other"; + } + + const formatStr = locale.formatRelative(token, date_, baseDate_, { + locale, + weekStartsOn, + }); + return format(date_, formatStr, { locale, weekStartsOn }); +} + +// Fallback for modularized imports: +export default formatRelative; diff --git a/node_modules/date-fns/fp/_lib/convertToFP.cjs b/node_modules/date-fns/fp/_lib/convertToFP.cjs new file mode 100644 index 0000000000000000000000000000000000000000..9b8b45f695f28737b9c2123ed780b479820be418 --- /dev/null +++ b/node_modules/date-fns/fp/_lib/convertToFP.cjs @@ -0,0 +1,20 @@ +"use strict"; +exports.convertToFP = convertToFP; + +/** + * Converts a function to a curried function that accepts arguments in reverse + * order. + * + * @param fn - The function to convert to FP + * @param arity - The arity of the function + * @param curriedArgs - The curried arguments + * + * @returns FP version of the function + * + * @private + */ +function convertToFP(fn, arity, curriedArgs = []) { + return curriedArgs.length >= arity + ? fn(...curriedArgs.slice(0, arity).reverse()) + : (...args) => convertToFP(fn, arity, curriedArgs.concat(args)); +} diff --git a/node_modules/date-fns/fp/_lib/convertToFP.d.cts b/node_modules/date-fns/fp/_lib/convertToFP.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..3741f432a8e8d108460490dc559323792a392ad6 --- /dev/null +++ b/node_modules/date-fns/fp/_lib/convertToFP.d.cts @@ -0,0 +1,17 @@ +import type { FPArity, FPFn, FPFnInput } from "../types.ts"; +/** + * Converts a function to a curried function that accepts arguments in reverse + * order. + * + * @param fn - The function to convert to FP + * @param arity - The arity of the function + * @param curriedArgs - The curried arguments + * + * @returns FP version of the function + * + * @private + */ +export declare function convertToFP< + Fn extends FPFnInput, + Arity extends FPArity, +>(fn: Fn, arity: Arity, curriedArgs?: unknown[]): FPFn; diff --git a/node_modules/date-fns/fp/_lib/convertToFP.d.ts b/node_modules/date-fns/fp/_lib/convertToFP.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3741f432a8e8d108460490dc559323792a392ad6 --- /dev/null +++ b/node_modules/date-fns/fp/_lib/convertToFP.d.ts @@ -0,0 +1,17 @@ +import type { FPArity, FPFn, FPFnInput } from "../types.ts"; +/** + * Converts a function to a curried function that accepts arguments in reverse + * order. + * + * @param fn - The function to convert to FP + * @param arity - The arity of the function + * @param curriedArgs - The curried arguments + * + * @returns FP version of the function + * + * @private + */ +export declare function convertToFP< + Fn extends FPFnInput, + Arity extends FPArity, +>(fn: Fn, arity: Arity, curriedArgs?: unknown[]): FPFn; diff --git a/node_modules/date-fns/fp/_lib/convertToFP.js b/node_modules/date-fns/fp/_lib/convertToFP.js new file mode 100644 index 0000000000000000000000000000000000000000..1e854634afaa24badb09135f91de6d8086c9c169 --- /dev/null +++ b/node_modules/date-fns/fp/_lib/convertToFP.js @@ -0,0 +1,17 @@ +/** + * Converts a function to a curried function that accepts arguments in reverse + * order. + * + * @param fn - The function to convert to FP + * @param arity - The arity of the function + * @param curriedArgs - The curried arguments + * + * @returns FP version of the function + * + * @private + */ +export function convertToFP(fn, arity, curriedArgs = []) { + return curriedArgs.length >= arity + ? fn(...curriedArgs.slice(0, arity).reverse()) + : (...args) => convertToFP(fn, arity, curriedArgs.concat(args)); +} diff --git a/node_modules/date-fns/fp/add.cjs b/node_modules/date-fns/fp/add.cjs new file mode 100644 index 0000000000000000000000000000000000000000..9bf1127025392bde1ce907122c0dbbfebacf86ab --- /dev/null +++ b/node_modules/date-fns/fp/add.cjs @@ -0,0 +1,7 @@ +"use strict"; +exports.add = void 0; + +var _index = require("../add.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const add = (exports.add = (0, _index2.convertToFP)(_index.add, 2)); diff --git a/node_modules/date-fns/fp/add.d.cts b/node_modules/date-fns/fp/add.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..9c7bafba51054353b75b4b429784b01f6d46095a --- /dev/null +++ b/node_modules/date-fns/fp/add.d.cts @@ -0,0 +1,5 @@ +export declare const add: import("./types.ts").FPFn2< + Date, + import("../fp.ts").Duration, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/add.d.ts b/node_modules/date-fns/fp/add.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c7bafba51054353b75b4b429784b01f6d46095a --- /dev/null +++ b/node_modules/date-fns/fp/add.d.ts @@ -0,0 +1,5 @@ +export declare const add: import("./types.ts").FPFn2< + Date, + import("../fp.ts").Duration, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/add.js b/node_modules/date-fns/fp/add.js new file mode 100644 index 0000000000000000000000000000000000000000..198961c14a8c42f9034feeed53853e80631a59f7 --- /dev/null +++ b/node_modules/date-fns/fp/add.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { add as fn } from "../add.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const add = convertToFP(fn, 2); + +// Fallback for modularized imports: +export default add; diff --git a/node_modules/date-fns/fp/addBusinessDays.cjs b/node_modules/date-fns/fp/addBusinessDays.cjs new file mode 100644 index 0000000000000000000000000000000000000000..4bd236d682c523806931860661475d257a29ca0f --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDays.cjs @@ -0,0 +1,10 @@ +"use strict"; +exports.addBusinessDays = void 0; + +var _index = require("../addBusinessDays.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addBusinessDays = (exports.addBusinessDays = (0, _index2.convertToFP)( + _index.addBusinessDays, + 2, +)); diff --git a/node_modules/date-fns/fp/addBusinessDays.d.cts b/node_modules/date-fns/fp/addBusinessDays.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..82827a4d55ece256031406d3f4e47d428ef3521a --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDays.d.cts @@ -0,0 +1,5 @@ +export declare const addBusinessDays: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addBusinessDays.d.ts b/node_modules/date-fns/fp/addBusinessDays.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..82827a4d55ece256031406d3f4e47d428ef3521a --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDays.d.ts @@ -0,0 +1,5 @@ +export declare const addBusinessDays: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addBusinessDays.js b/node_modules/date-fns/fp/addBusinessDays.js new file mode 100644 index 0000000000000000000000000000000000000000..47e4024a4037c833e40c8540419d57ad7c755d89 --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDays.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addBusinessDays as fn } from "../addBusinessDays.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addBusinessDays = convertToFP(fn, 2); + +// Fallback for modularized imports: +export default addBusinessDays; diff --git a/node_modules/date-fns/fp/addBusinessDaysWithOptions.cjs b/node_modules/date-fns/fp/addBusinessDaysWithOptions.cjs new file mode 100644 index 0000000000000000000000000000000000000000..63b13a7f305f34d48c378d930d0b7bf47d222d52 --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDaysWithOptions.cjs @@ -0,0 +1,8 @@ +"use strict"; +exports.addBusinessDaysWithOptions = void 0; + +var _index = require("../addBusinessDays.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addBusinessDaysWithOptions = (exports.addBusinessDaysWithOptions = (0, +_index2.convertToFP)(_index.addBusinessDays, 3)); diff --git a/node_modules/date-fns/fp/addBusinessDaysWithOptions.d.cts b/node_modules/date-fns/fp/addBusinessDaysWithOptions.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..21250d14be6452ceb9e10e1ceb9c53fd08d6b0dd --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDaysWithOptions.d.cts @@ -0,0 +1,7 @@ +export declare const addBusinessDaysWithOptions: import("./types.ts").FPFn3< + Date, + | import("../addBusinessDays.ts").AddBusinessDaysOptions + | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addBusinessDaysWithOptions.d.ts b/node_modules/date-fns/fp/addBusinessDaysWithOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..21250d14be6452ceb9e10e1ceb9c53fd08d6b0dd --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDaysWithOptions.d.ts @@ -0,0 +1,7 @@ +export declare const addBusinessDaysWithOptions: import("./types.ts").FPFn3< + Date, + | import("../addBusinessDays.ts").AddBusinessDaysOptions + | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addBusinessDaysWithOptions.js b/node_modules/date-fns/fp/addBusinessDaysWithOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..180a80bd3f12daee077a40c086b404abcfcdbe63 --- /dev/null +++ b/node_modules/date-fns/fp/addBusinessDaysWithOptions.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addBusinessDays as fn } from "../addBusinessDays.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addBusinessDaysWithOptions = convertToFP(fn, 3); + +// Fallback for modularized imports: +export default addBusinessDaysWithOptions; diff --git a/node_modules/date-fns/fp/addDays.cjs b/node_modules/date-fns/fp/addDays.cjs new file mode 100644 index 0000000000000000000000000000000000000000..f58f4c7e93eb51d7c956a13fe9a3c228c7b2544c --- /dev/null +++ b/node_modules/date-fns/fp/addDays.cjs @@ -0,0 +1,7 @@ +"use strict"; +exports.addDays = void 0; + +var _index = require("../addDays.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addDays = (exports.addDays = (0, _index2.convertToFP)(_index.addDays, 2)); diff --git a/node_modules/date-fns/fp/addDays.d.cts b/node_modules/date-fns/fp/addDays.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..c1806115feb3257c0c620c11ff87e0553627d29a --- /dev/null +++ b/node_modules/date-fns/fp/addDays.d.cts @@ -0,0 +1,5 @@ +export declare const addDays: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addDays.d.ts b/node_modules/date-fns/fp/addDays.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1806115feb3257c0c620c11ff87e0553627d29a --- /dev/null +++ b/node_modules/date-fns/fp/addDays.d.ts @@ -0,0 +1,5 @@ +export declare const addDays: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addDays.js b/node_modules/date-fns/fp/addDays.js new file mode 100644 index 0000000000000000000000000000000000000000..4c3695d596a2c1cdaee0b05c030545ca7f7ee31b --- /dev/null +++ b/node_modules/date-fns/fp/addDays.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addDays as fn } from "../addDays.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addDays = convertToFP(fn, 2); + +// Fallback for modularized imports: +export default addDays; diff --git a/node_modules/date-fns/fp/addDaysWithOptions.cjs b/node_modules/date-fns/fp/addDaysWithOptions.cjs new file mode 100644 index 0000000000000000000000000000000000000000..e8b92c8742ee3ae1c6eca9a0525994b807b911fe --- /dev/null +++ b/node_modules/date-fns/fp/addDaysWithOptions.cjs @@ -0,0 +1,8 @@ +"use strict"; +exports.addDaysWithOptions = void 0; + +var _index = require("../addDays.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addDaysWithOptions = (exports.addDaysWithOptions = (0, +_index2.convertToFP)(_index.addDays, 3)); diff --git a/node_modules/date-fns/fp/addDaysWithOptions.d.cts b/node_modules/date-fns/fp/addDaysWithOptions.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2f89b5568cfdc629a305ac3197bc96b63e50218e --- /dev/null +++ b/node_modules/date-fns/fp/addDaysWithOptions.d.cts @@ -0,0 +1,6 @@ +export declare const addDaysWithOptions: import("./types.ts").FPFn3< + Date, + import("../addDays.ts").AddDaysOptions | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addDaysWithOptions.d.ts b/node_modules/date-fns/fp/addDaysWithOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f89b5568cfdc629a305ac3197bc96b63e50218e --- /dev/null +++ b/node_modules/date-fns/fp/addDaysWithOptions.d.ts @@ -0,0 +1,6 @@ +export declare const addDaysWithOptions: import("./types.ts").FPFn3< + Date, + import("../addDays.ts").AddDaysOptions | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addDaysWithOptions.js b/node_modules/date-fns/fp/addDaysWithOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..db2adf5012501f177bbd9bc29f3578124a75fc6b --- /dev/null +++ b/node_modules/date-fns/fp/addDaysWithOptions.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addDays as fn } from "../addDays.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addDaysWithOptions = convertToFP(fn, 3); + +// Fallback for modularized imports: +export default addDaysWithOptions; diff --git a/node_modules/date-fns/fp/addHours.cjs b/node_modules/date-fns/fp/addHours.cjs new file mode 100644 index 0000000000000000000000000000000000000000..eee7658a86de39ab25172b0122fbff5fb414ee8a --- /dev/null +++ b/node_modules/date-fns/fp/addHours.cjs @@ -0,0 +1,10 @@ +"use strict"; +exports.addHours = void 0; + +var _index = require("../addHours.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addHours = (exports.addHours = (0, _index2.convertToFP)( + _index.addHours, + 2, +)); diff --git a/node_modules/date-fns/fp/addHours.d.cts b/node_modules/date-fns/fp/addHours.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..085cfe264892a94e874b65e5d8e5263a329242ed --- /dev/null +++ b/node_modules/date-fns/fp/addHours.d.cts @@ -0,0 +1,5 @@ +export declare const addHours: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addHours.d.ts b/node_modules/date-fns/fp/addHours.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..085cfe264892a94e874b65e5d8e5263a329242ed --- /dev/null +++ b/node_modules/date-fns/fp/addHours.d.ts @@ -0,0 +1,5 @@ +export declare const addHours: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addHours.js b/node_modules/date-fns/fp/addHours.js new file mode 100644 index 0000000000000000000000000000000000000000..15a11a43f3cb53fca5f98924c3e8725a81ab3ad0 --- /dev/null +++ b/node_modules/date-fns/fp/addHours.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addHours as fn } from "../addHours.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addHours = convertToFP(fn, 2); + +// Fallback for modularized imports: +export default addHours; diff --git a/node_modules/date-fns/fp/addHoursWithOptions.cjs b/node_modules/date-fns/fp/addHoursWithOptions.cjs new file mode 100644 index 0000000000000000000000000000000000000000..b5c6fdb00aeb90149166e21aee985ee3440562a8 --- /dev/null +++ b/node_modules/date-fns/fp/addHoursWithOptions.cjs @@ -0,0 +1,8 @@ +"use strict"; +exports.addHoursWithOptions = void 0; + +var _index = require("../addHours.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addHoursWithOptions = (exports.addHoursWithOptions = (0, +_index2.convertToFP)(_index.addHours, 3)); diff --git a/node_modules/date-fns/fp/addHoursWithOptions.d.cts b/node_modules/date-fns/fp/addHoursWithOptions.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..3c9e5a42a463fe61865acf8394dc5ae56cb5c8f2 --- /dev/null +++ b/node_modules/date-fns/fp/addHoursWithOptions.d.cts @@ -0,0 +1,6 @@ +export declare const addHoursWithOptions: import("./types.ts").FPFn3< + Date, + import("../addHours.ts").AddHoursOptions | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addHoursWithOptions.d.ts b/node_modules/date-fns/fp/addHoursWithOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c9e5a42a463fe61865acf8394dc5ae56cb5c8f2 --- /dev/null +++ b/node_modules/date-fns/fp/addHoursWithOptions.d.ts @@ -0,0 +1,6 @@ +export declare const addHoursWithOptions: import("./types.ts").FPFn3< + Date, + import("../addHours.ts").AddHoursOptions | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addHoursWithOptions.js b/node_modules/date-fns/fp/addHoursWithOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..14f161337a3358b75d2048ba1400b5911df0f9e6 --- /dev/null +++ b/node_modules/date-fns/fp/addHoursWithOptions.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addHours as fn } from "../addHours.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addHoursWithOptions = convertToFP(fn, 3); + +// Fallback for modularized imports: +export default addHoursWithOptions; diff --git a/node_modules/date-fns/fp/addISOWeekYears.cjs b/node_modules/date-fns/fp/addISOWeekYears.cjs new file mode 100644 index 0000000000000000000000000000000000000000..1deacee01fc35c8aa4a3930e8756eb45ad9c5c23 --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYears.cjs @@ -0,0 +1,10 @@ +"use strict"; +exports.addISOWeekYears = void 0; + +var _index = require("../addISOWeekYears.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addISOWeekYears = (exports.addISOWeekYears = (0, _index2.convertToFP)( + _index.addISOWeekYears, + 2, +)); diff --git a/node_modules/date-fns/fp/addISOWeekYears.d.cts b/node_modules/date-fns/fp/addISOWeekYears.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..27863bda3fd09a440949419a74e78d734c654e92 --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYears.d.cts @@ -0,0 +1,5 @@ +export declare const addISOWeekYears: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addISOWeekYears.d.ts b/node_modules/date-fns/fp/addISOWeekYears.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..27863bda3fd09a440949419a74e78d734c654e92 --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYears.d.ts @@ -0,0 +1,5 @@ +export declare const addISOWeekYears: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addISOWeekYears.js b/node_modules/date-fns/fp/addISOWeekYears.js new file mode 100644 index 0000000000000000000000000000000000000000..64c1d4a9dfacb0881fc0ce68afc8002bba546c86 --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYears.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addISOWeekYears as fn } from "../addISOWeekYears.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addISOWeekYears = convertToFP(fn, 2); + +// Fallback for modularized imports: +export default addISOWeekYears; diff --git a/node_modules/date-fns/fp/addISOWeekYearsWithOptions.cjs b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.cjs new file mode 100644 index 0000000000000000000000000000000000000000..5931c01e658123131e111a1bd68157c9c5771d6d --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.cjs @@ -0,0 +1,8 @@ +"use strict"; +exports.addISOWeekYearsWithOptions = void 0; + +var _index = require("../addISOWeekYears.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addISOWeekYearsWithOptions = (exports.addISOWeekYearsWithOptions = (0, +_index2.convertToFP)(_index.addISOWeekYears, 3)); diff --git a/node_modules/date-fns/fp/addISOWeekYearsWithOptions.d.cts b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..6e53d09a762d38cf75fc30e1d3f7bacc910e1c67 --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.d.cts @@ -0,0 +1,7 @@ +export declare const addISOWeekYearsWithOptions: import("./types.ts").FPFn3< + Date, + | import("../addISOWeekYears.ts").AddISOWeekYearsOptions + | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addISOWeekYearsWithOptions.d.ts b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e53d09a762d38cf75fc30e1d3f7bacc910e1c67 --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.d.ts @@ -0,0 +1,7 @@ +export declare const addISOWeekYearsWithOptions: import("./types.ts").FPFn3< + Date, + | import("../addISOWeekYears.ts").AddISOWeekYearsOptions + | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addISOWeekYearsWithOptions.js b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..dd28efa19a25f3a486bb4cb8bca6cfade7ea425c --- /dev/null +++ b/node_modules/date-fns/fp/addISOWeekYearsWithOptions.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addISOWeekYears as fn } from "../addISOWeekYears.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addISOWeekYearsWithOptions = convertToFP(fn, 3); + +// Fallback for modularized imports: +export default addISOWeekYearsWithOptions; diff --git a/node_modules/date-fns/fp/addMilliseconds.cjs b/node_modules/date-fns/fp/addMilliseconds.cjs new file mode 100644 index 0000000000000000000000000000000000000000..7e73ddc9a9329d765670235d1bb6232b63681b25 --- /dev/null +++ b/node_modules/date-fns/fp/addMilliseconds.cjs @@ -0,0 +1,10 @@ +"use strict"; +exports.addMilliseconds = void 0; + +var _index = require("../addMilliseconds.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addMilliseconds = (exports.addMilliseconds = (0, _index2.convertToFP)( + _index.addMilliseconds, + 2, +)); diff --git a/node_modules/date-fns/fp/addMilliseconds.d.cts b/node_modules/date-fns/fp/addMilliseconds.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..9e3db416126604a4ecc9ff77e5ac1ed709ef1577 --- /dev/null +++ b/node_modules/date-fns/fp/addMilliseconds.d.cts @@ -0,0 +1,5 @@ +export declare const addMilliseconds: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addMilliseconds.d.ts b/node_modules/date-fns/fp/addMilliseconds.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e3db416126604a4ecc9ff77e5ac1ed709ef1577 --- /dev/null +++ b/node_modules/date-fns/fp/addMilliseconds.d.ts @@ -0,0 +1,5 @@ +export declare const addMilliseconds: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addMilliseconds.js b/node_modules/date-fns/fp/addMilliseconds.js new file mode 100644 index 0000000000000000000000000000000000000000..5ee342680f9d34a6ea87e0d57000c124770d622b --- /dev/null +++ b/node_modules/date-fns/fp/addMilliseconds.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addMilliseconds as fn } from "../addMilliseconds.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addMilliseconds = convertToFP(fn, 2); + +// Fallback for modularized imports: +export default addMilliseconds; diff --git a/node_modules/date-fns/fp/addMillisecondsWithOptions.cjs b/node_modules/date-fns/fp/addMillisecondsWithOptions.cjs new file mode 100644 index 0000000000000000000000000000000000000000..beabbc12206bcf07e119e0d1cc689f5f97613984 --- /dev/null +++ b/node_modules/date-fns/fp/addMillisecondsWithOptions.cjs @@ -0,0 +1,8 @@ +"use strict"; +exports.addMillisecondsWithOptions = void 0; + +var _index = require("../addMilliseconds.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addMillisecondsWithOptions = (exports.addMillisecondsWithOptions = (0, +_index2.convertToFP)(_index.addMilliseconds, 3)); diff --git a/node_modules/date-fns/fp/addMillisecondsWithOptions.d.cts b/node_modules/date-fns/fp/addMillisecondsWithOptions.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..fc651a479469e606a906adb3f024bcbd3260a6bd --- /dev/null +++ b/node_modules/date-fns/fp/addMillisecondsWithOptions.d.cts @@ -0,0 +1,7 @@ +export declare const addMillisecondsWithOptions: import("./types.ts").FPFn3< + Date, + | import("../addMilliseconds.ts").AddMillisecondsOptions + | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addMillisecondsWithOptions.d.ts b/node_modules/date-fns/fp/addMillisecondsWithOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc651a479469e606a906adb3f024bcbd3260a6bd --- /dev/null +++ b/node_modules/date-fns/fp/addMillisecondsWithOptions.d.ts @@ -0,0 +1,7 @@ +export declare const addMillisecondsWithOptions: import("./types.ts").FPFn3< + Date, + | import("../addMilliseconds.ts").AddMillisecondsOptions + | undefined, + number, + import("../fp.ts").DateArg +>; diff --git a/node_modules/date-fns/fp/addMillisecondsWithOptions.js b/node_modules/date-fns/fp/addMillisecondsWithOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..8854f17dbd25939b1a8826cafc8bfed42bd34019 --- /dev/null +++ b/node_modules/date-fns/fp/addMillisecondsWithOptions.js @@ -0,0 +1,9 @@ +// This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +import { addMilliseconds as fn } from "../addMilliseconds.js"; +import { convertToFP } from "./_lib/convertToFP.js"; + +export const addMillisecondsWithOptions = convertToFP(fn, 3); + +// Fallback for modularized imports: +export default addMillisecondsWithOptions; diff --git a/node_modules/date-fns/fp/addMinutes.cjs b/node_modules/date-fns/fp/addMinutes.cjs new file mode 100644 index 0000000000000000000000000000000000000000..d4e208c7eec9497a86c0800701c6bd238bf449e4 --- /dev/null +++ b/node_modules/date-fns/fp/addMinutes.cjs @@ -0,0 +1,10 @@ +"use strict"; +exports.addMinutes = void 0; + +var _index = require("../addMinutes.cjs"); +var _index2 = require("./_lib/convertToFP.cjs"); // This file is generated automatically by `scripts/build/fp.ts`. Please, don't change it. + +const addMinutes = (exports.addMinutes = (0, _index2.convertToFP)( + _index.addMinutes, + 2, +)); diff --git a/node_modules/date-fns/fp/addMinutes.d.cts b/node_modules/date-fns/fp/addMinutes.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..ffacd3a67d8c71f383a9f9f59aade7c403de29cd --- /dev/null +++ b/node_modules/date-fns/fp/addMinutes.d.cts @@ -0,0 +1,5 @@ +export declare const addMinutes: import("./types.ts").FPFn2< + Date, + number, + import("../fp.ts").DateArg +>;