@formkit/tempo 0.0.18 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/addDay.d.ts +9 -0
  2. package/dist/addDay.mjs +11 -0
  3. package/dist/addDay.mjs.map +1 -0
  4. package/dist/addHour.d.ts +9 -0
  5. package/dist/addHour.mjs +11 -0
  6. package/dist/addHour.mjs.map +1 -0
  7. package/dist/addMinute.d.ts +9 -0
  8. package/dist/addMinute.mjs +11 -0
  9. package/dist/addMinute.mjs.map +1 -0
  10. package/dist/addMonth.d.ts +13 -0
  11. package/dist/addMonth.mjs +19 -0
  12. package/dist/addMonth.mjs.map +1 -0
  13. package/dist/addSecond.d.ts +9 -0
  14. package/dist/addSecond.mjs +11 -0
  15. package/dist/addSecond.mjs.map +1 -0
  16. package/dist/addYear.d.ts +13 -0
  17. package/dist/addYear.mjs +19 -0
  18. package/dist/addYear.mjs.map +1 -0
  19. package/dist/ap.d.ts +8 -0
  20. package/dist/ap.mjs +28 -0
  21. package/dist/ap.mjs.map +1 -0
  22. package/dist/applyOffset.d.ts +11 -0
  23. package/dist/applyOffset.mjs +20 -0
  24. package/dist/applyOffset.mjs.map +1 -0
  25. package/dist/bundle.mjs +1215 -0
  26. package/dist/bundle.mjs.map +1 -0
  27. package/dist/common.d.ts +137 -0
  28. package/dist/common.mjs +252 -0
  29. package/dist/common.mjs.map +1 -0
  30. package/dist/date.d.ts +9 -0
  31. package/dist/date.mjs +28 -0
  32. package/dist/date.mjs.map +1 -0
  33. package/dist/dayEnd.d.ts +9 -0
  34. package/dist/dayEnd.mjs +11 -0
  35. package/dist/dayEnd.mjs.map +1 -0
  36. package/dist/dayOfYear.d.ts +10 -0
  37. package/dist/dayOfYear.mjs +12 -0
  38. package/dist/dayOfYear.mjs.map +1 -0
  39. package/dist/dayStart.d.ts +9 -0
  40. package/dist/dayStart.mjs +11 -0
  41. package/dist/dayStart.mjs.map +1 -0
  42. package/dist/deviceLocale.d.ts +7 -0
  43. package/dist/deviceLocale.mjs +8 -0
  44. package/dist/deviceLocale.mjs.map +1 -0
  45. package/dist/deviceTZ.d.ts +8 -0
  46. package/dist/deviceTZ.mjs +8 -0
  47. package/dist/deviceTZ.mjs.map +1 -0
  48. package/dist/diffDays.d.ts +12 -0
  49. package/dist/diffDays.mjs +14 -0
  50. package/dist/diffDays.mjs.map +1 -0
  51. package/dist/diffHours.d.ts +12 -0
  52. package/dist/diffHours.mjs +14 -0
  53. package/dist/diffHours.mjs.map +1 -0
  54. package/dist/diffMilliseconds.d.ts +10 -0
  55. package/dist/diffMilliseconds.mjs +11 -0
  56. package/dist/diffMilliseconds.mjs.map +1 -0
  57. package/dist/diffMinutes.d.ts +11 -0
  58. package/dist/diffMinutes.mjs +10 -0
  59. package/dist/diffMinutes.mjs.map +1 -0
  60. package/dist/diffMonths.d.ts +10 -0
  61. package/dist/diffMonths.mjs +25 -0
  62. package/dist/diffMonths.mjs.map +1 -0
  63. package/dist/diffRound.d.ts +9 -0
  64. package/dist/diffRound.mjs +9 -0
  65. package/dist/diffRound.mjs.map +1 -0
  66. package/dist/diffSeconds.d.ts +12 -0
  67. package/dist/diffSeconds.mjs +10 -0
  68. package/dist/diffSeconds.mjs.map +1 -0
  69. package/dist/diffWeeks.d.ts +12 -0
  70. package/dist/diffWeeks.mjs +14 -0
  71. package/dist/diffWeeks.mjs.map +1 -0
  72. package/dist/diffYears.d.ts +10 -0
  73. package/dist/diffYears.mjs +10 -0
  74. package/dist/diffYears.mjs.map +1 -0
  75. package/dist/format.d.ts +36 -0
  76. package/dist/format.mjs +48 -0
  77. package/dist/format.mjs.map +1 -0
  78. package/dist/formatStr.d.ts +13 -0
  79. package/dist/formatStr.mjs +13 -0
  80. package/dist/formatStr.mjs.map +1 -0
  81. package/dist/fourDigitYear.d.ts +10 -0
  82. package/dist/fourDigitYear.mjs +12 -0
  83. package/dist/fourDigitYear.mjs.map +1 -0
  84. package/dist/hourEnd.d.ts +9 -0
  85. package/dist/hourEnd.mjs +11 -0
  86. package/dist/hourEnd.mjs.map +1 -0
  87. package/dist/hourStart.d.ts +9 -0
  88. package/dist/hourStart.mjs +11 -0
  89. package/dist/hourStart.mjs.map +1 -0
  90. package/dist/index.cjs +140 -21
  91. package/dist/index.cjs.map +1 -1
  92. package/dist/index.d.cts +75 -4
  93. package/dist/index.d.ts +54 -498
  94. package/dist/index.mjs +62 -1057
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/isAfter.d.ts +18 -0
  97. package/dist/isAfter.mjs +11 -0
  98. package/dist/isAfter.mjs.map +1 -0
  99. package/dist/isBefore.d.ts +13 -0
  100. package/dist/isBefore.mjs +11 -0
  101. package/dist/isBefore.mjs.map +1 -0
  102. package/dist/isEqual.d.ts +13 -0
  103. package/dist/isEqual.mjs +11 -0
  104. package/dist/isEqual.mjs.map +1 -0
  105. package/dist/iso8601.d.ts +13 -0
  106. package/dist/iso8601.mjs +27 -0
  107. package/dist/iso8601.mjs.map +1 -0
  108. package/dist/minuteEnd.d.ts +9 -0
  109. package/dist/minuteEnd.mjs +11 -0
  110. package/dist/minuteEnd.mjs.map +1 -0
  111. package/dist/minuteStart.d.ts +9 -0
  112. package/dist/minuteStart.mjs +11 -0
  113. package/dist/minuteStart.mjs.map +1 -0
  114. package/dist/monthDays.d.ts +9 -0
  115. package/dist/monthDays.mjs +10 -0
  116. package/dist/monthDays.mjs.map +1 -0
  117. package/dist/monthEnd.d.ts +10 -0
  118. package/dist/monthEnd.mjs +13 -0
  119. package/dist/monthEnd.mjs.map +1 -0
  120. package/dist/monthStart.d.ts +9 -0
  121. package/dist/monthStart.mjs +12 -0
  122. package/dist/monthStart.mjs.map +1 -0
  123. package/dist/nearestDay.d.ts +12 -0
  124. package/dist/nearestDay.mjs +46 -0
  125. package/dist/nearestDay.mjs.map +1 -0
  126. package/dist/offset.d.ts +14 -0
  127. package/dist/offset.mjs +36 -0
  128. package/dist/offset.mjs.map +1 -0
  129. package/dist/parse.d.ts +13 -0
  130. package/dist/parse.mjs +163 -0
  131. package/dist/parse.mjs.map +1 -0
  132. package/dist/parts.d.ts +12 -0
  133. package/dist/parts.mjs +214 -0
  134. package/dist/parts.mjs.map +1 -0
  135. package/dist/range.d.ts +10 -0
  136. package/dist/range.mjs +50 -0
  137. package/dist/range.mjs.map +1 -0
  138. package/dist/removeOffset.d.ts +10 -0
  139. package/dist/removeOffset.mjs +13 -0
  140. package/dist/removeOffset.mjs.map +1 -0
  141. package/dist/sameDay.d.ts +10 -0
  142. package/dist/sameDay.mjs +11 -0
  143. package/dist/sameDay.mjs.map +1 -0
  144. package/dist/sameHour.d.ts +10 -0
  145. package/dist/sameHour.mjs +11 -0
  146. package/dist/sameHour.mjs.map +1 -0
  147. package/dist/sameMinute.d.ts +10 -0
  148. package/dist/sameMinute.mjs +11 -0
  149. package/dist/sameMinute.mjs.map +1 -0
  150. package/dist/sameSecond.d.ts +10 -0
  151. package/dist/sameSecond.mjs +11 -0
  152. package/dist/sameSecond.mjs.map +1 -0
  153. package/dist/sameYear.d.ts +10 -0
  154. package/dist/sameYear.mjs +11 -0
  155. package/dist/sameYear.mjs.map +1 -0
  156. package/dist/types.d.ts +143 -0
  157. package/dist/types.mjs +1 -0
  158. package/dist/types.mjs.map +1 -0
  159. package/dist/tzDate.d.ts +15 -0
  160. package/dist/tzDate.mjs +12 -0
  161. package/dist/tzDate.mjs.map +1 -0
  162. package/dist/weekEnd.d.ts +12 -0
  163. package/dist/weekEnd.mjs +12 -0
  164. package/dist/weekEnd.mjs.map +1 -0
  165. package/dist/weekStart.d.ts +12 -0
  166. package/dist/weekStart.mjs +15 -0
  167. package/dist/weekStart.mjs.map +1 -0
  168. package/dist/yearDays.d.ts +9 -0
  169. package/dist/yearDays.mjs +10 -0
  170. package/dist/yearDays.mjs.map +1 -0
  171. package/dist/yearEnd.d.ts +9 -0
  172. package/dist/yearEnd.mjs +13 -0
  173. package/dist/yearEnd.mjs.map +1 -0
  174. package/dist/yearStart.d.ts +9 -0
  175. package/dist/yearStart.mjs +13 -0
  176. package/dist/yearStart.mjs.map +1 -0
  177. package/package.json +8 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/iso8601.ts","../src/date.ts","../src/addDay.ts","../src/monthEnd.ts","../src/monthDays.ts","../src/addMonth.ts","../src/addYear.ts","../src/addHour.ts","../src/addMinute.ts","../src/addSecond.ts","../src/common.ts","../src/ap.ts","../src/applyOffset.ts","../src/deviceTZ.ts","../src/offset.ts","../src/tzDate.ts","../src/dayOfYear.ts","../src/dayEnd.ts","../src/dayStart.ts","../src/parts.ts","../src/removeOffset.ts","../src/deviceLocale.ts","../src/format.ts","../src/formatStr.ts","../src/fourDigitYear.ts","../src/hourEnd.ts","../src/hourStart.ts","../src/minuteEnd.ts","../src/minuteStart.ts","../src/monthStart.ts","../src/yearDays.ts","../src/nearestDay.ts","../src/range.ts","../src/parse.ts","../src/sameDay.ts","../src/sameSecond.ts","../src/sameMinute.ts","../src/sameHour.ts","../src/sameYear.ts","../src/weekStart.ts","../src/weekEnd.ts","../src/yearStart.ts","../src/yearEnd.ts","../src/isBefore.ts","../src/isAfter.ts","../src/isEqual.ts"],"sourcesContent":["export { addDay } from \"./addDay\"\nexport { addMonth } from \"./addMonth\"\nexport { addYear } from \"./addYear\"\nexport { addHour } from \"./addHour\"\nexport { addMinute } from \"./addMinute\"\nexport { addSecond } from \"./addSecond\"\nexport { ap } from \"./ap\"\nexport { applyOffset } from \"./applyOffset\"\nexport { date } from \"./date\"\nexport { tzDate } from \"./tzDate\"\nexport { dayOfYear } from \"./dayOfYear\"\nexport { dayEnd } from \"./dayEnd\"\nexport { dayStart } from \"./dayStart\"\nexport { format } from \"./format\"\nexport { formatStr } from \"./formatStr\"\nexport { fourDigitYear } from \"./fourDigitYear\"\nexport { hourEnd } from \"./hourEnd\"\nexport { hourStart } from \"./hourStart\"\nexport { iso8601 } from \"./iso8601\"\nexport { minuteEnd } from \"./minuteEnd\"\nexport { minuteStart } from \"./minuteStart\"\nexport { monthDays } from \"./monthDays\"\nexport { monthEnd } from \"./monthEnd\"\nexport { monthStart } from \"./monthStart\"\nexport { nearestDay } from \"./nearestDay\"\nexport { offset } from \"./offset\"\nexport { parse } from \"./parse\"\nexport { parseParts } from \"./parse\"\nexport { parts } from \"./parts\"\nexport { range } from \"./range\"\nexport { removeOffset } from \"./removeOffset\"\nexport { sameDay } from \"./sameDay\"\nexport { sameSecond } from \"./sameSecond\"\nexport { sameMinute } from \"./sameMinute\"\nexport { sameHour } from \"./sameHour\"\nexport { sameYear } from \"./sameYear\"\nexport { weekEnd } from \"./weekEnd\"\nexport { weekStart } from \"./weekStart\"\nexport { yearDays } from \"./yearDays\"\nexport { yearStart } from \"./yearStart\"\nexport { yearEnd } from \"./yearEnd\"\nexport { isBefore } from \"./isBefore\"\nexport { isAfter } from \"./isAfter\"\nexport { isEqual } from \"./isEqual\"\nexport * from \"./types\"\n","/**\n * Matches a given date with ISO 8601 compliance. Allows the \"T\" to be missing\n * and only requires year and month, other params are required with increasing\n * specificity.\n */\nexport const iso8601Match =\n /^([0-9]{4})-([0-1][0-9])(?:-([0-3][0-9]))?(?:[T ]?([0-2][0-9])(?::([0-5][0-9]))?(?::([0-5][0-9]))?)?(?:\\.[0-9]+)?(Z|(?:\\+|\\-)[0-9]{2}:?[0-9]{2})?$/\n\n/**\n * True when the date string is valid ISO 8601.\n * @param date - A date string.\n */\nexport function iso8601(date: string): boolean {\n const matches = date.match(iso8601Match)\n if (matches) {\n const month = Number(matches[2])\n if (month < 1 || month > 12) return false\n\n if (typeof matches[3] !== undefined) {\n const date = Number(matches[3])\n if (date < 1 || date > 31) return false\n }\n if (typeof matches[4] !== undefined) {\n const hours = Number(matches[4])\n if (hours < 0 || hours > 23) return false\n }\n\n return true\n }\n return false\n}\n","import { iso8601, iso8601Match } from \"./iso8601\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Normalizes a \"short\" date like 2012-01-01 to 2012-01-01T00:00:00 to prevent\n * automatic coercion to UTC.\n * @param date - A string representation of the date.\n */\nfunction normalize(date: string) {\n const matches = date.match(iso8601Match)\n if (matches && typeof matches[4] === \"undefined\") {\n return (date += \"T00:00:00\")\n }\n return date\n}\n\n/**\n * A date to parse.\n * @param date - A Date object or an ISO 8601 date.\n */\nexport function date(date?: DateInput): Date {\n if (!date) {\n date = new Date()\n }\n if (date instanceof Date) {\n const d = new Date(date)\n d.setMilliseconds(0)\n return d\n }\n date = date.trim()\n if (iso8601(date)) {\n return new Date(normalize(date))\n }\n throw new Error(`Non ISO 8601 compliant date (${date}).`)\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n days after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addDay(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setDate(d.getDate() + count)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the last day of\n * the current month. Does not change the time.\n * @param inputDate - A string or Date object\n */\nexport function monthEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setDate(1)\n d.setMonth(d.getMonth() + 1)\n d.setDate(0)\n return d\n}\n","import { monthEnd } from \"./monthEnd\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns the total number of days from a given month.\n * @param inputDate - A string or Date object\n */\nexport function monthDays(inputDate: DateInput): number {\n const d = monthEnd(inputDate)\n return d.getDate()\n}\n","import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param inputDate - A date to increment by 1 or more months.\n * @param count - The quantity to add.\n * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addMonth(\n inputDate: DateInput,\n count = 1,\n dateOverflow = false\n) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n d.setMonth(d.getMonth() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n","import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n years after the original one. Keep in mind if\n * you start with a date late in a given month you could get a date after the\n * next month.\n * @param inputDate - A date to increment by 1 day.\n * @param count - The quantity of years add.\n * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addYear(inputDate: DateInput, count = 1, dateOverflow = false) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n\n d.setFullYear(d.getFullYear() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n hours after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addHour(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setHours(d.getHours() + count)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addMinute(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setMinutes(d.getMinutes() + count)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addSecond(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setSeconds(d.getSeconds() + count)\n return d\n}\n","import { date } from \"./date\"\nimport { ap } from \"./ap\"\nimport type {\n DateInput,\n NamedFormats,\n FormatPattern,\n FormatStyle,\n Part,\n FilledPart,\n} from \"./types\"\n\n/**\n * A date to use for determining various spec details.\n */\nexport const specDate = \"1999-03-04T02:05:01.000Z\"\n\n/**\n * A cache of Intl tokens and their respective formats.\n */\nexport const memoParts: Map<string, NamedFormats> = new Map()\n\n/**\n * Clock agnostic time format patterns.\n */\nexport const clockAgnostic: FormatPattern[] = [\n [\"YYYY\", { year: \"numeric\" }],\n [\"YY\", { year: \"2-digit\" }],\n [\"MMMM\", { month: \"long\" }],\n [\"MMM\", { month: \"short\" }],\n [\"MM\", { month: \"2-digit\" }],\n [\"M\", { month: \"numeric\" }],\n [\"DD\", { day: \"2-digit\" }],\n [\"D\", { day: \"numeric\" }],\n [\"dddd\", { weekday: \"long\" }],\n [\"ddd\", { weekday: \"short\" }],\n [\"d\", { weekday: \"narrow\" }],\n [\"mm\", { minute: \"2-digit\" }],\n [\"m\", { minute: \"numeric\" }],\n [\"ss\", { second: \"2-digit\" }],\n [\"s\", { second: \"numeric\" }],\n [\"Z\", { timeZoneName: \"short\" }],\n]\n\n/**\n * 24 hour click format patterns.\n */\nexport const clock24: FormatPattern[] = [\n [\"HH\", { hour: \"2-digit\" }],\n [\"H\", { hour: \"numeric\" }],\n]\n\n/**\n * 12 hour format patterns.\n */\nexport const clock12: FormatPattern[] = [\n [\"hh\", { hour: \"2-digit\" }],\n [\"h\", { hour: \"numeric\" }],\n [\"a\", { dayPeriod: \"narrow\" }],\n [\"A\", { dayPeriod: \"narrow\" }],\n]\n\n/**\n * Tokens that have a fixed length.\n */\nexport const fixedLength = {\n DD: 2,\n HH: 2,\n MM: 2,\n YY: 2,\n YYYY: 4,\n hh: 2,\n mm: 2,\n ss: 2,\n}\n\n/**\n * token Z can have variable length depending on the actual value, so it's\n */\nexport function fixedLengthByOffset(offsetString: string): number {\n // starts with [+-]xx:xx\n if (/^[+-]\\d{2}:\\d{2}/.test(offsetString)) {\n return 6\n }\n\n // starts with [+-]xxxx\n if (/^[+-]\\d{4}/.test(offsetString)) {\n return 5\n }\n\n throw new Error(\"Invalid offset format\")\n}\n\n/**\n * Tokens that are genitive — in that they can have \"possession\" when used in\n * a date phrase, \"March’s 4th day\" (but not in english).\n *\n * When computing a range for these, the range can be either genitive or not.\n * The same is true for parsing dates containing these tokens.\n */\nexport const genitiveTokens = [\"MMMM\", \"MMM\", \"dddd\", \"ddd\"]\n\n/**\n * A map of FormatPattern tuples to their respective token.\n */\nexport const tokens = /* @__PURE__ */ new Map(\n /* @__PURE__ */ [...clockAgnostic, ...clock24, ...clock12].map((format) => {\n return [format[0], format]\n })\n)\n\n/**\n * A map of locale’s am/pm.\n */\nexport const dayPeriodMap: Map<string, { am?: string; pm?: string }> = new Map()\n\n/**\n * An array of all available date styles.\n */\nexport const styles: ReadonlyArray<FormatStyle> = [\n \"full\",\n \"long\",\n \"medium\",\n \"short\",\n]\n\n/**\n * Creates a leading zero string of 2 digits.\n * @param n - A number.\n */\nexport const two = (n: number) => String(n).padStart(2, \"0\")\n/**\n * Creates a leading zero string of 4 digits.\n * @param n - A number.\n */\nexport const four = (n: number) => String(n).padStart(2, \"0\")\n\n/**\n * Normalizes a given part to NFKC.\n * @param part - The part to normalize.\n */\nexport function normStr(\n part: Intl.DateTimeFormatPart\n): Intl.DateTimeFormatPart {\n if (part.type === \"literal\") {\n part.value = part.value.normalize(\"NFKC\")\n }\n return part\n}\n\n/**\n * Returns the parts filled with pertinent values.\n * @param inputDate - The date to fill parts for\n * @param parts - An array of parts to fill\n * @param locale - The locale to fill with.\n * @param genitive - Whether to use genitive tokens values or not.\n * @param offset - The explicit offset to fill with (ignores the date’s true offset).\n */\nexport function fill(\n inputDate: DateInput,\n parts: Part[],\n locale: string,\n genitive = false,\n offset: string | null = null\n): FilledPart[] {\n const partMap = createPartMap(inputDate, parts, locale, genitive)\n const d = date(inputDate)\n\n /**\n * Not all values get returned \"properly\" as our tokens would suggest. For\n * example, at times Intl returns leading zeros when it shouldn't. This fn\n * is used to clean up those irregular values.\n * @param param - Part\n */\n function value({ partName, partValue, token }: Part) {\n if (partName === \"literal\") return partValue\n const value = partMap[partName]\n if (partName === \"hour\" && token === \"H\") {\n return value.replace(/^0/, \"\")\n }\n if ([\"mm\", \"ss\", \"MM\"].includes(token) && value.length === 1) {\n // Some tokens are supposed to have leading zeros, but Intl doesn't\n // always return them, depending on the locale and the format.\n return `0${value}`\n }\n if (partName === \"dayPeriod\") {\n const p = ap(d.getUTCHours() < 12 ? \"am\" : \"pm\", locale)\n return token === \"A\" ? p.toUpperCase() : p.toLowerCase()\n }\n if (partName === \"timeZoneName\") {\n return offset ?? minsToOffset(-1 * d.getTimezoneOffset())\n }\n return value\n }\n\n return parts.map((part): FilledPart => {\n return {\n ...part,\n value: value(part),\n }\n })\n}\n\n/**\n * Creates a map of part names to their respective values.\n * @param inputDate - The date to format\n * @param parts - The individual parts the need to be formatted.\n * @param locale - The locale to format the parts with.\n * @param genitive - Whether to use genitive tokens values or not.\n */\nfunction createPartMap(\n inputDate: DateInput,\n parts: Part[],\n locale: string,\n genitive = false\n): Record<keyof Intl.DateTimeFormatPartTypesRegistry, string> {\n const d = date(inputDate)\n const hour12 = parts.filter((part) => part.hour12)\n const hour24 = parts.filter((part) => !part.hour12)\n const valueParts: Intl.DateTimeFormatPart[] = []\n const genitiveParts: Part[] = []\n\n function addValues(requestedParts: Part[], hour12 = false) {\n const preciseLocale = `${locale}-u-hc-${hour12 ? \"h12\" : \"h23\"}`\n valueParts.push(\n ...new Intl.DateTimeFormat(\n preciseLocale,\n requestedParts.reduce(\n (options, part) => {\n if (part.partName === \"literal\") return options\n // Side effect! Genitive parts get shoved into a separate array.\n if (genitive && genitiveTokens.includes(part.token)) {\n genitiveParts.push(part)\n }\n return Object.assign(options, part.option)\n },\n { timeZone: \"UTC\" } as Intl.DateTimeFormatOptions\n )\n )\n .formatToParts(d)\n .map(normStr)\n )\n if (genitive && genitiveParts.length) {\n for (const part of genitiveParts) {\n let formattedParts: Intl.DateTimeFormatPart[] = []\n switch (part.token) {\n case \"MMMM\":\n formattedParts = new Intl.DateTimeFormat(preciseLocale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n })\n .formatToParts(d)\n .map(normStr)\n break\n case \"MMM\":\n formattedParts = new Intl.DateTimeFormat(preciseLocale, {\n dateStyle: \"medium\",\n timeZone: \"UTC\",\n })\n .formatToParts(d)\n .map(normStr)\n break\n }\n const genitiveFormattedPart = formattedParts.find(\n (p) => p.type === part.partName\n )\n const index = valueParts.findIndex((p) => p.type === part.partName)\n if (genitiveFormattedPart && index > -1) {\n valueParts[index] = genitiveFormattedPart\n }\n }\n }\n }\n\n if (hour12.length) addValues(hour12, true)\n if (hour24.length) addValues(hour24)\n\n return valueParts.reduce((map, part) => {\n map[part.type] = part.value\n return map\n }, {} as Record<keyof Intl.DateTimeFormatPartTypesRegistry, string>)\n}\n\n/**\n * Converts minutes (300) to an ISO8601 compatible offset (+0400).\n * @param timeDiffInMins - The difference in minutes between two timezones.\n * @returns\n */\nexport function minsToOffset(timeDiffInMins: number): string {\n const hours = String(Math.floor(Math.abs(timeDiffInMins / 60))).padStart(\n 2,\n \"0\"\n )\n const mins = String(Math.abs(timeDiffInMins % 60)).padStart(2, \"0\")\n const sign = timeDiffInMins < 0 ? \"-\" : \"+\"\n return `${sign}${hours}${mins}`\n}\n\n/**\n * Converts an offset (-0500) to minutes (-300).\n * @param offset - The offset to convert to minutes.\n */\nexport function offsetToMins(offset: string): number {\n validOffset(offset)\n const [_, sign, hours, mins] = offset.match(/([+-])([0-3][0-9])([0-6][0-9])/)!\n const offsetInMins = Number(hours) * 60 + Number(mins)\n return sign === \"+\" ? offsetInMins : -offsetInMins\n}\n\n/**\n * Validates that an offset is valid according to the format:\n * [+-]HHmm or [+-]HH:mm\n * @param offset - The offset to validate.\n */\nexport function validOffset(offset: string) {\n const valid = /^([+-])[0-3][0-9]:?[0-6][0-9]$/.test(offset)\n if (!valid) throw new Error(`Invalid offset: ${offset}`)\n return offset\n}\n\n/**\n * Given a string of tokens, escape any characters that are tokens.\n * @param str - The string to escape tokens in.\n * @returns The escaped string.\n */\nexport function escapeTokens(str: string): string {\n return clockAgnostic\n .concat(clock24)\n .concat(clock12)\n .sort((a, b) => (a[0].length > b[0].length ? 1 : -1))\n .reduce((target, part) => {\n return target.replace(part[0], `\\\\${part[0]}`)\n }, str)\n}\n\n/**\n * Checks if a given part should have a numeric value.\n * @param part - A part to check\n */\nexport function isNumeric(part: Part) {\n return [\"numeric\", \"2-digit\"].includes(part.partValue)\n}\n\n/**\n * Validates that an array of Parts can be parsed.\n * @param parts - Parts to validate for parsing ability.\n */\nexport function validate(parts: Part[]): Part[] | never {\n let lastPart: Part | undefined = undefined\n for (const part of parts) {\n if (part.partName === \"literal\" && !isNaN(parseFloat(part.partValue))) {\n throw new Error(`Numbers in format (${part.partValue}).`)\n }\n if (\n lastPart &&\n lastPart.partName !== \"literal\" &&\n part.partName !== \"literal\"\n ) {\n if (\n !(lastPart.token in fixedLength) &&\n !(part.token in fixedLength) &&\n !(isNumeric(lastPart) && part.token.toLowerCase() === \"a\")\n ) {\n throw new Error(\n `Illegal adjacent tokens (${lastPart.token}, ${part.token})`\n )\n }\n }\n lastPart = part\n }\n return parts\n}\n","import { dayPeriodMap, specDate, normStr } from \"./common\"\n\n/**\n * Determines the correct value for am/pm by locale and memoizes it.\n * @param ampm - am or pm\n * @param locale - The locale to fetch.\n */\nexport function ap(ampm: \"am\" | \"pm\", locale: string): string {\n const l = dayPeriodMap.get(locale)\n if (l && l[ampm]) return l[ampm] as string\n const specimen = new Date(specDate)\n specimen.setUTCHours(ampm === \"am\" ? 5 : 20)\n const subparts = new Intl.DateTimeFormat(locale, {\n timeStyle: \"full\",\n timeZone: \"UTC\",\n hour12: true,\n })\n .formatToParts(specimen)\n .map(normStr)\n const period = subparts.find((part) => part.type === \"dayPeriod\")\n if (period) {\n const localePeriods: { am?: string; pm?: string } = l || {}\n dayPeriodMap.set(\n locale,\n Object.assign(localePeriods, { [ampm]: period.value })\n )\n return period.value\n }\n return ampm\n}\n","import { date } from \"./date\"\nimport { offsetToMins } from \"./common\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Apply a given offset to a date, returning a new date with the offset\n * applied by adding or subtracting the given number of minutes.\n * @param dateInput - The date to apply the offset to.\n * @param offset - The offset to apply in the +-HHmm format.\n */\nexport function applyOffset(dateInput: DateInput, offset = \"+0000\"): Date {\n const d = date(dateInput)\n const timeDiffInMins = offsetToMins(offset)\n return new Date(d.getTime() + timeDiffInMins * 1000 * 60)\n}\n","/**\n * Get the timezone of the device.\n *\n * * Note: If the environment variable TZ is not set, it will return undefined.\n */\nexport function deviceTZ(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone as string | undefined\n}\n","import { date } from \"./date\"\nimport { normStr, minsToOffset } from \"./common\"\nimport { deviceTZ } from \"./deviceTZ\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Converts a date object from one timezone to that same time in UTC. This is\n * only for internal use.\n * @param d - A Date object\n * @param timeZone - A timezone string\n */\nfunction relativeTime(d: Date, timeZone: string): Date {\n const utcParts = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n timeZone,\n hourCycle: \"h23\",\n })\n .formatToParts(d)\n .map(normStr)\n const parts: {\n year?: string\n month?: string\n day?: string\n hour?: string\n minute?: string\n second?: string\n } = {}\n utcParts.forEach((part) => {\n parts[part.type as keyof typeof parts] = part.value\n })\n return new Date(\n `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}Z`\n )\n}\n\n/**\n * Returns the offset between two timezones on a given date. The results are\n * ISO8601 compatible offsets like -0800 or +0530.\n *\n * @param dateInput - The date on which to determine the offset.\n * @param tzA - (default: UTC) The second timezone to compare determine the offset between.\n * @param tzB - (default: device) The first timezone to compare determine the offset between.\n */\nexport function offset(\n utcTime: DateInput,\n tzA = \"UTC\",\n tzB = \"device\"\n): string {\n tzB = tzB === \"device\" ? deviceTZ() ?? \"utc\" : tzB\n const d = date(utcTime)\n const timeA = relativeTime(d, tzA)\n const timeB = relativeTime(d, tzB)\n const timeDiffInMins = (timeB.getTime() - timeA.getTime()) / 1000 / 60\n return minsToOffset(timeDiffInMins)\n}\n","import { offset } from \"./offset\"\nimport { applyOffset } from \"./applyOffset\"\nimport { date } from \"./date\"\nimport { DateInput } from \"./types\"\n\n/**\n * Creates a date object for the input date at the given timezone. For example\n * `tzDate(\"2017-05-06T12:00\", \"Europe/Amsterdam\")` will return a date object\n * for 2017-05-06T10:00:00Z since 12:00 in Amsterdam is 10:00Z.\n *\n * If given a Date object it will use local time and convert it to the given\n * timezone, thus \"changing\" the date.\n * @param inputDate - An iso8601 date string with no timezone\n * @param tz - A timezone string\n */\nexport function tzDate(inputDate: DateInput, tz: string) {\n const d = date(inputDate)\n return applyOffset(d, offset(d, tz))\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Gets the what day of the year a given date is. For example, August 1st is\n * the 213th day of the year on non- years and 214th on leap years.\n * @param inputDate - The input date.\n */\nexport function dayOfYear(inputDate: DateInput): number {\n const d = date(inputDate)\n return Math.round(\n (new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0).getTime() -\n new Date(d.getFullYear(), 0, 0).getTime()) /\n 86400000\n )\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given day.\n * @param inputDate - A string or Date object\n */\nexport function dayEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setHours(23, 59, 59, 999)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given day.\n * @param inputDate - A string or Date object\n */\nexport function dayStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setHours(0, 0, 0)\n return d\n}\n","import {\n styles,\n normStr,\n tokens,\n memoParts,\n clockAgnostic,\n clock24,\n specDate,\n clock12,\n} from \"./common\"\nimport type {\n ParseOptions,\n Format,\n Part,\n FormatStyle,\n FormatStyleObj,\n FormatPattern,\n NamedFormats,\n NamedFormatOption,\n} from \"./types\"\n/**\n * Given a format string, produce an array of matching \"parts\", each part\n * contains a regular expression and the corresponding\n * Intl.DateTimeFormatPartTypesRegistry key/value.\n * @param format - A format string like MM/DD/YYYY\n * @param locale - The locale to parse for.\n */\nexport function parts(format: Format, locale: string): Part[] {\n if (styles.includes(format as FormatStyle) || typeof format === \"object\") {\n return styleParts(format as FormatStyle | FormatStyleObj, locale)\n }\n let f = format\n let match = 0\n const testPattern = (pattern: FormatPattern) => {\n if (!pattern[2]) pattern[2] = new RegExp(`(.)?(${pattern[0]})`, \"g\")\n if (pattern[2].test(f)) {\n let didAdd = 0\n f = f.replace(pattern[2], (_, prefix, actualMatch) => {\n if (prefix === \"\\\\\") return actualMatch\n return `${typeof prefix === \"string\" ? prefix : \"\"}{!${\n didAdd++ ? match : match++\n }!}`\n })\n return !!didAdd\n }\n return false\n }\n\n function validate(patterns: Part[]): Part[] {\n const parts = patterns.map((part) => part.partName)\n const deduped = new Set(parts)\n if (parts.length > deduped.size) {\n throw new Error(`Cannot reuse format tokens.`)\n }\n return patterns\n }\n\n function createPart(\n hour12: boolean,\n [token, option, exp]: FormatPattern\n ): Part {\n const partName = Object.keys(option)[0] as Intl.DateTimeFormatPartTypes\n const partValue = option[partName] as string\n return {\n option,\n partName,\n partValue,\n token,\n pattern: exp as RegExp,\n hour12,\n }\n }\n\n const found24Patterns = clockAgnostic\n .filter(testPattern)\n .concat(clock24.filter(testPattern))\n .map(createPart.bind(null, false))\n\n // Reset the format before re-checking\n const parts = validate(\n found24Patterns.concat(\n clock12.filter(testPattern).map(createPart.bind(null, true))\n )\n )\n const extractIndex = /^\\{!(\\d+)!\\}$/\n return f\n .split(/(\\{!\\d+!\\})/)\n .map((match: string): Part => {\n const hasIndex = match.match(extractIndex)\n if (hasIndex) {\n return parts[Number(hasIndex[1])]\n }\n return {\n option: { literal: match },\n partName: \"literal\",\n partValue: match,\n token: match,\n pattern: new RegExp(\"\"),\n hour12: false,\n }\n })\n .filter((part) => !(part.partName === \"literal\" && part.partValue === \"\"))\n}\n\n/**\n * Determines the parts in a native date style, like \"full\".\n * @param format - A date style like \"full\" or \"short\"\n * @param locale - The locale string\n */\nfunction styleParts(\n format: FormatStyle | FormatStyleObj,\n locale: string\n): Part[] {\n const options: Intl.DateTimeFormatOptions = {\n timeZone: \"UTC\",\n }\n if (typeof format === \"string\") {\n options.dateStyle = format\n } else {\n if (\"date\" in format) options.dateStyle = format.date\n if (\"time\" in format) options.timeStyle = format.time\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n const segments = formatter.formatToParts(new Date(specDate)).map(normStr)\n const hourTypeSegments = formatter\n .formatToParts(new Date(\"1999-04-05T23:05:01.000Z\"))\n .map(normStr)\n const hourPart = hourTypeSegments.find((segment) => segment.type === \"hour\")\n const hourType = hourPart && hourPart.value === \"23\" ? 24 : 12\n return segments\n .map((part): Part | undefined => {\n const partName = part.type\n const formatPattern = guessPattern(\n part.type,\n part.value,\n locale,\n part.type === \"hour\" ? hourType : undefined\n )\n if (formatPattern === undefined) return\n const partValue = formatPattern[1][partName]\n if (!partValue) return\n if (!formatPattern[2])\n formatPattern[2] = new RegExp(`${formatPattern[0]}`, \"g\")\n return {\n option: { [partName]: partValue },\n partName,\n partValue,\n token: formatPattern[0],\n pattern: formatPattern[2],\n hour12: hourType === 12,\n }\n })\n .filter((part): part is Part => !!part)\n}\n\n/**\n * Attempts to guess the correct part value type for a given dateStyle. For\n * example a month of 02 would be \"2-digit\".\n *\n * @param partName - The part name to guess for, like 'year' or 'month'\n * @param partValue - The current value, it is assumed this is the smallest denom.\n */\nfunction guessPattern<T extends Intl.DateTimeFormatPartTypes>(\n partName: T,\n partValue: string,\n locale: string,\n hour: T extends \"hour\" ? 12 | 24 : undefined\n): FormatPattern | undefined {\n const l = partValue.length\n const n = !isNaN(Number(partValue))\n let style: NamedFormatOption | undefined\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n switch (partName) {\n case \"year\":\n return l === 2 ? tokens.get(\"YY\") : tokens.get(\"YYYY\")\n case \"month\":\n if (n) return l === 1 ? tokens.get(\"M\") : tokens.get(\"MM\")\n style = partStyle(locale, partName, partValue)\n switch (style) {\n case \"long\":\n return tokens.get(\"MMMM\")\n default:\n return tokens.get(\"MMM\")\n }\n case \"day\":\n return l === 1 ? tokens.get(\"D\") : tokens.get(\"DD\")\n case \"weekday\":\n style = partStyle(locale, partName, partValue)\n switch (style) {\n case \"narrow\":\n return tokens.get(\"d\")\n case \"short\":\n return tokens.get(\"ddd\")\n default:\n return tokens.get(\"dddd\")\n }\n case \"hour\":\n // Need to distinguish the locale’s default as 24 or 12 hour.\n if (hour === 12) return l === 1 ? tokens.get(\"h\") : tokens.get(\"hh\")\n return l === 1 ? tokens.get(\"H\") : tokens.get(\"HH\")\n case \"minute\":\n return l === 1 ? tokens.get(\"m\") : tokens.get(\"mm\")\n case \"second\":\n return l === 1 ? tokens.get(\"s\") : tokens.get(\"ss\")\n case \"dayPeriod\":\n return /^[A-Z]+$/u.test(partValue) ? tokens.get(\"A\") : tokens.get(\"a\")\n case \"literal\":\n return [partValue, { literal: partValue }, new RegExp(\"\")]\n case \"timeZoneName\":\n const offset = partValue.split(\"-\")\n return offset.length === 2 && offset[1].length === 4\n ? tokens.get(\"ZZ\")\n : tokens.get(\"Z\")\n default:\n return undefined\n }\n /* eslint-enable @typescript-eslint/no-non-null-assertion */\n}\n\n/**\n * Determines what \"style\" a given part is in. For example, if you provide:\n * ```js\n * partStyle('en', 'month', 'Jan')\n * // returns \"short\".\n * ```\n * Part styles are always expected to be \"genitive\" — for use in \"dateStyle\".\n * @param locale - Locale string\n * @param part - The part to attempt a lookup on\n * @param value - The value of a given part.\n */\nfunction partStyle(\n locale: string,\n part: keyof NamedFormats,\n value: string\n): NamedFormatOption | undefined {\n if (!memoParts.has(locale)) {\n const date = new Date(specDate)\n const weekdays = [3, 8, 9, 7, 6, 4, 3]\n const parts = [\"weekday\", \"month\", \"dayPeriod\"]\n const partStyles: NamedFormatOption[] = [\"long\", \"short\", \"narrow\"]\n const formats: Partial<NamedFormats> = {}\n for (let i = 0; i < 12; i++) {\n date.setMonth(0 + i)\n if (i in weekdays) date.setDate(weekdays[i])\n date.setUTCHours(8 + i)\n for (const style of partStyles) {\n const segments = new Intl.DateTimeFormat(\n locale,\n parts.reduce(\n (options, part) => Object.assign(options, { [part]: style }),\n { hour12: true, timeZone: \"UTC\" }\n )\n )\n .formatToParts(date)\n .map(normStr)\n if (style === \"long\" || style === \"short\") {\n const genitiveFormattedParts = new Intl.DateTimeFormat(locale, {\n dateStyle: style === \"short\" ? \"medium\" : \"long\",\n timeZone: \"UTC\",\n })\n .formatToParts(date)\n .map(normStr)\n const genitiveMonth = genitiveFormattedParts.find(\n (part) => part.type === \"month\"\n )\n const index = segments.findIndex((part) => part.type === \"month\")\n if (index > -1 && genitiveMonth) segments[index] = genitiveMonth\n }\n segments.forEach((part) => {\n if (part.type === \"literal\") return\n const type = part.type as keyof NamedFormats\n formats[type] = Object.assign(formats[type] || {}, {\n [part.value]: style,\n })\n })\n }\n }\n memoParts.set(locale, formats as NamedFormats)\n }\n const formats = memoParts.get(locale)\n return formats ? formats[part][value] : undefined\n}\n","import { applyOffset } from \"./applyOffset\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Inverts the offset and applies it to the given date, returning a new date.\n * @param dateInput - The date to remove the offset from.\n * @param offset - The offset to remove in the +-HHmm format.\n */\nexport function removeOffset(dateInput: DateInput, offset = \"+0000\"): Date {\n const positive = offset.slice(0, 1) === \"+\"\n return applyOffset(\n dateInput,\n offset.replace(positive ? \"+\" : \"-\", positive ? \"-\" : \"+\")\n )\n}\n","/**\n * Returns the device's locale. This is a simple proxy of the\n * `Intl.DateTimeFormat().resolvedOptions().locale` call.\n */\nexport function deviceLocale() {\n return Intl.DateTimeFormat().resolvedOptions().locale\n}\n","import { date } from \"./date\"\nimport { parts } from \"./parts\"\nimport { fill } from \"./common\"\nimport type { DateInput, Format, FormatOptions, Part } from \"./types\"\nimport { offset } from \"./offset\"\nimport { removeOffset } from \"./removeOffset\"\nimport { deviceLocale } from \"./deviceLocale\"\nimport { deviceTZ } from \"./deviceTZ\"\n\n/**\n * Produce a formatted string. Available strings:\n * token | description\n * ------|------------\n * YY | 2 digit year\n * YYYY | 4 digit year\n * M | The month 1-12\n * MM | The month 01-12\n * MMM | Short name Jan-Dec\n * MMMM | Full name January | December\n * D | The day of the month 1-31\n * DD | The day of the month 01-31\n * d | Single digit day \"T\"\n * ddd | Short day name Thu\n * dddd | Full day name Wednesday\n * H | Minimum hour digits, 24 hour, 0-23\n * HH | 2 hour digits, 24 hour, 00-23\n * h | Minimum hour digits, 12 hour clock, 1-12\n * hh | 2 hour digits, 12 hour clock, 01-12\n * m | The minute 0-59\n * mm | The minute 00-59\n * s | The second 0-59\n * ss | The second 00-59\n * a | am/pm\n * A | AM/PM\n * Z | +0800, +0530, -1345\n *\n * @param inputDate - A date object or ISO 8601 string\n * @param format - A format\n */\nexport function format(options: FormatOptions): string\nexport function format(\n inputDate: DateInput,\n format?: Format,\n locale?: string,\n genitive?: boolean,\n partFilter?: (part: Part) => boolean\n): string\nexport function format(\n inputDateOrOptions: DateInput | FormatOptions,\n format: Format = \"long\",\n locale: string | undefined = \"device\",\n genitive: boolean | undefined = false,\n partFilter?: (part: Part) => boolean\n): string {\n let tz: string | undefined, forceOffset: string | undefined\n\n if (\n typeof inputDateOrOptions === \"object\" &&\n !(inputDateOrOptions instanceof Date)\n ) {\n // Extract options from the object.\n ;({\n date: inputDateOrOptions,\n format,\n locale,\n genitive,\n partFilter,\n tz,\n } = inputDateOrOptions)\n }\n // ISO 8601 is a special case because it doesn't require a format.\n if (format === \"ISO8601\") return date(inputDateOrOptions).toISOString()\n\n if (tz) {\n forceOffset = offset(inputDateOrOptions, \"utc\", tz)\n }\n\n // We need to apply an offset to the date so that it can be formatted as UTC.\n tz ??= deviceTZ()\n if (tz?.toLowerCase() !== \"utc\") {\n inputDateOrOptions = removeOffset(\n inputDateOrOptions,\n offset(inputDateOrOptions, tz, \"utc\")\n )\n }\n\n if (!locale || locale === \"device\") {\n locale = deviceLocale()\n }\n\n return fill(\n inputDateOrOptions,\n parts(format, locale).filter(partFilter ?? (() => true)),\n locale,\n genitive,\n forceOffset\n )\n .map((p) => p.value)\n .join(\"\")\n}\n","import { parts } from \"./parts\"\nimport { escapeTokens } from \"./common\"\nimport type { Format, Part } from \"./types\"\n\n/**\n * Return the string format for a given format. For example:\n * ```js\n * formatStr({ date: 'long' }, 'en') // dddd, MMMM D, YYYY\n * ```\n * @param format - A format string or object.\n * @param locale - A locale or en by default.\n */\nexport function formatStr(\n format: Format,\n locale = \"en\",\n escapeLiterals = false,\n filterParts: (part: Part) => boolean = () => true\n): string {\n return parts(format, locale)\n .filter(filterParts)\n .reduce(\n (f, p) =>\n (f +=\n escapeLiterals && p.partName === \"literal\"\n ? escapeTokens(p.token)\n : p.token),\n \"\"\n )\n .normalize(\"NFKC\")\n}\n","/**\n * Converts a 2 digit year into a 4 digit year. This function assumes years 20\n * years into the future belong to the current century, and the past 80 are in\n * the past.\n *\n * @param value - 2 digits in string format\n */\nexport function fourDigitYear(value: string): number {\n const y = new Date().getFullYear()\n const currentYear = y % 100\n const century = Math.floor(y / 100)\n const parsedYear = Number(value)\n return (century + (parsedYear > currentYear + 20 ? -1 : 0)) * 100 + parsedYear\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given hour.\n * @param inputDate - A string or Date object\n */\nexport function hourEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setMinutes(59, 59, 999)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given hour.\n * @param inputDate - A string or Date object\n */\nexport function hourStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setMinutes(0, 0)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given minute.\n * @param inputDate - A string or Date object\n */\nexport function minuteEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setSeconds(59, 999)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given minute.\n * @param inputDate - A string or Date object\n */\nexport function minuteStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setSeconds(0)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the first day of a month.\n * @param inputDate - A string or Date object\n */\nexport function monthStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setDate(1)\n d.setHours(0, 0, 0)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Get the number of days in the given date’s year.\n * @param inputDate - A string or Date object\n */\nexport function yearDays(inputDate: DateInput): number {\n const d = date(inputDate)\n return (\n (new Date(d.getFullYear() + 1, 0, 0).getTime() -\n new Date(d.getFullYear(), 0, 0).getTime()) /\n 86400000\n )\n}\n","import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport { yearDays } from \"./yearDays\"\nimport { dayOfYear } from \"./dayOfYear\"\nimport { addDay } from \"./addDay\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Performs a bidirectional search for the nearest date that passes a function.\n * @param target - Performs a search for the nearest passing date.\n * @param search - The search function to use, given a date returns a boolean.\n * @param constraint - The number of iterations to perform before giving up, or logical constraint like \"month\", or \"week\".\n *\n */\nexport function nearestDay(\n inputDate: DateInput,\n search: (date: Date) => boolean,\n constraint: number | \"month\" | \"week\" | \"year\" = 7\n): Date | null {\n let increments: number\n let decrements: number\n const d = date(inputDate)\n switch (constraint) {\n case \"month\":\n decrements = d.getDate()\n increments = monthDays(d) - d.getDate()\n break\n case \"week\":\n decrements = d.getDay() + 1\n increments = 6 - d.getDay()\n break\n case \"year\":\n const total = yearDays(d)\n const day = dayOfYear(d)\n decrements = day\n increments = total - day\n break\n default:\n increments = decrements = constraint\n }\n\n for (let i = 0; i <= increments || i < decrements; i++) {\n if (i <= increments) {\n const next = addDay(d, i)\n if (search(next)) return next\n }\n if (i && i <= decrements) {\n const prev = addDay(d, -i)\n if (search(prev)) return prev\n }\n }\n return null\n}\n","import { format } from \"./format\"\nimport { ap } from \"./ap\"\nimport type { FormatToken } from \"./types\"\n/**\n * Returns an array of options for a given token in a given locale.\n * @param token - Get the full range of options for a given token\n * @param locale - The locale to fetch the options for.\n */\nexport function range(\n token: FormatToken,\n locale = \"en\",\n genitive = false\n): string[] {\n const r: (n: number, c: (index: number) => string | number) => string[] = (\n n,\n c\n ) =>\n Array(n)\n .fill(\"\")\n .map((_, i) => `${c(i)}`)\n\n if (token === \"M\") return r(12, (i) => i + 1)\n if (token === \"MM\")\n return r(12, (i) => {\n const m = i + 1\n return m < 10 ? `0${m}` : m\n })\n // MMM and MMMM\n if (token.startsWith(\"M\"))\n return range(\"MM\").map((m) =>\n format(`2000-${m}-05`, token, locale, genitive)\n )\n if (token.startsWith(\"d\"))\n return r(7, (i) => `0${i + 2}`).map((d) =>\n format(`2022-10-${d}`, token, locale)\n )\n if (token === \"a\")\n return [ap(\"am\", locale).toLowerCase(), ap(\"pm\", locale).toLowerCase()]\n if (token === \"A\")\n return [ap(\"am\", locale).toUpperCase(), ap(\"pm\", locale).toUpperCase()]\n if (token.startsWith(\"Y\")) {\n const year = new Date().getFullYear()\n return r(120, (i) => i + 1).reduce(\n (ranges, i) => {\n if (i !== \"120\")\n ranges.push(format(`${year + Number(i)}-06-06`, token, locale))\n ranges.unshift(format(`${year - Number(i)}-06-06`, token, locale))\n return ranges\n },\n [format(`${year}-06-06`, token, locale)]\n )\n }\n if (token.startsWith(\"D\"))\n return r(31, (i) => `${token === \"DD\" && i < 9 ? \"0\" : \"\"}${i + 1}`)\n if (token.startsWith(\"H\"))\n return r(24, (i) => `${token === \"HH\" && i < 10 ? \"0\" : \"\"}${i}`)\n if (token.startsWith(\"h\"))\n return r(12, (i) => `${token === \"hh\" && i < 9 ? \"0\" : \"\"}${i + 1}`)\n if (token.startsWith(\"m\") || token.startsWith(\"s\"))\n return r(60, (i) => `${token.length > 1 && i < 10 ? \"0\" : \"\"}${i}`)\n return []\n}\n","import { date } from \"./date\"\nimport { validate, styles, fixedLength, four, two, validOffset, fixedLengthByOffset } from \"./common\"\nimport { formatStr } from \"./formatStr\"\nimport { fourDigitYear } from \"./fourDigitYear\"\nimport { ap } from \"./ap\"\nimport { range } from \"./range\"\nimport { monthDays } from \"./monthDays\"\nimport { parts } from \"./parts\"\nimport type {\n ParseOptions,\n Format,\n Part,\n FormatStyle,\n FilledPart,\n FormatToken,\n} from \"./types\"\n\nexport function parse(options: ParseOptions): Date | never\nexport function parse(\n dateStr: string,\n format?: Format,\n locale?: string\n): Date | never\n/**\n * Parses a date string into a Date object using the given format.\n * @param dateStr - A string representing a date.\n * @param format - The format the given string is in.\n * @param locale - The locale to parse the string from.\n */\nexport function parse(\n dateStrOrOptions: string | ParseOptions,\n format: Format = \"ISO8601\",\n locale = \"device\"\n): Date | never {\n let partFilter: (part: Part) => boolean = () => true\n let dateStr: string\n let dateOverflow = \"backward\"\n if (typeof dateStrOrOptions === \"object\") {\n ;({\n date: dateStr,\n format = \"ISO8601\",\n locale = \"device\",\n dateOverflow = \"backward\",\n partFilter = () => true,\n } = dateStrOrOptions)\n } else {\n dateStr = dateStrOrOptions\n }\n if (!dateStr) throw new Error(\"parse() requires a date string.\")\n const invalid = (): never => {\n throw new Error(\n `Date (${dateStr}) does not match format (${formatStr(format, locale)})`\n )\n }\n if (format === \"ISO8601\") return date(dateStr)\n const genitive =\n styles.includes(format as FormatStyle) || typeof format === \"object\"\n const formatParts = validate(parts(format, locale).filter(partFilter))\n if (!formatParts.length) throw new Error(\"parse() requires a pattern.\")\n let parsedParts\n try {\n parsedParts = parseParts(dateStr, formatParts)\n } catch {\n return invalid()\n }\n const now = new Date()\n const parsed = new Map([\n [\"YYYY\", now.getFullYear()],\n [\"MM\", now.getMonth() + 1],\n [\"DD\", now.getDate()],\n [\"HH\", 0],\n [\"mm\", 0],\n [\"ss\", 0],\n ])\n let a: null | boolean = null\n let offset = \"\"\n parsedParts.forEach((part): void | never => {\n if (part.partName === \"literal\") return\n if (part.token === part.value) return invalid()\n const v = Number(part.value)\n if (parsed.has(part.token)) {\n // Parse for YYYY, MM, DD, HH, hh, mm, ss, Z\n parsed.set(part.token, v)\n } else if (part.token === \"YY\") {\n // Parse for YY\n parsed.set(\"YYYY\", fourDigitYear(part.value))\n } else {\n /* MMM - Short name Jan-Dec\n * MMMM - Full name January - December\n * h - Minimum hour digits, 12 hour clock, 1-12\n * hh - 2 hour digits, 12 hour clock, 01-12\n * m - The minute 0-59\n * mm - The minute 00-12\n * s - The second 0-59\n * a - am/pm\n * A - AM/PM\n */\n const t = part.token\n if (t.startsWith(\"d\")) {\n // d, ddd, dddd — we just ignore these because they are non specific\n return\n } else if (t === \"D\") {\n parsed.set(\"DD\", v)\n } else if (t === \"H\" || t.startsWith(\"h\")) {\n parsed.set(\"HH\", v)\n } else if (t === \"M\") {\n parsed.set(\"MM\", v)\n } else if (t === \"a\" || t === \"A\") {\n a = part.value.toLowerCase() === ap(\"am\", locale).toLowerCase()\n } else if (t === \"Z\") {\n offset = validOffset(part.value)\n } else {\n const values = range(t as FormatToken, locale, genitive)\n const index = values.indexOf(part.value)\n if (index !== -1) {\n switch (t) {\n case \"MMM\":\n case \"MMMM\":\n parsed.set(\"MM\", index + 1)\n break\n }\n }\n }\n }\n })\n let hours = parsed.get(\"HH\") || 0\n if (a === false) {\n hours += hours === 12 ? 0 : 12\n parsed.set(\"HH\", hours === 24 ? 0 : hours)\n } else if (a === true && hours === 12) {\n // 12am === 00 in 24 hour clock.\n parsed.set(\"HH\", 0)\n }\n parsed.set(\"MM\", (parsed.get(\"MM\") || 1) - 1)\n // eslint-disable-next-line prefer-const\n let [Y, M, D, h, m, s] = Array.from(parsed.values())\n\n // Determine if the date is valid for the month.\n const maxDaysInMonth = monthDays(new Date(`${four(Y)}-${two(M + 1)}-10`))\n if (maxDaysInMonth < D && dateOverflow === \"throw\")\n throw new Error(`Invalid date ${four(Y)}-${two(M + 1)}-${two(D)}`)\n D = dateOverflow === \"backward\" ? Math.min(D, maxDaysInMonth) : D\n\n // Create the date.\n const isoString = `${four(Y)}-${two(M + 1)}-${two(D)}T${two(h)}:${two(\n m\n )}:${two(s)}${offset}`\n const d = new Date(isoString)\n if (isFinite(+d)) return d\n return invalid()\n}\n\n/**\n * Given a string date and corresponding format parts, fill the parts with the\n * data from the string.\n * @param dateStr - A string to parse.\n * @param formatParts - The expected parts of the given string.\n */\nexport function parseParts(dateStr: string, formatParts: Part[]): FilledPart[] {\n let i = 0\n const advance = (parts: Part[]): [Part, Part | undefined] => [\n parts[i++],\n parts[i],\n ]\n let pos = 0\n const parsed: FilledPart[] = []\n let n: undefined | Part = undefined\n do {\n const [current, next] = advance(formatParts)\n n = next\n let len = 1\n if (current.partName === \"literal\") {\n // Literals can be discarded\n len = current.partValue.length\n } else if (current.partName === \"timeZoneName\") {\n len = fixedLengthByOffset(dateStr.substring(pos))\n } else if (current.token in fixedLength) {\n // Fixed length parse\n len = fixedLength[current.token as keyof typeof fixedLength]\n } else if (next) {\n // Variable length parse.\n if (next.partName === \"literal\") {\n len = dateStr.indexOf(next.partValue, pos) - pos\n if (len < 0) throw new Error()\n } else if (next.partName === \"dayPeriod\") {\n // Our validator is ensuring that the current item must be a variable\n // length number. We need to extract it.\n for (let i = 1; i <= 4; i++) {\n if (isNaN(Number(dateStr.charAt(pos + i)))) {\n len = i\n break\n }\n }\n } else {\n // Our validator guarantees the next is either not a number or it\n // will be the end of the string\n const nextChar = dateStr.substring(pos).search(/\\d/)\n if (nextChar !== -1) len = pos + nextChar\n }\n } else {\n len = dateStr.length\n }\n\n parsed.push({ ...current, value: dateStr.substring(pos, pos + len) })\n pos += len\n } while (n)\n return parsed\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same date. Ignores time.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameDay(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return (\n a.getDate() === b.getDate() &&\n a.getMonth() === b.getMonth() &&\n a.getFullYear() === b.getFullYear()\n )\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time seconds. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameSecond(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getSeconds() === b.getSeconds()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time minutes. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameMinute(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getMinutes() === b.getMinutes()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time hour. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameHour(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getHours() === b.getHours()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same year.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameYear(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getFullYear() === b.getFullYear()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given week. Defaults to Sunday as the\n * first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param inputDate - A string or Date object\n * @param startOfWeekDay - Determines which day of the week is the first\n */\nexport function weekStart(inputDate: DateInput, startOfWeekDay = 0): Date {\n const d = date(inputDate)\n let diff = startOfWeekDay - d.getDay()\n if (diff > 0) diff = diff - 7\n d.setDate(d.getDate() + diff)\n d.setHours(0, 0, 0)\n return d\n}\n","import { weekStart } from \"./weekStart\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the last day at the last second of the given week.\n * Defaults to Sunday as the first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param inputDate - Gets the last day of the week\n * @param startOfWeekDay - The first day of the week\n */\nexport function weekEnd(inputDate: DateInput, startOfWeekDay = 0): Date {\n const d = weekStart(inputDate, startOfWeekDay)\n d.setDate(d.getDate() + 6)\n d.setHours(23, 59, 59)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the start of the current year.\n * @param inputDate - A string or Date object\n */\nexport function yearStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n\n d.setMonth(0)\n d.setDate(1)\n d.setHours(0, 0, 0)\n\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the end of the current year.\n * @param inputDate - A string or Date object\n */\nexport function yearEnd(inputDate: DateInput): Date {\n const d = date(inputDate);\n\n d.setMonth(11);\n d.setDate(31);\n d.setHours(23, 59, 59, 999);\n\n return d;\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Is the first date before the second one?\n *\n * @param inputDate - 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 */\nexport function isBefore(inputDate: DateInput, dateToCompare: DateInput) {\n const _date = date(inputDate)\n const _dateToCompare = date(dateToCompare)\n\n return +_date < +_dateToCompare\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\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 inputDate - 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 */\nexport function isAfter(inputDate: DateInput, dateToCompare: DateInput) {\n const _date = date(inputDate)\n const _dateToCompare = date(dateToCompare)\n\n return +_date > +_dateToCompare\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Are the given dates equal?\n *\n * @param dateLeft - The first date to compare\n * @param dateRight - The second date to compare\n *\n * @returns The dates are equal.\n */\nexport function isEqual(dateLeft: DateInput, dateRight: DateInput) {\n const _dateLeft = date(dateLeft)\n const _dateRight = date(dateRight)\n\n return +_dateLeft === +_dateRight\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,eACX;AAMK,SAAS,QAAQA,OAAuB;AAC7C,QAAM,UAAUA,MAAK,MAAM,YAAY;AACvC,MAAI,SAAS;AACX,UAAM,QAAQ,OAAO,QAAQ,CAAC,CAAC;AAC/B,QAAI,QAAQ,KAAK,QAAQ;AAAI,aAAO;AAEpC,QAAI,OAAO,QAAQ,CAAC,MAAM,QAAW;AACnC,YAAMA,QAAO,OAAO,QAAQ,CAAC,CA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AO,OAAO;AAC5B,IAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI;AAC5B,IAAE,SAAS,GAAG,GAAG,CAAC;AAClB,SAAO;AACT;;;ACPO,SAAS,QAAQ,WAAsB,iBAAiB,GAAS;AACtE,QAAM,IAAI,UAAU,WAAW,cAAc;AAC7C,IAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC;AACzB,IAAE,SAAS,IAAI,IAAI,EAAE;AACrB,SAAO;AACT;;;ACRO,SAAS,UAAU,WAA4B;AACpD,QAAM,IAAI,KAAK,SAAS;AAExB,IAAE,SAAS,CAAC;AACZ,IAAE,QAAQ,CAAC;AACX,IAAE,SAAS,GAAG,GAAG,CAAC;AAElB,SAAO;AACT;;;ACRO,SAAS,QAAQ,WAA4B;AAClD,QAAM,IAAI,KAAK,SAAS;AAExB,IAAE,SAAS,EAAE;AACb,IAAE,QAAQ,EAAE;AACZ,IAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAE1B,SAAO;AACT;;;ACJO,SAAS,SAAS,WAAsB,eAA0B;AACvE,QAAM,QAAQ,KAAK,SAAS;AAC5B,QAAM,iBAAiB,KAAK,aAAa;AAEzC,SAAO,CAAC,QAAQ,CAAC;AACnB;;;ACAO,SAAS,QAAQ,WAAsB,eAA0B;AACtE,QAAM,QAAQ,KAAK,SAAS;AAC5B,QAAM,iBAAiB,KAAK,aAAa;AAEzC,SAAO,CAAC,QAAQ,CAAC;AACnB;;;ACVO,SAAS,QAAQ,UAAqB,WAAsB;AACjE,QAAM,YAAY,KAAK,QAAQ;AAC/B,QAAM,aAAa,KAAK,SAAS;AAEjC,SAAO,CAAC,cAAc,CAAC;AACzB;","names":["date","date","format","parts","offset","value","hour12","offset","parts","format","validate","parts","match","offset","date","formats","part","offset","format","format","format","offset","parts","i"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/iso8601.ts","../src/date.ts","../src/addDay.ts","../src/monthEnd.ts","../src/monthDays.ts","../src/addMonth.ts","../src/addYear.ts","../src/addHour.ts","../src/addMinute.ts","../src/addSecond.ts","../src/common.ts","../src/ap.ts","../src/applyOffset.ts","../src/deviceTZ.ts","../src/offset.ts","../src/tzDate.ts","../src/dayOfYear.ts","../src/dayEnd.ts","../src/dayStart.ts","../src/parts.ts","../src/removeOffset.ts","../src/deviceLocale.ts","../src/format.ts","../src/formatStr.ts","../src/fourDigitYear.ts","../src/hourEnd.ts","../src/hourStart.ts","../src/minuteEnd.ts","../src/minuteStart.ts","../src/monthStart.ts","../src/yearDays.ts","../src/nearestDay.ts","../src/range.ts","../src/parse.ts","../src/sameDay.ts","../src/sameSecond.ts","../src/sameMinute.ts","../src/sameHour.ts","../src/sameYear.ts","../src/weekStart.ts","../src/weekEnd.ts","../src/yearStart.ts","../src/yearEnd.ts","../src/isBefore.ts","../src/isAfter.ts","../src/isEqual.ts","../src/diffMilliseconds.ts","../src/diffRound.ts","../src/diffSeconds.ts","../src/diffMinutes.ts","../src/diffHours.ts","../src/diffDays.ts","../src/diffWeeks.ts","../src/diffMonths.ts","../src/diffYears.ts"],"sourcesContent":["export { addDay } from \"./addDay\"\nexport { addMonth } from \"./addMonth\"\nexport { addYear } from \"./addYear\"\nexport { addHour } from \"./addHour\"\nexport { addMinute } from \"./addMinute\"\nexport { addSecond } from \"./addSecond\"\nexport { ap } from \"./ap\"\nexport { applyOffset } from \"./applyOffset\"\nexport { date } from \"./date\"\nexport { tzDate } from \"./tzDate\"\nexport { dayOfYear } from \"./dayOfYear\"\nexport { dayEnd } from \"./dayEnd\"\nexport { dayStart } from \"./dayStart\"\nexport { format } from \"./format\"\nexport { formatStr } from \"./formatStr\"\nexport { fourDigitYear } from \"./fourDigitYear\"\nexport { hourEnd } from \"./hourEnd\"\nexport { hourStart } from \"./hourStart\"\nexport { iso8601 } from \"./iso8601\"\nexport { minuteEnd } from \"./minuteEnd\"\nexport { minuteStart } from \"./minuteStart\"\nexport { monthDays } from \"./monthDays\"\nexport { monthEnd } from \"./monthEnd\"\nexport { monthStart } from \"./monthStart\"\nexport { nearestDay } from \"./nearestDay\"\nexport { offset } from \"./offset\"\nexport { parse } from \"./parse\"\nexport { parseParts } from \"./parse\"\nexport { parts } from \"./parts\"\nexport { range } from \"./range\"\nexport { removeOffset } from \"./removeOffset\"\nexport { sameDay } from \"./sameDay\"\nexport { sameSecond } from \"./sameSecond\"\nexport { sameMinute } from \"./sameMinute\"\nexport { sameHour } from \"./sameHour\"\nexport { sameYear } from \"./sameYear\"\nexport { weekEnd } from \"./weekEnd\"\nexport { weekStart } from \"./weekStart\"\nexport { yearDays } from \"./yearDays\"\nexport { yearStart } from \"./yearStart\"\nexport { yearEnd } from \"./yearEnd\"\nexport { isBefore } from \"./isBefore\"\nexport { isAfter } from \"./isAfter\"\nexport { isEqual } from \"./isEqual\"\nexport * from \"./types\"\nexport { diffMilliseconds } from \"./diffMilliseconds\"\nexport { diffSeconds } from \"./diffSeconds\"\nexport { diffMinutes } from \"./diffMinutes\"\nexport { diffHours } from \"./diffHours\"\nexport { diffDays } from \"./diffDays\"\nexport { diffWeeks } from \"./diffWeeks\"\nexport { diffMonths } from \"./diffMonths\"\nexport { diffYears } from \"./diffYears\"\n","/**\n * Matches a given date with ISO 8601 compliance. Allows the \"T\" to be missing\n * and only requires year and month, other params are required with increasing\n * specificity.\n */\nexport const iso8601Match =\n /^([0-9]{4})-([0-1][0-9])(?:-([0-3][0-9]))?(?:[T ]?([0-2][0-9])(?::([0-5][0-9]))?(?::([0-5][0-9]))?)?(?:\\.[0-9]+)?(Z|(?:\\+|\\-)[0-9]{2}:?[0-9]{2})?$/\n\n/**\n * True when the date string is valid ISO 8601.\n * @param date - A date string.\n */\nexport function iso8601(date: string): boolean {\n const matches = date.match(iso8601Match)\n if (matches) {\n const month = Number(matches[2])\n if (month < 1 || month > 12) return false\n\n if (typeof matches[3] !== undefined) {\n const date = Number(matches[3])\n if (date < 1 || date > 31) return false\n }\n if (typeof matches[4] !== undefined) {\n const hours = Number(matches[4])\n if (hours < 0 || hours > 23) return false\n }\n\n return true\n }\n return false\n}\n","import { iso8601, iso8601Match } from \"./iso8601\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Normalizes a \"short\" date like 2012-01-01 to 2012-01-01T00:00:00 to prevent\n * automatic coercion to UTC.\n * @param date - A string representation of the date.\n */\nfunction normalize(date: string) {\n const matches = date.match(iso8601Match)\n if (matches && typeof matches[4] === \"undefined\") {\n return (date += \"T00:00:00\")\n }\n return date\n}\n\n/**\n * A date to parse.\n * @param date - A Date object or an ISO 8601 date.\n */\nexport function date(date?: DateInput): Date {\n if (!date) {\n date = new Date()\n }\n if (date instanceof Date) {\n const d = new Date(date)\n d.setMilliseconds(0)\n return d\n }\n date = date.trim()\n if (iso8601(date)) {\n return new Date(normalize(date))\n }\n throw new Error(`Non ISO 8601 compliant date (${date}).`)\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n days after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addDay(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setDate(d.getDate() + count)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the last day of\n * the current month. Does not change the time.\n * @param inputDate - A string or Date object\n */\nexport function monthEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setDate(1)\n d.setMonth(d.getMonth() + 1)\n d.setDate(0)\n return d\n}\n","import { monthEnd } from \"./monthEnd\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns the total number of days from a given month.\n * @param inputDate - A string or Date object\n */\nexport function monthDays(inputDate: DateInput): number {\n const d = monthEnd(inputDate)\n return d.getDate()\n}\n","import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param inputDate - A date to increment by 1 or more months.\n * @param count - The quantity to add.\n * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addMonth(\n inputDate: DateInput,\n count = 1,\n dateOverflow = false\n) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n d.setMonth(d.getMonth() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n","import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n years after the original one. Keep in mind if\n * you start with a date late in a given month you could get a date after the\n * next month.\n * @param inputDate - A date to increment by 1 day.\n * @param count - The quantity of years add.\n * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addYear(inputDate: DateInput, count = 1, dateOverflow = false) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n\n d.setFullYear(d.getFullYear() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n hours after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addHour(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setHours(d.getHours() + count)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addMinute(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setMinutes(d.getMinutes() + count)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addSecond(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setSeconds(d.getSeconds() + count)\n return d\n}\n","import { date } from \"./date\"\nimport { ap } from \"./ap\"\nimport type {\n DateInput,\n NamedFormats,\n FormatPattern,\n FormatStyle,\n Part,\n FilledPart,\n Format,\n} from \"./types\"\n\n/**\n * A date to use for determining various spec details.\n */\nexport const specDate = \"1999-03-04T02:05:01.000Z\"\n\n/**\n * A cache of Intl tokens and their respective formats.\n */\nexport const memoParts: Map<string, NamedFormats> = new Map()\n\n/**\n * Clock agnostic time format patterns.\n */\nexport const clockAgnostic: FormatPattern[] = [\n [\"YYYY\", { year: \"numeric\" }],\n [\"YY\", { year: \"2-digit\" }],\n [\"MMMM\", { month: \"long\" }],\n [\"MMM\", { month: \"short\" }],\n [\"MM\", { month: \"2-digit\" }],\n [\"M\", { month: \"numeric\" }],\n [\"DD\", { day: \"2-digit\" }],\n [\"D\", { day: \"numeric\" }],\n [\"dddd\", { weekday: \"long\" }],\n [\"ddd\", { weekday: \"short\" }],\n [\"d\", { weekday: \"narrow\" }],\n [\"mm\", { minute: \"2-digit\" }],\n [\"m\", { minute: \"numeric\" }],\n [\"ss\", { second: \"2-digit\" }],\n [\"s\", { second: \"numeric\" }],\n [\"ZZ\", { timeZoneName: \"long\" }],\n [\"Z\", { timeZoneName: \"short\" }],\n]\n\n/**\n * Timezone tokens.\n */\nconst timeZoneTokens = [\"Z\", \"ZZ\"] as const\n\n/**\n * Timezone token type.\n */\nexport type TimezoneToken = (typeof timeZoneTokens)[number]\n\n/**\n * 24 hour click format patterns.\n */\nexport const clock24: FormatPattern[] = [\n [\"HH\", { hour: \"2-digit\" }],\n [\"H\", { hour: \"numeric\" }],\n]\n\n/**\n * 12 hour format patterns.\n */\nexport const clock12: FormatPattern[] = [\n [\"hh\", { hour: \"2-digit\" }],\n [\"h\", { hour: \"numeric\" }],\n [\"a\", { dayPeriod: \"narrow\" }],\n [\"A\", { dayPeriod: \"narrow\" }],\n]\n\n/**\n * Tokens that have a fixed length.\n */\nexport const fixedLength = {\n DD: 2,\n HH: 2,\n MM: 2,\n YY: 2,\n YYYY: 4,\n hh: 2,\n mm: 2,\n ss: 2,\n}\n\n/**\n * token Z can have variable length depending on the actual value, so it's\n */\nexport function fixedLengthByOffset(offsetString: string): 6 | 5 {\n // starts with [+-]xx:xx\n if (/^[+-]\\d{2}:\\d{2}/.test(offsetString)) {\n return 6\n }\n\n // starts with [+-]xxxx\n if (/^[+-]\\d{4}/.test(offsetString)) {\n return 5\n }\n\n throw new Error(\"Invalid offset format\")\n}\n\n/**\n * Tokens that are genitive — in that they can have \"possession\" when used in\n * a date phrase, \"March’s 4th day\" (but not in english).\n *\n * When computing a range for these, the range can be either genitive or not.\n * The same is true for parsing dates containing these tokens.\n */\nexport const genitiveTokens = [\"MMMM\", \"MMM\", \"dddd\", \"ddd\"]\n\n/**\n * A map of FormatPattern tuples to their respective token.\n */\nexport const tokens = /* @__PURE__ */ new Map(\n /* @__PURE__ */ [...clockAgnostic, ...clock24, ...clock12].map((format) => {\n return [format[0], format]\n })\n)\n\n/**\n * A map of locale’s am/pm.\n */\nexport const dayPeriodMap: Map<string, { am?: string; pm?: string }> = new Map()\n\n/**\n * An array of all available date styles.\n */\nexport const styles: ReadonlyArray<FormatStyle> = [\n \"full\",\n \"long\",\n \"medium\",\n \"short\",\n]\n\n/**\n * Creates a leading zero string of 2 digits.\n * @param n - A number.\n */\nexport const two = (n: number) => String(n).padStart(2, \"0\")\n/**\n * Creates a leading zero string of 4 digits.\n * @param n - A number.\n */\nexport const four = (n: number) => String(n).padStart(2, \"0\")\n\n/**\n * Normalizes a given part to NFKC.\n * @param part - The part to normalize.\n */\nexport function normStr(\n part: Intl.DateTimeFormatPart\n): Intl.DateTimeFormatPart {\n if (part.type === \"literal\") {\n part.value = part.value.normalize(\"NFKC\")\n }\n return part\n}\n\n/**\n * Returns the parts filled with pertinent values.\n * @param inputDate - The date to fill parts for\n * @param parts - An array of parts to fill\n * @param locale - The locale to fill with.\n * @param genitive - Whether to use genitive tokens values or not.\n * @param offset - The explicit offset to fill with (ignores the date’s true offset).\n */\nexport function fill(\n inputDate: DateInput,\n parts: Part[],\n locale: string,\n genitive = false,\n offset: string | null = null\n): FilledPart[] {\n const partMap = createPartMap(inputDate, parts, locale, genitive)\n const d = date(inputDate)\n\n /**\n * Not all values get returned \"properly\" as our tokens would suggest. For\n * example, at times Intl returns leading zeros when it shouldn't. This fn\n * is used to clean up those irregular values.\n * @param param - Part\n */\n function value({ partName, partValue, token }: Part) {\n if (partName === \"literal\") return partValue\n const value = partMap[partName]\n if (partName === \"hour\" && token === \"H\") {\n return value.replace(/^0/, \"\") || \"0\"\n }\n if ([\"mm\", \"ss\", \"MM\"].includes(token) && value.length === 1) {\n // Some tokens are supposed to have leading zeros, but Intl doesn't\n // always return them, depending on the locale and the format.\n return `0${value}`\n }\n if (partName === \"dayPeriod\") {\n const p = ap(d.getUTCHours() < 12 ? \"am\" : \"pm\", locale)\n return token === \"A\" ? p.toUpperCase() : p.toLowerCase()\n }\n if (partName === \"timeZoneName\") {\n return offset ?? minsToOffset(-1 * d.getTimezoneOffset(), token)\n }\n return value\n }\n\n return parts.map((part): FilledPart => {\n return {\n ...part,\n value: value(part),\n }\n })\n}\n\n/**\n * Creates a map of part names to their respective values.\n * @param inputDate - The date to format\n * @param parts - The individual parts the need to be formatted.\n * @param locale - The locale to format the parts with.\n * @param genitive - Whether to use genitive tokens values or not.\n */\nfunction createPartMap(\n inputDate: DateInput,\n parts: Part[],\n locale: string,\n genitive = false\n): Record<keyof Intl.DateTimeFormatPartTypesRegistry, string> {\n const d = date(inputDate)\n const hour12 = parts.filter((part) => part.hour12)\n const hour24 = parts.filter((part) => !part.hour12)\n const valueParts: Intl.DateTimeFormatPart[] = []\n const genitiveParts: Part[] = []\n\n function addValues(requestedParts: Part[], hour12 = false) {\n const preciseLocale = `${locale}-u-hc-${hour12 ? \"h12\" : \"h23\"}`\n valueParts.push(\n ...new Intl.DateTimeFormat(\n preciseLocale,\n requestedParts.reduce(\n (options, part) => {\n if (part.partName === \"literal\") return options\n // Side effect! Genitive parts get shoved into a separate array.\n if (genitive && genitiveTokens.includes(part.token)) {\n genitiveParts.push(part)\n }\n return Object.assign(options, part.option)\n },\n { timeZone: \"UTC\" } as Intl.DateTimeFormatOptions\n )\n )\n .formatToParts(d)\n .map(normStr)\n )\n if (genitive && genitiveParts.length) {\n for (const part of genitiveParts) {\n let formattedParts: Intl.DateTimeFormatPart[] = []\n switch (part.token) {\n case \"MMMM\":\n formattedParts = new Intl.DateTimeFormat(preciseLocale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n })\n .formatToParts(d)\n .map(normStr)\n break\n case \"MMM\":\n formattedParts = new Intl.DateTimeFormat(preciseLocale, {\n dateStyle: \"medium\",\n timeZone: \"UTC\",\n })\n .formatToParts(d)\n .map(normStr)\n break\n }\n const genitiveFormattedPart = formattedParts.find(\n (p) => p.type === part.partName\n )\n const index = valueParts.findIndex((p) => p.type === part.partName)\n if (genitiveFormattedPart && index > -1) {\n valueParts[index] = genitiveFormattedPart\n }\n }\n }\n }\n\n if (hour12.length) addValues(hour12, true)\n if (hour24.length) addValues(hour24)\n\n return valueParts.reduce((map, part) => {\n map[part.type] = part.value\n return map\n }, {} as Record<keyof Intl.DateTimeFormatPartTypesRegistry, string>)\n}\n\n/**\n * Converts minutes (300) to an ISO8601 compatible offset (+0400 or +04:00).\n * @param timeDiffInMins - The difference in minutes between two timezones.\n * @returns\n */\nexport function minsToOffset(\n timeDiffInMins: number,\n token: string = \"Z\"\n): string {\n const hours = String(Math.floor(Math.abs(timeDiffInMins / 60))).padStart(\n 2,\n \"0\"\n )\n const mins = String(Math.abs(timeDiffInMins % 60)).padStart(2, \"0\")\n const sign = timeDiffInMins < 0 ? \"-\" : \"+\"\n\n if (token === \"ZZ\") {\n return `${sign}${hours}${mins}`\n }\n\n return `${sign}${hours}:${mins}`\n}\n\n/**\n * Converts an offset (-0500) to minutes (-300).\n * @param offset - The offset to convert to minutes.\n * @param token - The timezone token format.\n */\nexport function offsetToMins(offset: string, token: TimezoneToken): number {\n validOffset(offset, token)\n const [_, sign, hours, mins] = offset.match(\n /([+-])([0-3][0-9]):?([0-6][0-9])/\n )!\n const offsetInMins = Number(hours) * 60 + Number(mins)\n return sign === \"+\" ? offsetInMins : -offsetInMins\n}\n\n/**\n * Validates that an offset is valid according to the format:\n * [+-]HHmm or [+-]HH:mm\n * @param offset - The offset to validate.\n * @param token - The timezone token format.\n */\nexport function validOffset(offset: string, token: TimezoneToken = \"Z\") {\n const valid = ((token: TimezoneToken): boolean => {\n switch (token) {\n case \"Z\":\n return /^([+-])[0-3][0-9]:[0-6][0-9]$/.test(offset)\n case \"ZZ\":\n return /^([+-])[0-3][0-9][0-6][0-9]$/.test(offset)\n }\n })(token)\n\n if (!valid) throw new Error(`Invalid offset: ${offset}`)\n return offset\n}\n\n/**\n * Given a string of tokens, escape any characters that are tokens.\n * @param str - The string to escape tokens in.\n * @returns The escaped string.\n */\nexport function escapeTokens(str: string): string {\n return clockAgnostic\n .concat(clock24)\n .concat(clock12)\n .sort((a, b) => (a[0].length > b[0].length ? 1 : -1))\n .reduce((target, part) => {\n return target.replace(part[0], `\\\\${part[0]}`)\n }, str)\n}\n\n/**\n * Checks if a given part should have a numeric value.\n * @param part - A part to check\n */\nexport function isNumeric(part: Part) {\n return [\"numeric\", \"2-digit\"].includes(part.partValue)\n}\n\n/**\n * Validates that an array of Parts can be parsed.\n * @param parts - Parts to validate for parsing ability.\n */\nexport function validate(parts: Part[]): Part[] | never {\n let lastPart: Part | undefined = undefined\n for (const part of parts) {\n if (part.partName === \"literal\" && !isNaN(parseFloat(part.partValue))) {\n throw new Error(`Numbers in format (${part.partValue}).`)\n }\n if (\n lastPart &&\n lastPart.partName !== \"literal\" &&\n part.partName !== \"literal\"\n ) {\n if (\n !(lastPart.token in fixedLength) &&\n !(part.token in fixedLength) &&\n !(isNumeric(lastPart) && part.token.toLowerCase() === \"a\")\n ) {\n throw new Error(\n `Illegal adjacent tokens (${lastPart.token}, ${part.token})`\n )\n }\n }\n lastPart = part\n }\n return parts\n}\n\n/**\n * Returns the timezone token format from a given format.\n * @param format - The format to check.\n * @returns The timezone token format (\"Z\" or \"ZZ\").\n */\nexport function getOffsetFormat(format: Format): TimezoneToken {\n if (typeof format === \"string\") {\n return format.includes(\"ZZ\") ? \"ZZ\" : \"Z\"\n }\n return \"time\" in format && format.time === \"full\" ? \"Z\" : \"ZZ\"\n}\n","import { dayPeriodMap, specDate, normStr } from \"./common\"\n\n/**\n * Determines the correct value for am/pm by locale and memoizes it.\n * @param ampm - am or pm\n * @param locale - The locale to fetch.\n */\nexport function ap(ampm: \"am\" | \"pm\", locale: string): string {\n const l = dayPeriodMap.get(locale)\n if (l && l[ampm]) return l[ampm] as string\n const specimen = new Date(specDate)\n specimen.setUTCHours(ampm === \"am\" ? 5 : 20)\n const subparts = new Intl.DateTimeFormat(locale, {\n timeStyle: \"full\",\n timeZone: \"UTC\",\n hour12: true,\n })\n .formatToParts(specimen)\n .map(normStr)\n const period = subparts.find((part) => part.type === \"dayPeriod\")\n if (period) {\n const localePeriods: { am?: string; pm?: string } = l || {}\n dayPeriodMap.set(\n locale,\n Object.assign(localePeriods, { [ampm]: period.value })\n )\n return period.value\n }\n return ampm\n}\n","import { date } from \"./date\"\nimport { TimezoneToken, fixedLengthByOffset, offsetToMins } from \"./common\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Apply a given offset to a date, returning a new date with the offset\n * applied by adding or subtracting the given number of minutes.\n * @param dateInput - The date to apply the offset to.\n * @param offset - The offset to apply in the +-HHmm or +-HH:mm format.\n */\nexport function applyOffset(dateInput: DateInput, offset = \"+00:00\"): Date {\n const d = date(dateInput)\n const token = ((): TimezoneToken => {\n switch (fixedLengthByOffset(offset)) {\n case 5:\n return \"ZZ\"\n case 6:\n return \"Z\"\n }\n })()\n const timeDiffInMins = offsetToMins(offset, token)\n return new Date(d.getTime() + timeDiffInMins * 1000 * 60)\n}\n","/**\n * Get the timezone of the device.\n *\n * * Note: If the environment variable TZ is not set, it will return undefined.\n */\nexport function deviceTZ(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone as string | undefined\n}\n","import { date } from \"./date\"\nimport { normStr, minsToOffset, TimezoneToken } from \"./common\"\nimport { deviceTZ } from \"./deviceTZ\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Converts a date object from one timezone to that same time in UTC. This is\n * only for internal use.\n * @param d - A Date object\n * @param timeZone - A timezone string\n */\nfunction relativeTime(d: Date, timeZone: string): Date {\n const utcParts = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n timeZone,\n hourCycle: \"h23\",\n })\n .formatToParts(d)\n .map(normStr)\n const parts: {\n year?: string\n month?: string\n day?: string\n hour?: string\n minute?: string\n second?: string\n } = {}\n utcParts.forEach((part) => {\n parts[part.type as keyof typeof parts] = part.value\n })\n return new Date(\n `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}Z`\n )\n}\n\n/**\n * Returns the offset between two timezones on a given date. The results are\n * ISO8601 compatible offsets like -0800 or +0530.\n *\n * @param dateInput - The date on which to determine the offset.\n * @param tzA - (default: UTC) The second timezone to compare determine the offset between.\n * @param tzB - (default: device) The first timezone to compare determine the offset between.\n */\nexport function offset(\n utcTime: DateInput,\n tzA = \"UTC\",\n tzB = \"device\",\n timeZoneToken: TimezoneToken = \"Z\" ,\n): string {\n tzB = tzB === \"device\" ? deviceTZ() ?? \"utc\" : tzB\n const d = date(utcTime)\n const timeA = relativeTime(d, tzA)\n const timeB = relativeTime(d, tzB)\n const timeDiffInMins = (timeB.getTime() - timeA.getTime()) / 1000 / 60\n return minsToOffset(timeDiffInMins, timeZoneToken)\n}\n","import { offset } from \"./offset\"\nimport { applyOffset } from \"./applyOffset\"\nimport { date } from \"./date\"\nimport { DateInput } from \"./types\"\n\n/**\n * Creates a date object for the input date at the given timezone. For example\n * `tzDate(\"2017-05-06T12:00\", \"Europe/Amsterdam\")` will return a date object\n * for 2017-05-06T10:00:00Z since 12:00 in Amsterdam is 10:00Z.\n *\n * If given a Date object it will use local time and convert it to the given\n * timezone, thus \"changing\" the date.\n * @param inputDate - An iso8601 date string with no timezone\n * @param tz - A timezone string\n */\nexport function tzDate(inputDate: DateInput, tz: string) {\n const d = date(inputDate)\n return applyOffset(d, offset(d, tz))\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Gets the what day of the year a given date is. For example, August 1st is\n * the 213th day of the year on non- years and 214th on leap years.\n * @param inputDate - The input date.\n */\nexport function dayOfYear(inputDate: DateInput): number {\n const d = date(inputDate)\n return Math.round(\n (new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0).getTime() -\n new Date(d.getFullYear(), 0, 0).getTime()) /\n 86400000\n )\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given day.\n * @param inputDate - A string or Date object\n */\nexport function dayEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setHours(23, 59, 59, 999)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given day.\n * @param inputDate - A string or Date object\n */\nexport function dayStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setHours(0, 0, 0)\n return d\n}\n","import {\n styles,\n normStr,\n tokens,\n memoParts,\n clockAgnostic,\n clock24,\n specDate,\n clock12,\n} from \"./common\"\nimport type {\n ParseOptions,\n Format,\n Part,\n FormatStyle,\n FormatStyleObj,\n FormatPattern,\n NamedFormats,\n NamedFormatOption,\n} from \"./types\"\n/**\n * Given a format string, produce an array of matching \"parts\", each part\n * contains a regular expression and the corresponding\n * Intl.DateTimeFormatPartTypesRegistry key/value.\n * @param format - A format string like MM/DD/YYYY\n * @param locale - The locale to parse for.\n */\nexport function parts(format: Format, locale: string): Part[] {\n if (styles.includes(format as FormatStyle) || typeof format === \"object\") {\n return styleParts(format as FormatStyle | FormatStyleObj, locale)\n }\n let f = format\n let match = 0\n const testPattern = (pattern: FormatPattern) => {\n if (!pattern[2]) pattern[2] = new RegExp(`(.)?(${pattern[0]})`, \"g\")\n if (pattern[2].test(f)) {\n let didAdd = 0\n f = f.replace(pattern[2], (_, prefix, actualMatch) => {\n if (prefix === \"\\\\\") return actualMatch\n return `${typeof prefix === \"string\" ? prefix : \"\"}{!${\n didAdd++ ? match : match++\n }!}`\n })\n return !!didAdd\n }\n return false\n }\n\n function validate(patterns: Part[]): Part[] {\n const parts = patterns.map((part) => part.partName)\n const deduped = new Set(parts)\n if (parts.length > deduped.size) {\n throw new Error(`Cannot reuse format tokens.`)\n }\n return patterns\n }\n\n function createPart(\n hour12: boolean,\n [token, option, exp]: FormatPattern\n ): Part {\n const partName = Object.keys(option)[0] as Intl.DateTimeFormatPartTypes\n const partValue = option[partName] as string\n return {\n option,\n partName,\n partValue,\n token,\n pattern: exp as RegExp,\n hour12,\n }\n }\n\n const found24Patterns = clockAgnostic\n .filter(testPattern)\n .concat(clock24.filter(testPattern))\n .map(createPart.bind(null, false))\n\n // Reset the format before re-checking\n const parts = validate(\n found24Patterns.concat(\n clock12.filter(testPattern).map(createPart.bind(null, true))\n )\n )\n const extractIndex = /^\\{!(\\d+)!\\}$/\n return f\n .split(/(\\{!\\d+!\\})/)\n .map((match: string): Part => {\n const hasIndex = match.match(extractIndex)\n if (hasIndex) {\n return parts[Number(hasIndex[1])]\n }\n return {\n option: { literal: match },\n partName: \"literal\",\n partValue: match,\n token: match,\n pattern: new RegExp(\"\"),\n hour12: false,\n }\n })\n .filter((part) => !(part.partName === \"literal\" && part.partValue === \"\"))\n}\n\n/**\n * Determines the parts in a native date style, like \"full\".\n * @param format - A date style like \"full\" or \"short\"\n * @param locale - The locale string\n */\nfunction styleParts(\n format: FormatStyle | FormatStyleObj,\n locale: string\n): Part[] {\n const options: Intl.DateTimeFormatOptions = {\n timeZone: \"UTC\",\n }\n if (typeof format === \"string\") {\n options.dateStyle = format\n } else {\n if (\"date\" in format) options.dateStyle = format.date\n if (\"time\" in format) options.timeStyle = format.time\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n const segments = formatter.formatToParts(new Date(specDate)).map(normStr)\n const hourTypeSegments = formatter\n .formatToParts(new Date(\"1999-04-05T23:05:01.000Z\"))\n .map(normStr)\n const hourPart = hourTypeSegments.find((segment) => segment.type === \"hour\")\n const hourType = hourPart && hourPart.value === \"23\" ? 24 : 12\n return segments\n .map((part): Part | undefined => {\n const partName = part.type\n const formatPattern = guessPattern(\n part.type,\n part.value,\n locale,\n part.type === \"hour\" ? hourType : undefined,\n options\n )\n if (formatPattern === undefined) return\n const partValue = formatPattern[1][partName]\n if (!partValue) return\n if (!formatPattern[2])\n formatPattern[2] = new RegExp(`${formatPattern[0]}`, \"g\")\n return {\n option: { [partName]: partValue },\n partName,\n partValue,\n token: formatPattern[0],\n pattern: formatPattern[2],\n hour12: hourType === 12,\n }\n })\n .filter((part): part is Part => !!part)\n}\n\n/**\n * Attempts to guess the correct part value type for a given dateStyle. For\n * example a month of 02 would be \"2-digit\".\n *\n * @param partName - The part name to guess for, like 'year' or 'month'\n * @param partValue - The current value, it is assumed this is the smallest denom.\n */\nfunction guessPattern<T extends Intl.DateTimeFormatPartTypes>(\n partName: T,\n partValue: string,\n locale: string,\n hour: T extends \"hour\" ? 12 | 24 : undefined,\n options: Intl.DateTimeFormatOptions\n): FormatPattern | undefined {\n const l = partValue.length\n const n = !isNaN(Number(partValue))\n let style: NamedFormatOption | undefined\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n switch (partName) {\n case \"year\":\n return l === 2 ? tokens.get(\"YY\") : tokens.get(\"YYYY\")\n case \"month\":\n if (n) return l === 1 ? tokens.get(\"M\") : tokens.get(\"MM\")\n style = partStyle(locale, partName, partValue)\n switch (style) {\n case \"long\":\n return tokens.get(\"MMMM\")\n default:\n return tokens.get(\"MMM\")\n }\n case \"day\":\n return l === 1 ? tokens.get(\"D\") : tokens.get(\"DD\")\n case \"weekday\":\n style = partStyle(locale, partName, partValue)\n switch (style) {\n case \"narrow\":\n return tokens.get(\"d\")\n case \"short\":\n return tokens.get(\"ddd\")\n default:\n return tokens.get(\"dddd\")\n }\n case \"hour\":\n // Need to distinguish the locale’s default as 24 or 12 hour.\n if (hour === 12) return l === 1 ? tokens.get(\"h\") : tokens.get(\"hh\")\n return l === 1 ? tokens.get(\"H\") : tokens.get(\"HH\")\n case \"minute\":\n return l === 1 ? tokens.get(\"m\") : tokens.get(\"mm\")\n case \"second\":\n return l === 1 ? tokens.get(\"s\") : tokens.get(\"ss\")\n case \"dayPeriod\":\n return /^[A-Z]+$/u.test(partValue) ? tokens.get(\"A\") : tokens.get(\"a\")\n case \"literal\":\n return [partValue, { literal: partValue }, new RegExp(\"\")]\n case \"timeZoneName\":\n return options.timeStyle === \"full\" ? tokens.get(\"Z\") : tokens.get(\"ZZ\")\n default:\n return undefined\n }\n /* eslint-enable @typescript-eslint/no-non-null-assertion */\n}\n\n/**\n * Determines what \"style\" a given part is in. For example, if you provide:\n * ```js\n * partStyle('en', 'month', 'Jan')\n * // returns \"short\".\n * ```\n * Part styles are always expected to be \"genitive\" — for use in \"dateStyle\".\n * @param locale - Locale string\n * @param part - The part to attempt a lookup on\n * @param value - The value of a given part.\n */\nfunction partStyle(\n locale: string,\n part: keyof NamedFormats,\n value: string\n): NamedFormatOption | undefined {\n if (!memoParts.has(locale)) {\n const date = new Date(specDate)\n const weekdays = [3, 8, 9, 7, 6, 4, 3]\n const parts = [\"weekday\", \"month\", \"dayPeriod\"]\n const partStyles: NamedFormatOption[] = [\"long\", \"short\", \"narrow\"]\n const formats: Partial<NamedFormats> = {}\n for (let i = 0; i < 12; i++) {\n date.setMonth(0 + i)\n if (i in weekdays) date.setDate(weekdays[i])\n date.setUTCHours(8 + i)\n for (const style of partStyles) {\n const segments = new Intl.DateTimeFormat(\n locale,\n parts.reduce(\n (options, part) => Object.assign(options, { [part]: style }),\n { hour12: true, timeZone: \"UTC\" }\n )\n )\n .formatToParts(date)\n .map(normStr)\n if (style === \"long\" || style === \"short\") {\n const genitiveFormattedParts = new Intl.DateTimeFormat(locale, {\n dateStyle: style === \"short\" ? \"medium\" : \"long\",\n timeZone: \"UTC\",\n })\n .formatToParts(date)\n .map(normStr)\n const genitiveMonth = genitiveFormattedParts.find(\n (part) => part.type === \"month\"\n )\n const index = segments.findIndex((part) => part.type === \"month\")\n if (index > -1 && genitiveMonth) segments[index] = genitiveMonth\n }\n segments.forEach((part) => {\n if (part.type === \"literal\") return\n const type = part.type as keyof NamedFormats\n formats[type] = Object.assign(formats[type] || {}, {\n [part.value]: style,\n })\n })\n }\n }\n memoParts.set(locale, formats as NamedFormats)\n }\n const formats = memoParts.get(locale)\n return formats ? formats[part][value] : undefined\n}\n","import { applyOffset } from \"./applyOffset\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Inverts the offset and applies it to the given date, returning a new date.\n * @param dateInput - The date to remove the offset from.\n * @param offset - The offset to remove in the +-HHmm or +-HH:mm format.\n */\nexport function removeOffset(dateInput: DateInput, offset = \"+00:00\"): Date {\n const positive = offset.slice(0, 1) === \"+\"\n return applyOffset(\n dateInput,\n offset.replace(positive ? \"+\" : \"-\", positive ? \"-\" : \"+\")\n )\n}\n","/**\n * Returns the device's locale. This is a simple proxy of the\n * `Intl.DateTimeFormat().resolvedOptions().locale` call.\n */\nexport function deviceLocale() {\n return Intl.DateTimeFormat().resolvedOptions().locale\n}\n","import { date } from \"./date\"\nimport { parts } from \"./parts\"\nimport { fill, getOffsetFormat } from \"./common\"\nimport type { DateInput, Format, FormatOptions, FormatStyle, Part } from \"./types\"\nimport { offset } from \"./offset\"\nimport { removeOffset } from \"./removeOffset\"\nimport { deviceLocale } from \"./deviceLocale\"\nimport { deviceTZ } from \"./deviceTZ\"\n\n/**\n * Produce a formatted string. Available strings:\n * token | description\n * ------|------------\n * YY | 2 digit year\n * YYYY | 4 digit year\n * M | The month 1-12\n * MM | The month 01-12\n * MMM | Short name Jan-Dec\n * MMMM | Full name January | December\n * D | The day of the month 1-31\n * DD | The day of the month 01-31\n * d | Single digit day \"T\"\n * ddd | Short day name Thu\n * dddd | Full day name Wednesday\n * H | Minimum hour digits, 24 hour, 0-23\n * HH | 2 hour digits, 24 hour, 00-23\n * h | Minimum hour digits, 12 hour clock, 1-12\n * hh | 2 hour digits, 12 hour clock, 01-12\n * m | The minute 0-59\n * mm | The minute 00-59\n * s | The second 0-59\n * ss | The second 00-59\n * a | am/pm\n * A | AM/PM\n * Z | +0800, +0530, -1345\n *\n * @param inputDate - A date object or ISO 8601 string\n * @param format - A format\n */\nexport function format(options: FormatOptions): string\nexport function format(\n inputDate: DateInput,\n format?: Format,\n locale?: string,\n genitive?: boolean,\n partFilter?: (part: Part) => boolean\n): string\nexport function format(\n inputDateOrOptions: DateInput | FormatOptions,\n format: Format = \"long\",\n locale: string | undefined = \"device\",\n genitive: boolean | undefined = false,\n partFilter?: (part: Part) => boolean\n): string {\n let tz: string | undefined, forceOffset: string | undefined\n\n if (\n typeof inputDateOrOptions === \"object\" &&\n !(inputDateOrOptions instanceof Date)\n ) {\n // Extract options from the object.\n ;({\n date: inputDateOrOptions,\n format,\n locale,\n genitive,\n partFilter,\n tz,\n } = inputDateOrOptions)\n }\n // ISO 8601 is a special case because it doesn't require a format.\n if (format === \"ISO8601\") return date(inputDateOrOptions).toISOString()\n\n if (tz) {\n forceOffset = offset(inputDateOrOptions, \"utc\", tz, getOffsetFormat(format))\n }\n\n // We need to apply an offset to the date so that it can be formatted as UTC.\n tz ??= deviceTZ()\n if (tz?.toLowerCase() !== \"utc\") {\n inputDateOrOptions = removeOffset(\n inputDateOrOptions,\n offset(inputDateOrOptions, tz, \"utc\")\n )\n }\n\n if (!locale || locale === \"device\") {\n locale = deviceLocale()\n }\n\n return fill(\n inputDateOrOptions,\n parts(format, locale).filter(partFilter ?? (() => true)),\n locale,\n genitive,\n forceOffset\n )\n .map((p) => p.value)\n .join(\"\")\n}\n","import { parts } from \"./parts\"\nimport { escapeTokens } from \"./common\"\nimport type { Format, Part } from \"./types\"\n\n/**\n * Return the string format for a given format. For example:\n * ```js\n * formatStr({ date: 'long' }, 'en') // dddd, MMMM D, YYYY\n * ```\n * @param format - A format string or object.\n * @param locale - A locale or en by default.\n */\nexport function formatStr(\n format: Format,\n locale = \"en\",\n escapeLiterals = false,\n filterParts: (part: Part) => boolean = () => true\n): string {\n return parts(format, locale)\n .filter(filterParts)\n .reduce(\n (f, p) =>\n (f +=\n escapeLiterals && p.partName === \"literal\"\n ? escapeTokens(p.token)\n : p.token),\n \"\"\n )\n .normalize(\"NFKC\")\n}\n","/**\n * Converts a 2 digit year into a 4 digit year. This function assumes years 20\n * years into the future belong to the current century, and the past 80 are in\n * the past.\n *\n * @param value - 2 digits in string format\n */\nexport function fourDigitYear(value: string): number {\n const y = new Date().getFullYear()\n const currentYear = y % 100\n const century = Math.floor(y / 100)\n const parsedYear = Number(value)\n return (century + (parsedYear > currentYear + 20 ? -1 : 0)) * 100 + parsedYear\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given hour.\n * @param inputDate - A string or Date object\n */\nexport function hourEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setMinutes(59, 59, 999)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given hour.\n * @param inputDate - A string or Date object\n */\nexport function hourStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setMinutes(0, 0)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given minute.\n * @param inputDate - A string or Date object\n */\nexport function minuteEnd(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setSeconds(59, 999)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given minute.\n * @param inputDate - A string or Date object\n */\nexport function minuteStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setSeconds(0)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the first day of a month.\n * @param inputDate - A string or Date object\n */\nexport function monthStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n d.setDate(1)\n d.setHours(0, 0, 0)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Get the number of days in the given date’s year.\n * @param inputDate - A string or Date object\n */\nexport function yearDays(inputDate: DateInput): number {\n const d = date(inputDate)\n return (\n (new Date(d.getFullYear() + 1, 0, 0).getTime() -\n new Date(d.getFullYear(), 0, 0).getTime()) /\n 86400000\n )\n}\n","import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport { yearDays } from \"./yearDays\"\nimport { dayOfYear } from \"./dayOfYear\"\nimport { addDay } from \"./addDay\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Performs a bidirectional search for the nearest date that passes a function.\n * @param target - Performs a search for the nearest passing date.\n * @param search - The search function to use, given a date returns a boolean.\n * @param constraint - The number of iterations to perform before giving up, or logical constraint like \"month\", or \"week\".\n *\n */\nexport function nearestDay(\n inputDate: DateInput,\n search: (date: Date) => boolean,\n constraint: number | \"month\" | \"week\" | \"year\" = 7\n): Date | null {\n let increments: number\n let decrements: number\n const d = date(inputDate)\n switch (constraint) {\n case \"month\":\n decrements = d.getDate()\n increments = monthDays(d) - d.getDate()\n break\n case \"week\":\n decrements = d.getDay() + 1\n increments = 6 - d.getDay()\n break\n case \"year\":\n const total = yearDays(d)\n const day = dayOfYear(d)\n decrements = day\n increments = total - day\n break\n default:\n increments = decrements = constraint\n }\n\n for (let i = 0; i <= increments || i < decrements; i++) {\n if (i <= increments) {\n const next = addDay(d, i)\n if (search(next)) return next\n }\n if (i && i <= decrements) {\n const prev = addDay(d, -i)\n if (search(prev)) return prev\n }\n }\n return null\n}\n","import { format } from \"./format\"\nimport { ap } from \"./ap\"\nimport type { FormatToken } from \"./types\"\n/**\n * Returns an array of options for a given token in a given locale.\n * @param token - Get the full range of options for a given token\n * @param locale - The locale to fetch the options for.\n */\nexport function range(\n token: FormatToken,\n locale = \"en\",\n genitive = false\n): string[] {\n const r: (n: number, c: (index: number) => string | number) => string[] = (\n n,\n c\n ) =>\n Array(n)\n .fill(\"\")\n .map((_, i) => `${c(i)}`)\n\n if (token === \"M\") return r(12, (i) => i + 1)\n if (token === \"MM\")\n return r(12, (i) => {\n const m = i + 1\n return m < 10 ? `0${m}` : m\n })\n // MMM and MMMM\n if (token.startsWith(\"M\"))\n return range(\"MM\").map((m) =>\n format(`2000-${m}-05`, token, locale, genitive)\n )\n if (token.startsWith(\"d\"))\n return r(7, (i) => `0${i + 2}`).map((d) =>\n format(`2022-10-${d}`, token, locale)\n )\n if (token === \"a\")\n return [ap(\"am\", locale).toLowerCase(), ap(\"pm\", locale).toLowerCase()]\n if (token === \"A\")\n return [ap(\"am\", locale).toUpperCase(), ap(\"pm\", locale).toUpperCase()]\n if (token.startsWith(\"Y\")) {\n const year = new Date().getFullYear()\n return r(120, (i) => i + 1).reduce(\n (ranges, i) => {\n if (i !== \"120\")\n ranges.push(format(`${year + Number(i)}-06-06`, token, locale))\n ranges.unshift(format(`${year - Number(i)}-06-06`, token, locale))\n return ranges\n },\n [format(`${year}-06-06`, token, locale)]\n )\n }\n if (token.startsWith(\"D\"))\n return r(31, (i) => `${token === \"DD\" && i < 9 ? \"0\" : \"\"}${i + 1}`)\n if (token.startsWith(\"H\"))\n return r(24, (i) => `${token === \"HH\" && i < 10 ? \"0\" : \"\"}${i}`)\n if (token.startsWith(\"h\"))\n return r(12, (i) => `${token === \"hh\" && i < 9 ? \"0\" : \"\"}${i + 1}`)\n if (token.startsWith(\"m\") || token.startsWith(\"s\"))\n return r(60, (i) => `${token.length > 1 && i < 10 ? \"0\" : \"\"}${i}`)\n return []\n}\n","import { date } from \"./date\"\nimport { validate, styles, fixedLength, four, two, validOffset, fixedLengthByOffset } from \"./common\"\nimport { formatStr } from \"./formatStr\"\nimport { fourDigitYear } from \"./fourDigitYear\"\nimport { ap } from \"./ap\"\nimport { range } from \"./range\"\nimport { monthDays } from \"./monthDays\"\nimport { parts } from \"./parts\"\nimport type {\n ParseOptions,\n Format,\n Part,\n FormatStyle,\n FilledPart,\n FormatToken,\n} from \"./types\"\n\nexport function parse(options: ParseOptions): Date | never\nexport function parse(\n dateStr: string,\n format?: Format,\n locale?: string\n): Date | never\n/**\n * Parses a date string into a Date object using the given format.\n * @param dateStr - A string representing a date.\n * @param format - The format the given string is in.\n * @param locale - The locale to parse the string from.\n */\nexport function parse(\n dateStrOrOptions: string | ParseOptions,\n format: Format = \"ISO8601\",\n locale = \"device\"\n): Date | never {\n let partFilter: (part: Part) => boolean = () => true\n let dateStr: string\n let dateOverflow = \"backward\"\n if (typeof dateStrOrOptions === \"object\") {\n ;({\n date: dateStr,\n format = \"ISO8601\",\n locale = \"device\",\n dateOverflow = \"backward\",\n partFilter = () => true,\n } = dateStrOrOptions)\n } else {\n dateStr = dateStrOrOptions\n }\n if (!dateStr) throw new Error(\"parse() requires a date string.\")\n const invalid = (): never => {\n throw new Error(\n `Date (${dateStr}) does not match format (${formatStr(format, locale)})`\n )\n }\n if (format === \"ISO8601\") return date(dateStr)\n const genitive =\n styles.includes(format as FormatStyle) || typeof format === \"object\"\n const formatParts = validate(parts(format, locale).filter(partFilter))\n if (!formatParts.length) throw new Error(\"parse() requires a pattern.\")\n let parsedParts\n try {\n parsedParts = parseParts(dateStr, formatParts)\n } catch {\n return invalid()\n }\n const now = new Date()\n const parsed = new Map([\n [\"YYYY\", now.getFullYear()],\n [\"MM\", now.getMonth() + 1],\n [\"DD\", now.getDate()],\n [\"HH\", 0],\n [\"mm\", 0],\n [\"ss\", 0],\n ])\n let a: null | boolean = null\n let offset = \"\"\n parsedParts.forEach((part): void | never => {\n if (part.partName === \"literal\") return\n if (part.token === part.value) return invalid()\n const v = Number(part.value)\n if (parsed.has(part.token)) {\n // Parse for YYYY, MM, DD, HH, hh, mm, ss, Z\n parsed.set(part.token, v)\n } else if (part.token === \"YY\") {\n // Parse for YY\n parsed.set(\"YYYY\", fourDigitYear(part.value))\n } else {\n /* MMM - Short name Jan-Dec\n * MMMM - Full name January - December\n * h - Minimum hour digits, 12 hour clock, 1-12\n * hh - 2 hour digits, 12 hour clock, 01-12\n * m - The minute 0-59\n * mm - The minute 00-12\n * s - The second 0-59\n * a - am/pm\n * A - AM/PM\n */\n const t = part.token\n if (t.startsWith(\"d\")) {\n // d, ddd, dddd — we just ignore these because they are non specific\n return\n } else if (t === \"D\") {\n parsed.set(\"DD\", v)\n } else if (t === \"H\" || t.startsWith(\"h\")) {\n parsed.set(\"HH\", v)\n } else if (t === \"M\") {\n parsed.set(\"MM\", v)\n } else if (t === \"a\" || t === \"A\") {\n a = part.value.toLowerCase() === ap(\"am\", locale).toLowerCase()\n } else if (t === \"Z\" || t === \"ZZ\") {\n offset = validOffset(part.value, t)\n } else {\n const values = range(t as FormatToken, locale, genitive)\n const index = values.indexOf(part.value)\n if (index !== -1) {\n switch (t) {\n case \"MMM\":\n case \"MMMM\":\n parsed.set(\"MM\", index + 1)\n break\n }\n }\n }\n }\n })\n let hours = parsed.get(\"HH\") || 0\n if (a === false) {\n hours += hours === 12 ? 0 : 12\n parsed.set(\"HH\", hours === 24 ? 0 : hours)\n } else if (a === true && hours === 12) {\n // 12am === 00 in 24 hour clock.\n parsed.set(\"HH\", 0)\n }\n parsed.set(\"MM\", (parsed.get(\"MM\") || 1) - 1)\n // eslint-disable-next-line prefer-const\n let [Y, M, D, h, m, s] = Array.from(parsed.values())\n\n // Determine if the date is valid for the month.\n const maxDaysInMonth = monthDays(new Date(`${four(Y)}-${two(M + 1)}-10`))\n if (maxDaysInMonth < D && dateOverflow === \"throw\")\n throw new Error(`Invalid date ${four(Y)}-${two(M + 1)}-${two(D)}`)\n D = dateOverflow === \"backward\" ? Math.min(D, maxDaysInMonth) : D\n\n // Create the date.\n const isoString = `${four(Y)}-${two(M + 1)}-${two(D)}T${two(h)}:${two(\n m\n )}:${two(s)}${offset}`\n const d = new Date(isoString)\n if (isFinite(+d)) return d\n return invalid()\n}\n\n/**\n * Given a string date and corresponding format parts, fill the parts with the\n * data from the string.\n * @param dateStr - A string to parse.\n * @param formatParts - The expected parts of the given string.\n */\nexport function parseParts(dateStr: string, formatParts: Part[]): FilledPart[] {\n let i = 0\n const advance = (parts: Part[]): [Part, Part | undefined] => [\n parts[i++],\n parts[i],\n ]\n let pos = 0\n const parsed: FilledPart[] = []\n let n: undefined | Part = undefined\n do {\n const [current, next] = advance(formatParts)\n n = next\n let len = 1\n if (current.partName === \"literal\") {\n // Literals can be discarded\n len = current.partValue.length\n } else if (current.partName === \"timeZoneName\") {\n len = fixedLengthByOffset(dateStr.substring(pos))\n } else if (current.token in fixedLength) {\n // Fixed length parse\n len = fixedLength[current.token as keyof typeof fixedLength]\n } else if (next) {\n // Variable length parse.\n if (next.partName === \"literal\") {\n len = dateStr.indexOf(next.partValue, pos) - pos\n if (len < 0) throw new Error()\n } else if (next.partName === \"dayPeriod\") {\n // Our validator is ensuring that the current item must be a variable\n // length number. We need to extract it.\n for (let i = 1; i <= 4; i++) {\n if (isNaN(Number(dateStr.charAt(pos + i)))) {\n len = i\n break\n }\n }\n } else {\n // Our validator guarantees the next is either not a number or it\n // will be the end of the string\n const nextChar = dateStr.substring(pos).search(/\\d/)\n if (nextChar !== -1) len = pos + nextChar\n }\n } else {\n len = dateStr.length\n }\n\n parsed.push({ ...current, value: dateStr.substring(pos, pos + len) })\n pos += len\n } while (n)\n return parsed\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same date. Ignores time.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameDay(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return (\n a.getDate() === b.getDate() &&\n a.getMonth() === b.getMonth() &&\n a.getFullYear() === b.getFullYear()\n )\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time seconds. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameSecond(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getSeconds() === b.getSeconds()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time minutes. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameMinute(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getMinutes() === b.getMinutes()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time hour. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameHour(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getHours() === b.getHours()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same year.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameYear(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getFullYear() === b.getFullYear()\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given week. Defaults to Sunday as the\n * first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param inputDate - A string or Date object\n * @param startOfWeekDay - Determines which day of the week is the first\n */\nexport function weekStart(inputDate: DateInput, startOfWeekDay = 0): Date {\n const d = date(inputDate)\n let diff = startOfWeekDay - d.getDay()\n if (diff > 0) diff = diff - 7\n d.setDate(d.getDate() + diff)\n d.setHours(0, 0, 0)\n return d\n}\n","import { weekStart } from \"./weekStart\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the last day at the last second of the given week.\n * Defaults to Sunday as the first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param inputDate - Gets the last day of the week\n * @param startOfWeekDay - The first day of the week\n */\nexport function weekEnd(inputDate: DateInput, startOfWeekDay = 0): Date {\n const d = weekStart(inputDate, startOfWeekDay)\n d.setDate(d.getDate() + 6)\n d.setHours(23, 59, 59)\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the start of the current year.\n * @param inputDate - A string or Date object\n */\nexport function yearStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n\n d.setMonth(0)\n d.setDate(1)\n d.setHours(0, 0, 0)\n\n return d\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the end of the current year.\n * @param inputDate - A string or Date object\n */\nexport function yearEnd(inputDate: DateInput): Date {\n const d = date(inputDate);\n\n d.setMonth(11);\n d.setDate(31);\n d.setHours(23, 59, 59, 999);\n\n return d;\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Is the first date before the second one?\n *\n * @param inputDate - 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 */\nexport function isBefore(inputDate: DateInput, dateToCompare: DateInput) {\n const _date = date(inputDate)\n const _dateToCompare = date(dateToCompare)\n\n return +_date < +_dateToCompare\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\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 inputDate - 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 */\nexport function isAfter(inputDate: DateInput, dateToCompare: DateInput) {\n const _date = date(inputDate)\n const _dateToCompare = date(dateToCompare)\n\n return +_date > +_dateToCompare\n}\n","import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Are the given dates equal?\n *\n * @param dateLeft - The first date to compare\n * @param dateRight - The second date to compare\n *\n * @returns The dates are equal.\n */\nexport function isEqual(dateLeft: DateInput, dateRight: DateInput) {\n const _dateLeft = date(dateLeft)\n const _dateRight = date(dateRight)\n\n return +_dateLeft === +_dateRight\n}\n","import { date } from \"./date\"\nimport { DateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in milliseconds.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date\n */\nexport function diffMilliseconds(dateA: DateInput, dateB: DateInput) {\n const left = date(dateA)\n const right = date(dateB)\n return +left - +right\n}\n","export type DiffRoundingMethod = \"trunc\" | \"round\" | \"floor\" | \"ceil\"\n\n/**\n * Return a rounded value with the given rounding method\n * @param value the value to round\n * @param method the rounding method\n */\nexport function diffRound(value: number, method: DiffRoundingMethod = \"trunc\") {\n const r = Math[method](value)\n return r == 0 ? 0 : r\n}\n","import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DiffRoundingMethod, diffRound } from \"./diffRound\"\nimport { DateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in seconds.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date\n * @param roundingMethod the rounding method to use, default: trunc\n */\nexport function diffSeconds(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n) {\n return diffRound(diffMilliseconds(dateA, dateB) / 1000, roundingMethod)\n}\n","import { DateInput } from \"./types\"\nimport { diffMilliseconds } from \"./diffMilliseconds\"\nimport { diffRound, type DiffRoundingMethod } from \"./diffRound\"\n\n/**\n * Returns the difference between 2 dates in minutes.\n * @param dateA A date to compare with the right date\n * @param roundingMethod the rounding method to use, default: trunc\n */\nexport function diffMinutes(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n) {\n return diffRound(diffMilliseconds(dateA, dateB) / 60_000, roundingMethod)\n}\n","import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { diffRound, type DiffRoundingMethod } from \"./diffRound\"\nimport { DateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in hours.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date\n * @param roundingMethod the rounding method to use, default: trunc\n */\nexport function diffHours(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n) {\n return diffRound(\n diffMilliseconds(dateA, dateB) / 3_600_000, // 1000 * 60 * 60\n roundingMethod\n )\n}\n","import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DateInput } from \"./types\"\nimport { diffRound, type DiffRoundingMethod } from \"./diffRound\"\n\n/**\n * Returns the difference between 2 dates in days.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date\n * @param roundingMethod the rounding method to use, default: trunc\n */\nexport function diffDays(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n) {\n return diffRound(\n diffMilliseconds(dateA, dateB) / 86_400_000, // hour * 24\n roundingMethod\n )\n}\n","import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DateInput } from \"./types\"\nimport { diffRound, type DiffRoundingMethod } from \"./diffRound\"\n\n/**\n * Returns the difference between 2 dates in days.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date\n * @param roundingMethod the rounding method to use, default: trunc\n */\nexport function diffWeeks(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n) {\n return diffRound(\n diffMilliseconds(dateA, dateB) / 604800000, // day * 7\n roundingMethod\n )\n}\n","import { date } from \"./date\"\nimport { DateInput } from \"./types\"\nimport { monthDays } from \"./monthDays\"\n\n/**\n * Returns the difference between 2 dates in months.\n * @param dateA A date to compare with the dateB date\n * @param dateB A date to compare with the dateA date\n */\nexport function diffMonths(dateA: DateInput, dateB: DateInput): number {\n const l = date(dateA)\n const r = date(dateB)\n // if the dateB one is bigger, we switch them around as it's easier to do\n if (l < r) {\n const rs = diffMonths(r, l)\n return rs == 0 ? 0 : -rs\n }\n\n // we first get the amount of calendar months\n let months =\n (l.getFullYear() - r.getFullYear()) * 12 + (l.getMonth() - r.getMonth())\n\n const ld = l.getDate()\n const rd = r.getDate()\n\n // if no full month has passed we may subtract a month from the calendar months so we get the amount of full months\n if (ld < rd) {\n // in case dateA date is the last day of the month & the dateB date is higher, we don't subtract as a full month did actually pass\n const lm = monthDays(l)\n if (!(lm == ld && lm < rd)) {\n months--\n }\n }\n //ensures we don't give back -0\n return months == 0 ? 0 : months\n}\n","import { diffMonths } from \"./diffMonths\"\nimport { DateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in years.\n * @param dateA A date to compare with the dateB date\n * @param dateB A date to compare with the dateA date\n */\nexport function diffYears(dateA: DateInput, dateB: DateInput): number {\n const r = Math.trunc(diffMonths(dateA, dateB) / 12)\n //ensures we don't give back -0\n return r == 0 ? 0 : r\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,eACX;AAMK,SAAS,QAAQA,OAAuB;AAC7C,QAAM,UAAUA,MAAK,MAAM,YAAY;AACvC,MAA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,OACA,gBACA;AACA,SAAO;AAAA,IACL,iBAAiB,OAAO,KAAK,IAAI;AAAA;AAAA,IACjC;AAAA,EACF;AACF;;;ACTO,SAAS,UACd,OACA,OACA,gBACA;AACA,SAAO;AAAA,IACL,iBAAiB,OAAO,KAAK,IAAI;AAAA;AAAA,IACjC;AAAA,EACF;AACF;;;ACVO,SAAS,WAAW,OAAkB,OAA0B;AACrE,QAAM,IAAI,KAAK,KAAK;AACpB,QAAM,IAAI,KAAK,KAAK;AAEpB,MAAI,IAAI,GAAG;AACT,UAAM,KAAK,WAAW,GAAG,CAAC;AAC1B,WAAO,MAAM,IAAI,IAAI,CAAC;AAAA,EACxB;AAGA,MAAI,UACD,EAAE,YAAY,IAAI,EAAE,YAAY,KAAK,MAAM,EAAE,SAAS,IAAI,EAAE,SAAS;AAExE,QAAM,KAAK,EAAE,QAAQ;AACrB,QAAM,KAAK,EAAE,QAAQ;AAGrB,MAAI,KAAK,IAAI;AAEX,UAAM,KAAK,UAAU,CAAC;AACtB,QAAI,EAAE,MAAM,MAAM,KAAK,KAAK;AAC1B;AAAA,IACF;AAAA,EACF;AAEA,SAAO,UAAU,IAAI,IAAI;AAC3B;;;AC3BO,SAAS,UAAU,OAAkB,OAA0B;AACpE,QAAM,IAAI,KAAK,MAAM,WAAW,OAAO,KAAK,IAAI,EAAE;AAElD,SAAO,KAAK,IAAI,IAAI;AACtB;","names":["date","date","format","parts","offset","value","hour12","token","offset","parts","format","validate","parts","match","date","formats","part","offset","format","format","format","offset","parts","i"]}
