ivt
Version:
Ivt Components Library
1 lines • 337 kB
Source Map (JSON)
{"version":3,"file":"calendar-olAv9AH7.mjs","sources":["../../node_modules/date-fns/addMonths.js","../../node_modules/date-fns/addWeeks.js","../../node_modules/date-fns/addYears.js","../../node_modules/date-fns/max.js","../../node_modules/date-fns/min.js","../../node_modules/date-fns/isSameDay.js","../../node_modules/date-fns/differenceInCalendarMonths.js","../../node_modules/date-fns/endOfMonth.js","../../node_modules/date-fns/_lib/normalizeInterval.js","../../node_modules/date-fns/eachMonthOfInterval.js","../../node_modules/date-fns/startOfMonth.js","../../node_modules/date-fns/endOfYear.js","../../node_modules/date-fns/eachYearOfInterval.js","../../node_modules/date-fns/endOfWeek.js","../../node_modules/date-fns/endOfISOWeek.js","../../node_modules/date-fns/getDaysInMonth.js","../../node_modules/date-fns/getMonth.js","../../node_modules/date-fns/getYear.js","../../node_modules/date-fns/isAfter.js","../../node_modules/date-fns/isBefore.js","../../node_modules/date-fns/isSameMonth.js","../../node_modules/date-fns/isSameYear.js","../../node_modules/date-fns/setMonth.js","../../node_modules/date-fns/setYear.js","../../node_modules/@date-fns/tz/tzName/index.js","../../node_modules/@date-fns/tz/tzOffset/index.js","../../node_modules/@date-fns/tz/date/mini.js","../../node_modules/@date-fns/tz/date/index.js","../../node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js","../../node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js","../../node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js","../../node_modules/react-day-picker/dist/esm/classes/DateLib.js","../../node_modules/react-day-picker/dist/esm/classes/CalendarDay.js","../../node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js","../../node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js","../../node_modules/react-day-picker/dist/esm/components/Button.js","../../node_modules/react-day-picker/dist/esm/components/CaptionLabel.js","../../node_modules/react-day-picker/dist/esm/components/Chevron.js","../../node_modules/react-day-picker/dist/esm/components/Day.js","../../node_modules/react-day-picker/dist/esm/components/DayButton.js","../../node_modules/react-day-picker/dist/esm/UI.js","../../node_modules/react-day-picker/dist/esm/components/Dropdown.js","../../node_modules/react-day-picker/dist/esm/components/DropdownNav.js","../../node_modules/react-day-picker/dist/esm/components/Footer.js","../../node_modules/react-day-picker/dist/esm/components/Month.js","../../node_modules/react-day-picker/dist/esm/components/MonthCaption.js","../../node_modules/react-day-picker/dist/esm/components/MonthGrid.js","../../node_modules/react-day-picker/dist/esm/components/Months.js","../../node_modules/react-day-picker/dist/esm/useDayPicker.js","../../node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js","../../node_modules/react-day-picker/dist/esm/components/Nav.js","../../node_modules/react-day-picker/dist/esm/components/NextMonthButton.js","../../node_modules/react-day-picker/dist/esm/components/Option.js","../../node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js","../../node_modules/react-day-picker/dist/esm/components/Root.js","../../node_modules/react-day-picker/dist/esm/components/Select.js","../../node_modules/react-day-picker/dist/esm/components/Week.js","../../node_modules/react-day-picker/dist/esm/components/Weekday.js","../../node_modules/react-day-picker/dist/esm/components/Weekdays.js","../../node_modules/react-day-picker/dist/esm/components/WeekNumber.js","../../node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js","../../node_modules/react-day-picker/dist/esm/components/Weeks.js","../../node_modules/react-day-picker/dist/esm/components/YearsDropdown.js","../../node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js","../../node_modules/react-day-picker/dist/esm/utils/typeguards.js","../../node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js","../../node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js","../../node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js","../../node_modules/react-day-picker/dist/esm/helpers/getComponents.js","../../node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js","../../node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js","../../node_modules/react-day-picker/dist/esm/formatters/formatCaption.js","../../node_modules/react-day-picker/dist/esm/formatters/formatDay.js","../../node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js","../../node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js","../../node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js","../../node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js","../../node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js","../../node_modules/react-day-picker/dist/esm/helpers/getFormatters.js","../../node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js","../../node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js","../../node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js","../../node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js","../../node_modules/react-day-picker/dist/esm/labels/labelDayButton.js","../../node_modules/react-day-picker/dist/esm/labels/labelGrid.js","../../node_modules/react-day-picker/dist/esm/labels/labelGridcell.js","../../node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js","../../node_modules/react-day-picker/dist/esm/labels/labelNav.js","../../node_modules/react-day-picker/dist/esm/labels/labelNext.js","../../node_modules/react-day-picker/dist/esm/labels/labelPrevious.js","../../node_modules/react-day-picker/dist/esm/labels/labelWeekday.js","../../node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js","../../node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js","../../node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js","../../node_modules/react-day-picker/dist/esm/useAnimation.js","../../node_modules/react-day-picker/dist/esm/helpers/getDates.js","../../node_modules/react-day-picker/dist/esm/helpers/getDays.js","../../node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js","../../node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js","../../node_modules/react-day-picker/dist/esm/helpers/getMonths.js","../../node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js","../../node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js","../../node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js","../../node_modules/react-day-picker/dist/esm/helpers/getWeeks.js","../../node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js","../../node_modules/react-day-picker/dist/esm/useCalendar.js","../../node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js","../../node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js","../../node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js","../../node_modules/react-day-picker/dist/esm/useFocus.js","../../node_modules/react-day-picker/dist/esm/selection/useMulti.js","../../node_modules/react-day-picker/dist/esm/utils/addToRange.js","../../node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js","../../node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js","../../node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js","../../node_modules/react-day-picker/dist/esm/selection/useRange.js","../../node_modules/react-day-picker/dist/esm/selection/useSingle.js","../../node_modules/react-day-picker/dist/esm/useSelection.js","../../node_modules/react-day-picker/dist/esm/DayPicker.js","../../src/components/ui/calendar/calendar.tsx"],"sourcesContent":["import { constructFrom } from \"./constructFrom.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link addMonths} function options.\n */\n\n/**\n * @name addMonths\n * @category Month Helpers\n * @summary Add the specified number of months to the given date.\n *\n * @description\n * Add the specified number of months to the given date.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The date to be changed\n * @param amount - The amount of months to be added.\n * @param options - The options object\n *\n * @returns The new date with the months added\n *\n * @example\n * // Add 5 months to 1 September 2014:\n * const result = addMonths(new Date(2014, 8, 1), 5)\n * //=> Sun Feb 01 2015 00:00:00\n *\n * // Add one month to 30 January 2023:\n * const result = addMonths(new Date(2023, 0, 30), 1)\n * //=> Tue Feb 28 2023 00:00:00\n */\nexport function addMonths(date, amount, options) {\n const _date = toDate(date, options?.in);\n if (isNaN(amount)) return constructFrom(options?.in || date, NaN);\n if (!amount) {\n // If 0 months, no-op to avoid changing times in the hour before end of DST\n return _date;\n }\n const dayOfMonth = _date.getDate();\n\n // The JS Date object supports date math by accepting out-of-bounds values for\n // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and\n // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we\n // want except that dates will wrap around the end of a month, meaning that\n // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So\n // we'll default to the end of the desired month by adding 1 to the desired\n // month and using a date of 0 to back up one day to the end of the desired\n // month.\n const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());\n endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);\n const daysInMonth = endOfDesiredMonth.getDate();\n if (dayOfMonth >= daysInMonth) {\n // If we're already at the end of the month, then this is the correct date\n // and we're done.\n return endOfDesiredMonth;\n } else {\n // Otherwise, we now know that setting the original day-of-month value won't\n // cause an overflow, so set the desired day-of-month. Note that we can't\n // just set the date of `endOfDesiredMonth` because that object may have had\n // its time changed in the unusual case where where a DST transition was on\n // the last day of the month and its local time was in the hour skipped or\n // repeated next to a DST transition. So we use `date` instead which is\n // guaranteed to still have the original time.\n _date.setFullYear(\n endOfDesiredMonth.getFullYear(),\n endOfDesiredMonth.getMonth(),\n dayOfMonth,\n );\n return _date;\n }\n}\n\n// Fallback for modularized imports:\nexport default addMonths;\n","import { addDays } from \"./addDays.js\";\n\n/**\n * The {@link addWeeks} function options.\n */\n\n/**\n * @name addWeeks\n * @category Week Helpers\n * @summary Add the specified number of weeks to the given date.\n *\n * @description\n * Add the specified number of weeks to the given date.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The date to be changed\n * @param amount - The amount of weeks to be added.\n * @param options - An object with options\n *\n * @returns The new date with the weeks added\n *\n * @example\n * // Add 4 weeks to 1 September 2014:\n * const result = addWeeks(new Date(2014, 8, 1), 4)\n * //=> Mon Sep 29 2014 00:00:00\n */\nexport function addWeeks(date, amount, options) {\n return addDays(date, amount * 7, options);\n}\n\n// Fallback for modularized imports:\nexport default addWeeks;\n","import { addMonths } from \"./addMonths.js\";\n\n/**\n * The {@link addYears} function options.\n */\n\n/**\n * @name addYears\n * @category Year Helpers\n * @summary Add the specified number of years to the given date.\n *\n * @description\n * Add the specified number of years to the given date.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type.\n *\n * @param date - The date to be changed\n * @param amount - The amount of years to be added.\n * @param options - The options\n *\n * @returns The new date with the years added\n *\n * @example\n * // Add 5 years to 1 September 2014:\n * const result = addYears(new Date(2014, 8, 1), 5)\n * //=> Sun Sep 01 2019 00:00:00\n */\nexport function addYears(date, amount, options) {\n return addMonths(date, amount * 12, options);\n}\n\n// Fallback for modularized imports:\nexport default addYears;\n","import { constructFrom } from \"./constructFrom.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link max} function options.\n */\n\n/**\n * @name max\n * @category Common Helpers\n * @summary Return the latest of the given dates.\n *\n * @description\n * Return the latest of the given dates.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param dates - The dates to compare\n *\n * @returns The latest of the dates\n *\n * @example\n * // Which of these dates is the latest?\n * const result = max([\n * new Date(1989, 6, 10),\n * new Date(1987, 1, 11),\n * new Date(1995, 6, 2),\n * new Date(1990, 0, 1)\n * ])\n * //=> Sun Jul 02 1995 00:00:00\n */\nexport function max(dates, options) {\n let result;\n let context = options?.in;\n\n dates.forEach((date) => {\n // Use the first date object as the context function\n if (!context && typeof date === \"object\")\n context = constructFrom.bind(null, date);\n\n const date_ = toDate(date, context);\n if (!result || result < date_ || isNaN(+date_)) result = date_;\n });\n\n return constructFrom(context, result || NaN);\n}\n\n// Fallback for modularized imports:\nexport default max;\n","import { constructFrom } from \"./constructFrom.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link min} function options.\n */\n\n/**\n * @name min\n * @category Common Helpers\n * @summary Returns the earliest of the given dates.\n *\n * @description\n * Returns the earliest of the given dates.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param dates - The dates to compare\n *\n * @returns The earliest of the dates\n *\n * @example\n * // Which of these dates is the earliest?\n * const result = min([\n * new Date(1989, 6, 10),\n * new Date(1987, 1, 11),\n * new Date(1995, 6, 2),\n * new Date(1990, 0, 1)\n * ])\n * //=> Wed Feb 11 1987 00:00:00\n */\nexport function min(dates, options) {\n let result;\n let context = options?.in;\n\n dates.forEach((date) => {\n // Use the first date object as the context function\n if (!context && typeof date === \"object\")\n context = constructFrom.bind(null, date);\n\n const date_ = toDate(date, context);\n if (!result || result > date_ || isNaN(+date_)) result = date_;\n });\n\n return constructFrom(context, result || NaN);\n}\n\n// Fallback for modularized imports:\nexport default min;\n","import { normalizeDates } from \"./_lib/normalizeDates.js\";\nimport { startOfDay } from \"./startOfDay.js\";\n\n/**\n * The {@link isSameDay} function options.\n */\n\n/**\n * @name isSameDay\n * @category Day Helpers\n * @summary Are the given dates in the same day (and year and month)?\n *\n * @description\n * Are the given dates in the same day (and year and month)?\n *\n * @param laterDate - The first date to check\n * @param earlierDate - The second date to check\n * @param options - An object with options\n *\n * @returns The dates are in the same day (and year and month)\n *\n * @example\n * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?\n * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))\n * //=> true\n *\n * @example\n * // Are 4 September and 4 October in the same day?\n * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))\n * //=> false\n *\n * @example\n * // Are 4 September, 2014 and 4 September, 2015 in the same day?\n * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))\n * //=> false\n */\nexport function isSameDay(laterDate, earlierDate, options) {\n const [dateLeft_, dateRight_] = normalizeDates(\n options?.in,\n laterDate,\n earlierDate,\n );\n return +startOfDay(dateLeft_) === +startOfDay(dateRight_);\n}\n\n// Fallback for modularized imports:\nexport default isSameDay;\n","import { normalizeDates } from \"./_lib/normalizeDates.js\";\n\n/**\n * The {@link differenceInCalendarMonths} function options.\n */\n\n/**\n * @name differenceInCalendarMonths\n * @category Month Helpers\n * @summary Get the number of calendar months between the given dates.\n *\n * @description\n * Get the number of calendar months between the given dates.\n *\n * @param laterDate - The later date\n * @param earlierDate - The earlier date\n * @param options - An object with options\n *\n * @returns The number of calendar months\n *\n * @example\n * // How many calendar months are between 31 January 2014 and 1 September 2014?\n * const result = differenceInCalendarMonths(\n * new Date(2014, 8, 1),\n * new Date(2014, 0, 31)\n * )\n * //=> 8\n */\nexport function differenceInCalendarMonths(laterDate, earlierDate, options) {\n const [laterDate_, earlierDate_] = normalizeDates(\n options?.in,\n laterDate,\n earlierDate,\n );\n\n const yearsDiff = laterDate_.getFullYear() - earlierDate_.getFullYear();\n const monthsDiff = laterDate_.getMonth() - earlierDate_.getMonth();\n\n return yearsDiff * 12 + monthsDiff;\n}\n\n// Fallback for modularized imports:\nexport default differenceInCalendarMonths;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * The {@link endOfMonth} function options.\n */\n\n/**\n * @name endOfMonth\n * @category Month Helpers\n * @summary Return the end of a month for the given date.\n *\n * @description\n * Return the end of a month for the given date.\n * The result will be in the local timezone.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The original date\n * @param options - An object with options\n *\n * @returns The end of a month\n *\n * @example\n * // The end of a month for 2 September 2014 11:55:00:\n * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Tue Sep 30 2014 23:59:59.999\n */\nexport function endOfMonth(date, options) {\n const _date = toDate(date, options?.in);\n const month = _date.getMonth();\n _date.setFullYear(_date.getFullYear(), month + 1, 0);\n _date.setHours(23, 59, 59, 999);\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default endOfMonth;\n","import { normalizeDates } from \"./normalizeDates.js\";\n\nexport function normalizeInterval(context, interval) {\n const [start, end] = normalizeDates(context, interval.start, interval.end);\n return { start, end };\n}\n","import { normalizeInterval } from \"./_lib/normalizeInterval.js\";\nimport { constructFrom } from \"./constructFrom.js\";\n\n/**\n * The {@link eachMonthOfInterval} function options.\n */\n\n/**\n * The {@link eachMonthOfInterval} function result type. It resolves the proper data type.\n */\n\n/**\n * @name eachMonthOfInterval\n * @category Interval Helpers\n * @summary Return the array of months within the specified time interval.\n *\n * @description\n * Return the array of months within the specified time interval.\n *\n * @typeParam IntervalType - Interval type.\n * @typeParam Options - Options type.\n *\n * @param interval - The interval.\n * @param options - An object with options.\n *\n * @returns The array with starts of months from the month of the interval start to the month of the interval end\n *\n * @example\n * // Each month between 6 February 2014 and 10 August 2014:\n * const result = eachMonthOfInterval({\n * start: new Date(2014, 1, 6),\n * end: new Date(2014, 7, 10)\n * })\n * //=> [\n * // Sat Feb 01 2014 00:00:00,\n * // Sat Mar 01 2014 00:00:00,\n * // Tue Apr 01 2014 00:00:00,\n * // Thu May 01 2014 00:00:00,\n * // Sun Jun 01 2014 00:00:00,\n * // Tue Jul 01 2014 00:00:00,\n * // Fri Aug 01 2014 00:00:00\n * // ]\n */\nexport function eachMonthOfInterval(interval, options) {\n const { start, end } = normalizeInterval(options?.in, interval);\n\n let reversed = +start > +end;\n const endTime = reversed ? +start : +end;\n const date = reversed ? end : start;\n date.setHours(0, 0, 0, 0);\n date.setDate(1);\n\n let step = options?.step ?? 1;\n if (!step) return [];\n if (step < 0) {\n step = -step;\n reversed = !reversed;\n }\n\n const dates = [];\n\n while (+date <= endTime) {\n dates.push(constructFrom(start, date));\n date.setMonth(date.getMonth() + step);\n }\n\n return reversed ? dates.reverse() : dates;\n}\n\n// Fallback for modularized imports:\nexport default eachMonthOfInterval;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * The {@link startOfMonth} function options.\n */\n\n/**\n * @name startOfMonth\n * @category Month Helpers\n * @summary Return the start of a month for the given date.\n *\n * @description\n * Return the start of a month for the given date. The result will be in the local timezone.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments.\n * Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed,\n * or inferred from the arguments.\n *\n * @param date - The original date\n * @param options - An object with options\n *\n * @returns The start of a month\n *\n * @example\n * // The start of a month for 2 September 2014 11:55:00:\n * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Mon Sep 01 2014 00:00:00\n */\nexport function startOfMonth(date, options) {\n const _date = toDate(date, options?.in);\n _date.setDate(1);\n _date.setHours(0, 0, 0, 0);\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default startOfMonth;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * The {@link endOfYear} function options.\n */\n\n/**\n * @name endOfYear\n * @category Year Helpers\n * @summary Return the end of a year for the given date.\n *\n * @description\n * Return the end of a year for the given date.\n * The result will be in the local timezone.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The original date\n * @param options - The options\n *\n * @returns The end of a year\n *\n * @example\n * // The end of a year for 2 September 2014 11:55:00:\n * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Wed Dec 31 2014 23:59:59.999\n */\nexport function endOfYear(date, options) {\n const _date = toDate(date, options?.in);\n const year = _date.getFullYear();\n _date.setFullYear(year + 1, 0, 0);\n _date.setHours(23, 59, 59, 999);\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default endOfYear;\n","import { normalizeInterval } from \"./_lib/normalizeInterval.js\";\nimport { constructFrom } from \"./constructFrom.js\";\n\n/**\n * The {@link eachYearOfInterval} function options.\n */\n\n/**\n * The {@link eachYearOfInterval} function result type. It resolves the proper data type.\n * It uses the first argument date object type, starting from the date argument,\n * then the start interval date, and finally the end interval date. If\n * a context function is passed, it uses the context function return type.\n */\n\n/**\n * @name eachYearOfInterval\n * @category Interval Helpers\n * @summary Return the array of yearly timestamps within the specified time interval.\n *\n * @description\n * Return the array of yearly timestamps within the specified time interval.\n *\n * @typeParam IntervalType - Interval type.\n * @typeParam Options - Options type.\n *\n * @param interval - The interval.\n * @param options - An object with options.\n *\n * @returns The array with starts of yearly timestamps from the month of the interval start to the month of the interval end\n *\n * @example\n * // Each year between 6 February 2014 and 10 August 2017:\n * const result = eachYearOfInterval({\n * start: new Date(2014, 1, 6),\n * end: new Date(2017, 7, 10)\n * })\n * //=> [\n * // Wed Jan 01 2014 00:00:00,\n * // Thu Jan 01 2015 00:00:00,\n * // Fri Jan 01 2016 00:00:00,\n * // Sun Jan 01 2017 00:00:00\n * // ]\n */\nexport function eachYearOfInterval(interval, options) {\n const { start, end } = normalizeInterval(options?.in, interval);\n\n let reversed = +start > +end;\n const endTime = reversed ? +start : +end;\n const date = reversed ? end : start;\n date.setHours(0, 0, 0, 0);\n date.setMonth(0, 1);\n\n let step = options?.step ?? 1;\n if (!step) return [];\n if (step < 0) {\n step = -step;\n reversed = !reversed;\n }\n\n const dates = [];\n\n while (+date <= endTime) {\n dates.push(constructFrom(start, date));\n date.setFullYear(date.getFullYear() + step);\n }\n\n return reversed ? dates.reverse() : dates;\n}\n\n// Fallback for modularized imports:\nexport default eachYearOfInterval;\n","import { getDefaultOptions } from \"./_lib/defaultOptions.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link endOfWeek} function options.\n */\n\n/**\n * @name endOfWeek\n * @category Week Helpers\n * @summary Return the end of a week for the given date.\n *\n * @description\n * Return the end of a week for the given date.\n * The result will be in the local timezone.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The original date\n * @param options - An object with options\n *\n * @returns The end of a week\n *\n * @example\n * // The end of a week for 2 September 2014 11:55:00:\n * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Sat Sep 06 2014 23:59:59.999\n *\n * @example\n * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:\n * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })\n * //=> Sun Sep 07 2014 23:59:59.999\n */\nexport function endOfWeek(date, options) {\n const defaultOptions = getDefaultOptions();\n const weekStartsOn =\n options?.weekStartsOn ??\n options?.locale?.options?.weekStartsOn ??\n defaultOptions.weekStartsOn ??\n defaultOptions.locale?.options?.weekStartsOn ??\n 0;\n\n const _date = toDate(date, options?.in);\n const day = _date.getDay();\n const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);\n\n _date.setDate(_date.getDate() + diff);\n _date.setHours(23, 59, 59, 999);\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default endOfWeek;\n","import { endOfWeek } from \"./endOfWeek.js\";\n\n/**\n * The {@link endOfISOWeek} function options.\n */\n\n/**\n * @name endOfISOWeek\n * @category ISO Week Helpers\n * @summary Return the end of an ISO week for the given date.\n *\n * @description\n * Return the end of an ISO week for the given date.\n * The result will be in the local timezone.\n *\n * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The original date\n * @param options - An object with options\n *\n * @returns The end of an ISO week\n *\n * @example\n * // The end of an ISO week for 2 September 2014 11:55:00:\n * const result = endOfISOWeek(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Sun Sep 07 2014 23:59:59.999\n */\nexport function endOfISOWeek(date, options) {\n return endOfWeek(date, { ...options, weekStartsOn: 1 });\n}\n\n// Fallback for modularized imports:\nexport default endOfISOWeek;\n","import { constructFrom } from \"./constructFrom.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link getDaysInMonth} function options.\n */\n\n/**\n * @name getDaysInMonth\n * @category Month Helpers\n * @summary Get the number of days in a month of the given date.\n *\n * @description\n * Get the number of days in a month of the given date, considering the context if provided.\n *\n * @param date - The given date\n * @param options - An object with options\n *\n * @returns The number of days in a month\n *\n * @example\n * // How many days are in February 2000?\n * const result = getDaysInMonth(new Date(2000, 1))\n * //=> 29\n */\nexport function getDaysInMonth(date, options) {\n const _date = toDate(date, options?.in);\n const year = _date.getFullYear();\n const monthIndex = _date.getMonth();\n const lastDayOfMonth = constructFrom(_date, 0);\n lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);\n lastDayOfMonth.setHours(0, 0, 0, 0);\n return lastDayOfMonth.getDate();\n}\n\n// Fallback for modularized imports:\nexport default getDaysInMonth;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * The {@link getMonth} function options.\n */\n\n/**\n * @name getMonth\n * @category Month Helpers\n * @summary Get the month of the given date.\n *\n * @description\n * Get the month of the given date.\n *\n * @param date - The given date\n * @param options - An object with options\n *\n * @returns The month index (0-11)\n *\n * @example\n * // Which month is 29 February 2012?\n * const result = getMonth(new Date(2012, 1, 29))\n * //=> 1\n */\nexport function getMonth(date, options) {\n return toDate(date, options?.in).getMonth();\n}\n\n// Fallback for modularized imports:\nexport default getMonth;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * The {@link getYear} function options.\n */\n\n/**\n * @name getYear\n * @category Year Helpers\n * @summary Get the year of the given date.\n *\n * @description\n * Get the year of the given date.\n *\n * @param date - The given date\n * @param options - An object with options\n *\n * @returns The year\n *\n * @example\n * // Which year is 2 July 2014?\n * const result = getYear(new Date(2014, 6, 2))\n * //=> 2014\n */\nexport function getYear(date, options) {\n return toDate(date, options?.in).getFullYear();\n}\n\n// Fallback for modularized imports:\nexport default getYear;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * @name isAfter\n * @category Common Helpers\n * @summary Is the first date after the second one?\n *\n * @description\n * Is the first date after the second one?\n *\n * @param date - The date that should be after the other one to return true\n * @param dateToCompare - The date to compare with\n *\n * @returns The first date is after the second date\n *\n * @example\n * // Is 10 July 1989 after 11 February 1987?\n * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))\n * //=> true\n */\nexport function isAfter(date, dateToCompare) {\n return +toDate(date) > +toDate(dateToCompare);\n}\n\n// Fallback for modularized imports:\nexport default isAfter;\n","import { toDate } from \"./toDate.js\";\n\n/**\n * @name isBefore\n * @category Common Helpers\n * @summary Is the first date before the second one?\n *\n * @description\n * Is the first date before the second one?\n *\n * @param date - The date that should be before the other one to return true\n * @param dateToCompare - The date to compare with\n *\n * @returns The first date is before the second date\n *\n * @example\n * // Is 10 July 1989 before 11 February 1987?\n * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))\n * //=> false\n */\nexport function isBefore(date, dateToCompare) {\n return +toDate(date) < +toDate(dateToCompare);\n}\n\n// Fallback for modularized imports:\nexport default isBefore;\n","import { normalizeDates } from \"./_lib/normalizeDates.js\";\n\n/**\n * The {@link isSameMonth} function options.\n */\n\n/**\n * @name isSameMonth\n * @category Month Helpers\n * @summary Are the given dates in the same month (and year)?\n *\n * @description\n * Are the given dates in the same month (and year)?\n *\n * @param laterDate - The first date to check\n * @param earlierDate - The second date to check\n * @param options - An object with options\n *\n * @returns The dates are in the same month (and year)\n *\n * @example\n * // Are 2 September 2014 and 25 September 2014 in the same month?\n * const result = isSameMonth(new Date(2014, 8, 2), new Date(2014, 8, 25))\n * //=> true\n *\n * @example\n * // Are 2 September 2014 and 25 September 2015 in the same month?\n * const result = isSameMonth(new Date(2014, 8, 2), new Date(2015, 8, 25))\n * //=> false\n */\nexport function isSameMonth(laterDate, earlierDate, options) {\n const [laterDate_, earlierDate_] = normalizeDates(\n options?.in,\n laterDate,\n earlierDate,\n );\n return (\n laterDate_.getFullYear() === earlierDate_.getFullYear() &&\n laterDate_.getMonth() === earlierDate_.getMonth()\n );\n}\n\n// Fallback for modularized imports:\nexport default isSameMonth;\n","import { normalizeDates } from \"./_lib/normalizeDates.js\";\n\n/**\n * The {@link isSameYear} function options.\n */\n\n/**\n * @name isSameYear\n * @category Year Helpers\n * @summary Are the given dates in the same year?\n *\n * @description\n * Are the given dates in the same year?\n *\n * @param laterDate - The first date to check\n * @param earlierDate - The second date to check\n * @param options - An object with options\n *\n * @returns The dates are in the same year\n *\n * @example\n * // Are 2 September 2014 and 25 September 2014 in the same year?\n * const result = isSameYear(new Date(2014, 8, 2), new Date(2014, 8, 25))\n * //=> true\n */\nexport function isSameYear(laterDate, earlierDate, options) {\n const [laterDate_, earlierDate_] = normalizeDates(\n options?.in,\n laterDate,\n earlierDate,\n );\n return laterDate_.getFullYear() === earlierDate_.getFullYear();\n}\n\n// Fallback for modularized imports:\nexport default isSameYear;\n","import { constructFrom } from \"./constructFrom.js\";\nimport { getDaysInMonth } from \"./getDaysInMonth.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link setMonth} function options.\n */\n\n/**\n * @name setMonth\n * @category Month Helpers\n * @summary Set the month to the given date.\n *\n * @description\n * Set the month to the given date.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The date to be changed\n * @param month - The month index to set (0-11)\n * @param options - The options\n *\n * @returns The new date with the month set\n *\n * @example\n * // Set February to 1 September 2014:\n * const result = setMonth(new Date(2014, 8, 1), 1)\n * //=> Sat Feb 01 2014 00:00:00\n */\nexport function setMonth(date, month, options) {\n const _date = toDate(date, options?.in);\n const year = _date.getFullYear();\n const day = _date.getDate();\n\n const midMonth = constructFrom(options?.in || date, 0);\n midMonth.setFullYear(year, month, 15);\n midMonth.setHours(0, 0, 0, 0);\n const daysInMonth = getDaysInMonth(midMonth);\n\n // Set the earlier date, allows to wrap Jan 31 to Feb 28\n _date.setMonth(month, Math.min(day, daysInMonth));\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default setMonth;\n","import { constructFrom } from \"./constructFrom.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link setYear} function options.\n */\n\n/**\n * @name setYear\n * @category Year Helpers\n * @summary Set the year to the given date.\n *\n * @description\n * Set the year to the given date.\n *\n * @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).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The date to be changed\n * @param year - The year of the new date\n * @param options - An object with options.\n *\n * @returns The new date with the year set\n *\n * @example\n * // Set year 2013 to 1 September 2014:\n * const result = setYear(new Date(2014, 8, 1), 2013)\n * //=> Sun Sep 01 2013 00:00:00\n */\nexport function setYear(date, year, options) {\n const date_ = toDate(date, options?.in);\n\n // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date\n if (isNaN(+date_)) return constructFrom(options?.in || date, NaN);\n\n date_.setFullYear(year);\n return date_;\n}\n\n// Fallback for modularized imports:\nexport default setYear;\n","/**\n * Time zone name format.\n */\n\n/**\n * The function returns the time zone name for the given date in the specified\n * time zone.\n *\n * It uses the `Intl.DateTimeFormat` API and by default outputs the time zone\n * name in a long format, e.g. \"Pacific Standard Time\" or\n * \"Singapore Standard Time\".\n *\n * It is possible to specify the format as the third argument using one of the following options\n *\n * - \"short\": e.g. \"EDT\" or \"GMT+8\".\n * - \"long\": e.g. \"Eastern Daylight Time\".\n * - \"shortGeneric\": e.g. \"ET\" or \"Singapore Time\".\n * - \"longGeneric\": e.g. \"Eastern Time\" or \"Singapore Standard Time\".\n *\n * These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone\n *\n * @param timeZone - Time zone name (IANA or UTC offset)\n * @param date - Date object to get the time zone name for\n * @param format - Optional format of the time zone name. Defaults to \"long\". Can be \"short\", \"long\", \"shortGeneric\", or \"longGeneric\".\n *\n * @returns Time zone name (e.g. \"Singapore Standard Time\")\n */\nexport function tzName(timeZone, date, format = \"long\") {\n return new Intl.DateTimeFormat(\"en-US\", {\n // Enforces engine to render the time. Without the option JavaScriptCore omits it.\n hour: \"numeric\",\n timeZone: timeZone,\n timeZoneName: format\n }).format(date).split(/\\s/g) // Format.JS uses non-breaking spaces\n .slice(2) // Skip the hour and AM/PM parts\n .join(\" \");\n}","const offsetFormatCache = {};\nconst offsetCache = {};\n\n/**\n * The function extracts UTC offset in minutes from the given date in specified\n * time zone.\n *\n * Unlike `Date.prototype.getTimezoneOffset`, this function returns the value\n * mirrored to the sign of the offset in the time zone. For Asia/Singapore\n * (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.\n *\n * @param timeZone - Time zone name (IANA or UTC offset)\n * @param date - Date to check the offset for\n *\n * @returns UTC offset in minutes\n */\nexport function tzOffset(timeZone, date) {\n try {\n const format = offsetFormatCache[timeZone] ||= new Intl.DateTimeFormat(\"en-US\", {\n timeZone,\n timeZoneName: \"longOffset\"\n }).format;\n const offsetStr = format(date).split(\"GMT\")[1];\n if (offsetStr in offsetCache) return offsetCache[offsetStr];\n return calcOffset(offsetStr, offsetStr.split(\":\"));\n } catch {\n // Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH\n // See: https://github.com/nodejs/node/issues/53419\n if (timeZone in offsetCache) return offsetCache[timeZone];\n const captures = timeZone?.match(offsetRe);\n if (captures) return calcOffset(timeZone, captures.slice(1));\n return NaN;\n }\n}\nconst offsetRe = /([+-]\\d\\d):?(\\d\\d)?/;\nfunction calcOffset(cacheStr, values) {\n const hours = +(values[0] || 0);\n const minutes = +(values[1] || 0);\n // Convert seconds to minutes by dividing by 60 to keep the function return in minutes.\n const seconds = +(values[2] || 0) / 60;\n return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;\n}","import { tzOffset } from \"../tzOffset/index.js\";\nexport class TZDateMini extends Date {\n //#region static\n\n constructor(...args) {\n super();\n if (args.length > 1 && typeof args[args.length - 1] === \"string\") {\n this.timeZone = args.pop();\n }\n this.internal = new Date();\n if (isNaN(tzOffset(this.timeZone, this))) {\n this.setTime(NaN);\n } else {\n if (!args.length) {\n this.setTime(Date.now());\n } else if (typeof args[0] === \"number\" && (args.length === 1 || args.length === 2 && typeof args[1] !== \"number\")) {\n this.setTime(args[0]);\n } else if (typeof args[0] === \"string\") {\n this.setTime(+new Date(args[0]));\n } else if (args[0] instanceof Date) {\n this.setTime(+args[0]);\n } else {\n this.setTime(+new Date(...args));\n adjustToSystemTZ(this, NaN);\n syncToInternal(this);\n }\n }\n }\n static tz(tz, ...args) {\n return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);\n }\n\n //#endregion\n\n //#region time zone\n\n withTimeZone(timeZone) {\n return new TZDateMini(+this, timeZone);\n }\n getTimezoneOffset() {\n const offset = -tzOffset(this.timeZone, this);\n // Remove the seconds offset\n // use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.\n return offset > 0 ? Math.floor(offset) : Math.ceil(offset);\n }\n\n //#endregion\n\n //#region time\n\n setTime(time) {\n Date.prototype.setTime.apply(this, arguments);\n syncToInternal(this);\n return +this;\n }\n\n //#endregion\n\n //#region date-fns integration\n\n [Symbol.for(\"constructDateFrom\")](date) {\n return new TZDateMini(+new Date(date), this.timeZone);\n }\n\n //#endregion\n}\n\n// Assign getters and setters\nconst re = /^(get|set)(?!UTC)/;\nObject.getOwnPropertyNames(Date.prototype).forEach(method => {\n if (!re.test(method)) return;\n const utcMethod = method.replace(re, \"$1UTC\");\n // Filter out methods without UTC counterparts\n if (!TZDateMini.prototype[utcMethod]) return;\n if (method.startsWith(\"get\")) {\n // Delegate to internal date's UTC method\n TZDateMini.prototype[method] = function () {\n return this.internal[utcMethod]();\n };\n } else {\n // Assign regular setter\n TZDateMini.prototype[method] = function () {\n Date.prototype[utcMethod].apply(this.internal, arguments);\n syncFromInternal(this);\n return +this;\n };\n\n // Assign UTC setter\n TZDateMini.prototype[utcMethod] = function () {\n Date.prototype[utcMethod].apply(this, arguments);\n syncToInternal(this);\n return +this;\n };\n }\n});\n\n/**\n * Function syncs time to internal date, applying the time zone offset.\n *\n * @param {Date} date - Date to sync\n */\nfunction syncToInternal(date) {\n date.internal.setTime(+date);\n date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, date) * 60));\n}\n\n/**\n * Function syncs the internal date UTC values to the date. It allows to get\n * accurate timestamp value.\n *\n * @param {Date} date - The date to sync\n */\nfunction syncFromInternal(date) {\n // First we transpose the internal values\n Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());\n Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());\n\n // Now we have to adjust the date to the system time zone\n adjustToSystemTZ(date);\n}\n\n/**\n * Function adjusts the date to the system time zone. It uses the time zone\n * differences to calculate the offset and adjust the date.\n *\n * @param {Date} date - Date to adjust\n */\nfunction adjustToSystemTZ(date) {\n // Save the time zone offset before all the adjustments\n const baseOffset = tzOffset(date.timeZone, date);\n // Remove the seconds offset\n // use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.\n const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);\n //#region System DST adjustment\n\n // The biggest problem with using the system time zone is that when we create\n // a date from internal values stored in UTC, the system time zone might end\n // up on the DST hour:\n //\n // $ TZ=America/New_York node\n // > new Date(2020, 2, 8, 1).toString()\n // 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'\n // > new Date(2020, 2, 8, 2).toString()\n // 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'\n // > new Date(2020, 2, 8, 3).toString()\n // 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'\n // > new Date(2020, 2, 8, 4).toString()\n // 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'\n //\n // Here we get the same hour for both 2 and 3, because the system time zone\n // has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have\n // to adjust the internal date to reflect that.\n //\n // However we want to adjust only if that's the DST hour the change happenes,\n // not the hour where DST moves to.\n\n // We calculate the previous hour to see if the time zone offset has changed\n // and we have landed on the DST hour.\n const prevHour = new Date(+date);\n // We use UTC methods here as we don't want to land on the same hour again\n // in case of DST.\n prevHour.setUTCHours(prevHour.getUTCHours() - 1);\n\n // Calculate if we are on the system DST hour.\n const systemOffset = -new Date(+date).getTimezoneOffset();\n const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();\n const systemDSTChange = systemOffset - prevHourSystemOffset;\n // Detect the DST shift. System DST change will occur both on\n const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();\n\n // Move the internal date when we are on the system DST hour.\n if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);\n\n //#endregion\n\n //#region System diff adjustment\n\n // Now we need to adjust the date, since we just applied internal values.\n // We need to calculate the difference between the system and date time zones\n // and apply it to the date.\n\n const offsetDiff = systemOffset - offset;\n if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);\n\n //#endregion\n\n //#region Seconds System diff adjustment\n\n const systemDate = new Date(+date);\n // Set the UTC seconds to 0 to isolate the timezone offset in seconds.\n systemDate.setUTCSeconds(0);\n // For negative systemOffset, invert the seconds.\n const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;\n\n // Calculate the seconds offset based on the timezone offset.\n const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;\n if (secondsOffset || systemSecondsOffset) {\n date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);\n Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);\n }\n\n //#endregion\n\n //#region Post-adjustment DST fix\n\n const postBaseOffset = tzOffset(date.timeZone, date);\n // Remove the seconds offset\n // us