package/dist/index.d.cts CHANGED
@@ -195,7 +195,7 @@ declare function ap(ampm: "am" | "pm", locale: string): string;
195
195
  * Apply a given offset to a date, returning a new date with the offset
196
196
  * applied by adding or subtracting the given number of minutes.
197
197
  * @param dateInput - The date to apply the offset to.
198
- * @param offset - The offset to apply in the +-HHmm format.
198
+ * @param offset - The offset to apply in the +-HHmm or +-HH:mm format.
199
199
  */
200
200
  declare function applyOffset(dateInput: DateInput, offset?: string): Date;
201
201
 
@@ -346,6 +346,15 @@ declare function monthStart(inputDate: DateInput): Date;
346
346
  */
347
347
  declare function nearestDay(inputDate: DateInput, search: (date: Date) => boolean, constraint?: number | "month" | "week" | "year"): Date | null;
348
348
 
349
+ /**
350
+ * Timezone tokens.
351
+ */
352
+ declare const timeZoneTokens: readonly ["Z", "ZZ"];
353
+ /**
354
+ * Timezone token type.
355
+ */
356
+ type TimezoneToken = (typeof timeZoneTokens)[number];
357
+
349
358
  /**
350
359
  * Returns the offset between two timezones on a given date. The results are
351
360
  * ISO8601 compatible offsets like -0800 or +0530.
@@ -354,7 +363,7 @@ declare function nearestDay(inputDate: DateInput, search: (date: Date) => boolea
354
363
  * @param tzA - (default: UTC) The second timezone to compare determine the offset between.
355
364
  * @param tzB - (default: device) The first timezone to compare determine the offset between.
356
365
  */
357
- declare function offset(utcTime: DateInput, tzA?: string, tzB?: string): string;
366
+ declare function offset(utcTime: DateInput, tzA?: string, tzB?: string, timeZoneToken?: TimezoneToken): string;
358
367
 
359
368
  declare function parse(options: ParseOptions): Date | never;
360
369
  declare function parse(dateStr: string, format?: Format, locale?: string): Date | never;
@@ -385,7 +394,7 @@ declare function range(token: FormatToken, locale?: string, genitive?: boolean):
385
394
  /**
386
395
  * Inverts the offset and applies it to the given date, returning a new date.
387
396
  * @param dateInput - The date to remove the offset from.
388
- * @param offset - The offset to remove in the +-HHmm format.
397
+ * @param offset - The offset to remove in the +-HHmm or +-HH:mm format.
389
398
  */
390
399
  declare function removeOffset(dateInput: DateInput, offset?: string): Date;
391
400
 
@@ -495,4 +504,66 @@ declare function isAfter(inputDate: DateInput, dateToCompare: DateInput): boolea
495
504
  */
496
505
  declare function isEqual(dateLeft: DateInput, dateRight: DateInput): boolean;
497
506
 
498
- export { type DateInput, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, addDay, addHour, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMinute, sameSecond, sameYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };
507
+ /**
508
+ * Returns the difference between 2 dates in milliseconds.
509
+ * @param dateA A date to compare with the right date
510
+ * @param dateB A date to compare with the left date
511
+ */
512
+ declare function diffMilliseconds(dateA: DateInput, dateB: DateInput): number;
513
+
514
+ type DiffRoundingMethod = "trunc" | "round" | "floor" | "ceil";
515
+
516
+ /**
517
+ * Returns the difference between 2 dates in seconds.
518
+ * @param dateA A date to compare with the right date
519
+ * @param dateB A date to compare with the left date
520
+ * @param roundingMethod the rounding method to use, default: trunc
521
+ */
522
+ declare function diffSeconds(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
523
+
524
+ /**
525
+ * Returns the difference between 2 dates in minutes.
526
+ * @param dateA A date to compare with the right date
527
+ * @param roundingMethod the rounding method to use, default: trunc
528
+ */
529
+ declare function diffMinutes(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
530
+
531
+ /**
532
+ * Returns the difference between 2 dates in hours.
533
+ * @param dateA A date to compare with the right date
534
+ * @param dateB A date to compare with the left date
535
+ * @param roundingMethod the rounding method to use, default: trunc
536
+ */
537
+ declare function diffHours(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
538
+
539
+ /**
540
+ * Returns the difference between 2 dates in days.
541
+ * @param dateA A date to compare with the right date
542
+ * @param dateB A date to compare with the left date
543
+ * @param roundingMethod the rounding method to use, default: trunc
544
+ */
545
+ declare function diffDays(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
546
+
547
+ /**
548
+ * Returns the difference between 2 dates in days.
549
+ * @param dateA A date to compare with the right date
550
+ * @param dateB A date to compare with the left date
551
+ * @param roundingMethod the rounding method to use, default: trunc
552
+ */
553
+ declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
554
+
555
+ /**
556
+ * Returns the difference between 2 dates in months.
557
+ * @param dateA A date to compare with the dateB date
558
+ * @param dateB A date to compare with the dateA date
559
+ */
560
+ declare function diffMonths(dateA: DateInput, dateB: DateInput): number;
561
+
562
+ /**
563
+ * Returns the difference between 2 dates in years.
564
+ * @param dateA A date to compare with the dateB date
565
+ * @param dateB A date to compare with the dateA date
566
+ */
567
+ declare function diffYears(dateA: DateInput, dateB: DateInput): number;
568
+
569
+ export { type DateInput, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, addDay, addHour, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMinute, sameSecond, sameYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };