@checkdigit/time 4.0.0-PR.18-9134 → 4.0.0-PR.18-e0fa

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 (1190) hide show
  1. package/README.md +2 -4
  2. package/dist-mjs/date-fns/_lib/defaultOptions/index.mjs +1 -1
  3. package/dist-mjs/date-fns/_lib/format/formatters/index.mjs +1 -1
  4. package/dist-mjs/date-fns/_lib/format/lightFormatters/index.mjs +2 -4
  5. package/dist-mjs/date-fns/_lib/format/longFormatters/index.mjs +1 -1
  6. package/dist-mjs/date-fns/_lib/getTimezoneOffsetInMilliseconds/index.mjs +1 -1
  7. package/dist-mjs/date-fns/_lib/protectedTokens/index.mjs +1 -1
  8. package/dist-mjs/date-fns/_test/dst/addBusinessDays/basic.mjs +1 -1
  9. package/dist-mjs/date-fns/_test/dst/eachDayOfInterval/basic.mjs +1 -1
  10. package/dist-mjs/date-fns/_test/dst/formatDistanceStrict/cairo.mjs +2 -8
  11. package/dist-mjs/date-fns/_test/dst/formatDistanceStrict/melbourne.mjs +2 -5
  12. package/dist-mjs/date-fns/_test/dst/parseISO/basic.mjs +3 -9
  13. package/dist-mjs/date-fns/_test/dst/parseISO/samoa.mjs +2 -5
  14. package/dist-mjs/date-fns/_test/dst/parseISO/sydney.mjs +1 -1
  15. package/dist-mjs/date-fns/_test/dst/tzOffsetTransitions.mjs +1 -1
  16. package/dist-mjs/date-fns/_test/formatISO/india.mjs +2 -5
  17. package/dist-mjs/date-fns/_test/formatRFC3339/australia.mjs +4 -13
  18. package/dist-mjs/date-fns/_test/formatRFC3339/india.mjs +4 -13
  19. package/dist-mjs/date-fns/_test/formatRFC3339/newfoundland.mjs +5 -16
  20. package/dist-mjs/date-fns/_test/formatRFC3339/newzealand.mjs +5 -16
  21. package/dist-mjs/date-fns/_test/formatRFC3339/poland.mjs +5 -16
  22. package/dist-mjs/date-fns/add/index.mjs +2 -10
  23. package/dist-mjs/date-fns/addBusinessDays/index.mjs +1 -1
  24. package/dist-mjs/date-fns/addDays/index.mjs +1 -1
  25. package/dist-mjs/date-fns/addHours/index.mjs +1 -1
  26. package/dist-mjs/date-fns/addISOWeekYears/index.mjs +1 -1
  27. package/dist-mjs/date-fns/addMilliseconds/index.mjs +1 -1
  28. package/dist-mjs/date-fns/addMinutes/index.mjs +1 -1
  29. package/dist-mjs/date-fns/addMonths/index.mjs +2 -6
  30. package/dist-mjs/date-fns/addQuarters/index.mjs +1 -1
  31. package/dist-mjs/date-fns/addSeconds/index.mjs +1 -1
  32. package/dist-mjs/date-fns/addWeeks/index.mjs +1 -1
  33. package/dist-mjs/date-fns/addYears/index.mjs +1 -1
  34. package/dist-mjs/date-fns/areIntervalsOverlapping/index.mjs +5 -9
  35. package/dist-mjs/date-fns/clamp/index.mjs +1 -1
  36. package/dist-mjs/date-fns/constructNow/index.mjs +1 -1
  37. package/dist-mjs/date-fns/differenceInCalendarDays/index.mjs +1 -1
  38. package/dist-mjs/date-fns/differenceInCalendarISOWeeks/index.mjs +1 -1
  39. package/dist-mjs/date-fns/differenceInCalendarWeeks/index.mjs +1 -1
  40. package/dist-mjs/date-fns/differenceInDays/index.mjs +2 -4
  41. package/dist-mjs/date-fns/differenceInHours/index.mjs +1 -1
  42. package/dist-mjs/date-fns/differenceInISOWeekYears/index.mjs +3 -7
  43. package/dist-mjs/date-fns/differenceInMinutes/index.mjs +1 -1
  44. package/dist-mjs/date-fns/differenceInMonths/index.mjs +2 -4
  45. package/dist-mjs/date-fns/eachQuarterOfInterval/index.mjs +1 -1
  46. package/dist-mjs/date-fns/eachWeekOfInterval/index.mjs +1 -1
  47. package/dist-mjs/date-fns/eachWeekendOfInterval/index.mjs +1 -1
  48. package/dist-mjs/date-fns/eachWeekendOfMonth/index.mjs +1 -1
  49. package/dist-mjs/date-fns/eachWeekendOfYear/index.mjs +1 -1
  50. package/dist-mjs/date-fns/endOfDay/index.mjs +1 -1
  51. package/dist-mjs/date-fns/endOfDecade/index.mjs +1 -1
  52. package/dist-mjs/date-fns/endOfHour/index.mjs +1 -1
  53. package/dist-mjs/date-fns/endOfISOWeek/index.mjs +1 -1
  54. package/dist-mjs/date-fns/endOfISOWeekYear/index.mjs +1 -1
  55. package/dist-mjs/date-fns/endOfMinute/index.mjs +1 -1
  56. package/dist-mjs/date-fns/endOfMonth/index.mjs +1 -1
  57. package/dist-mjs/date-fns/endOfQuarter/index.mjs +1 -1
  58. package/dist-mjs/date-fns/endOfSecond/index.mjs +1 -1
  59. package/dist-mjs/date-fns/endOfWeek/index.mjs +1 -1
  60. package/dist-mjs/date-fns/endOfYear/index.mjs +1 -1
  61. package/dist-mjs/date-fns/format/index.mjs +2 -4
  62. package/dist-mjs/date-fns/formatDistance/index.mjs +1 -1
  63. package/dist-mjs/date-fns/formatDistanceStrict/index.mjs +2 -7
  64. package/dist-mjs/date-fns/formatDistanceToNowStrict/index.mjs +1 -1
  65. package/dist-mjs/date-fns/formatDuration/index.mjs +3 -14
  66. package/dist-mjs/date-fns/formatISO/index.mjs +1 -1
  67. package/dist-mjs/date-fns/formatISODuration/index.mjs +2 -9
  68. package/dist-mjs/date-fns/formatRFC3339/index.mjs +2 -4
  69. package/dist-mjs/date-fns/formatRFC7231/index.mjs +2 -15
  70. package/dist-mjs/date-fns/formatRelative/index.mjs +1 -1
  71. package/dist-mjs/date-fns/getDate/index.mjs +1 -1
  72. package/dist-mjs/date-fns/getDay/index.mjs +1 -1
  73. package/dist-mjs/date-fns/getDayOfYear/index.mjs +1 -1
  74. package/dist-mjs/date-fns/getDaysInMonth/index.mjs +1 -1
  75. package/dist-mjs/date-fns/getDaysInYear/index.mjs +1 -1
  76. package/dist-mjs/date-fns/getDecade/index.mjs +1 -1
  77. package/dist-mjs/date-fns/getDefaultOptions/index.mjs +2 -4
  78. package/dist-mjs/date-fns/getHours/index.mjs +1 -1
  79. package/dist-mjs/date-fns/getISODay/index.mjs +1 -1
  80. package/dist-mjs/date-fns/getISOWeek/index.mjs +1 -1
  81. package/dist-mjs/date-fns/getISOWeekYear/index.mjs +1 -1
  82. package/dist-mjs/date-fns/getISOWeeksInYear/index.mjs +1 -1
  83. package/dist-mjs/date-fns/getMilliseconds/index.mjs +1 -1
  84. package/dist-mjs/date-fns/getMinutes/index.mjs +1 -1
  85. package/dist-mjs/date-fns/getMonth/index.mjs +1 -1
  86. package/dist-mjs/date-fns/getOverlappingDaysInIntervals/index.mjs +3 -9
  87. package/dist-mjs/date-fns/getQuarter/index.mjs +1 -1
  88. package/dist-mjs/date-fns/getSeconds/index.mjs +1 -1
  89. package/dist-mjs/date-fns/getTime/index.mjs +1 -1
  90. package/dist-mjs/date-fns/getUnixTime/index.mjs +1 -1
  91. package/dist-mjs/date-fns/getWeek/index.mjs +1 -1
  92. package/dist-mjs/date-fns/getWeekOfMonth/index.mjs +1 -1
  93. package/dist-mjs/date-fns/getWeekYear/index.mjs +1 -1
  94. package/dist-mjs/date-fns/getWeeksInMonth/index.mjs +2 -6
  95. package/dist-mjs/date-fns/getYear/index.mjs +1 -1
  96. package/dist-mjs/date-fns/interval/index.mjs +1 -1
  97. package/dist-mjs/date-fns/intervalToDuration/index.mjs +1 -1
  98. package/dist-mjs/date-fns/intlFormat/index.mjs +2 -4
  99. package/dist-mjs/date-fns/intlFormatDistance/index.mjs +1 -1
  100. package/dist-mjs/date-fns/isDate/index.mjs +1 -1
  101. package/dist-mjs/date-fns/isExists/index.mjs +1 -1
  102. package/dist-mjs/date-fns/isFirstDayOfMonth/index.mjs +1 -1
  103. package/dist-mjs/date-fns/isFriday/index.mjs +1 -1
  104. package/dist-mjs/date-fns/isFuture/index.mjs +1 -1
  105. package/dist-mjs/date-fns/isLastDayOfMonth/index.mjs +1 -1
  106. package/dist-mjs/date-fns/isLeapYear/index.mjs +1 -1
  107. package/dist-mjs/date-fns/isMatch/index.mjs +1 -1
  108. package/dist-mjs/date-fns/isMonday/index.mjs +1 -1
  109. package/dist-mjs/date-fns/isPast/index.mjs +1 -1
  110. package/dist-mjs/date-fns/isSameMonth/index.mjs +1 -1
  111. package/dist-mjs/date-fns/isSameWeek/index.mjs +1 -1
  112. package/dist-mjs/date-fns/isSaturday/index.mjs +1 -1
  113. package/dist-mjs/date-fns/isSunday/index.mjs +1 -1
  114. package/dist-mjs/date-fns/isThisHour/index.mjs +1 -1
  115. package/dist-mjs/date-fns/isThisISOWeek/index.mjs +1 -1
  116. package/dist-mjs/date-fns/isThisMinute/index.mjs +1 -1
  117. package/dist-mjs/date-fns/isThisMonth/index.mjs +1 -1
  118. package/dist-mjs/date-fns/isThisQuarter/index.mjs +1 -1
  119. package/dist-mjs/date-fns/isThisSecond/index.mjs +1 -1
  120. package/dist-mjs/date-fns/isThisWeek/index.mjs +1 -1
  121. package/dist-mjs/date-fns/isThisYear/index.mjs +1 -1
  122. package/dist-mjs/date-fns/isThursday/index.mjs +1 -1
  123. package/dist-mjs/date-fns/isToday/index.mjs +1 -1
  124. package/dist-mjs/date-fns/isTomorrow/index.mjs +1 -1
  125. package/dist-mjs/date-fns/isTuesday/index.mjs +1 -1
  126. package/dist-mjs/date-fns/isWednesday/index.mjs +1 -1
  127. package/dist-mjs/date-fns/isWeekend/index.mjs +1 -1
  128. package/dist-mjs/date-fns/isWithinInterval/index.mjs +2 -5
  129. package/dist-mjs/date-fns/isYesterday/index.mjs +1 -1
  130. package/dist-mjs/date-fns/lastDayOfDecade/index.mjs +1 -1
  131. package/dist-mjs/date-fns/lastDayOfISOWeek/index.mjs +1 -1
  132. package/dist-mjs/date-fns/lastDayOfISOWeekYear/index.mjs +1 -1
  133. package/dist-mjs/date-fns/lastDayOfMonth/index.mjs +1 -1
  134. package/dist-mjs/date-fns/lastDayOfQuarter/index.mjs +1 -1
  135. package/dist-mjs/date-fns/lastDayOfWeek/index.mjs +1 -1
  136. package/dist-mjs/date-fns/lastDayOfYear/index.mjs +1 -1
  137. package/dist-mjs/date-fns/lightFormat/index.mjs +2 -4
  138. package/dist-mjs/date-fns/locale/_lib/buildFormatLongFn/index.mjs +1 -1
  139. package/dist-mjs/date-fns/locale/_lib/buildLocalizeFn/index.mjs +1 -1
  140. package/dist-mjs/date-fns/locale/_lib/buildMatchFn/index.mjs +1 -1
  141. package/dist-mjs/date-fns/locale/_lib/buildMatchPatternFn/index.mjs +1 -1
  142. package/dist-mjs/date-fns/locale/en-US/_lib/formatRelative/index.mjs +1 -1
  143. package/dist-mjs/date-fns/locale/en-US/_lib/localize/index.mjs +3 -24
  144. package/dist-mjs/date-fns/locale/en-US/_lib/match/index.mjs +3 -29
  145. package/dist-mjs/date-fns/max/index.mjs +1 -1
  146. package/dist-mjs/date-fns/milliseconds/index.mjs +2 -10
  147. package/dist-mjs/date-fns/min/index.mjs +1 -1
  148. package/dist-mjs/date-fns/nextDay/index.mjs +1 -1
  149. package/dist-mjs/date-fns/nextFriday/index.mjs +1 -1
  150. package/dist-mjs/date-fns/nextMonday/index.mjs +1 -1
  151. package/dist-mjs/date-fns/nextSaturday/index.mjs +1 -1
  152. package/dist-mjs/date-fns/nextSunday/index.mjs +1 -1
  153. package/dist-mjs/date-fns/nextThursday/index.mjs +1 -1
  154. package/dist-mjs/date-fns/nextTuesday/index.mjs +1 -1
  155. package/dist-mjs/date-fns/nextWednesday/index.mjs +1 -1
  156. package/dist-mjs/date-fns/parse/_lib/Parser.mjs +2 -8
  157. package/dist-mjs/date-fns/parse/_lib/Setter.mjs +1 -1
  158. package/dist-mjs/date-fns/parse/_lib/parsers/AMPMMidnightParser.mjs +1 -1
  159. package/dist-mjs/date-fns/parse/_lib/parsers/AMPMParser.mjs +1 -1
  160. package/dist-mjs/date-fns/parse/_lib/parsers/DateParser.mjs +4 -34
  161. package/dist-mjs/date-fns/parse/_lib/parsers/DayOfYearParser.mjs +3 -23
  162. package/dist-mjs/date-fns/parse/_lib/parsers/DayParser.mjs +1 -1
  163. package/dist-mjs/date-fns/parse/_lib/parsers/DayPeriodParser.mjs +1 -1
  164. package/dist-mjs/date-fns/parse/_lib/parsers/EraParser.mjs +1 -1
  165. package/dist-mjs/date-fns/parse/_lib/parsers/ExtendedYearParser.mjs +1 -1
  166. package/dist-mjs/date-fns/parse/_lib/parsers/FractionOfSecondParser.mjs +1 -1
  167. package/dist-mjs/date-fns/parse/_lib/parsers/Hour0To11Parser.mjs +1 -1
  168. package/dist-mjs/date-fns/parse/_lib/parsers/Hour0to23Parser.mjs +1 -1
  169. package/dist-mjs/date-fns/parse/_lib/parsers/Hour1To24Parser.mjs +1 -1
  170. package/dist-mjs/date-fns/parse/_lib/parsers/Hour1to12Parser.mjs +1 -1
  171. package/dist-mjs/date-fns/parse/_lib/parsers/ISODayParser.mjs +2 -18
  172. package/dist-mjs/date-fns/parse/_lib/parsers/ISOTimezoneParser.mjs +5 -17
  173. package/dist-mjs/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.mjs +5 -17
  174. package/dist-mjs/date-fns/parse/_lib/parsers/ISOWeekParser.mjs +2 -17
  175. package/dist-mjs/date-fns/parse/_lib/parsers/ISOWeekYearParser.mjs +2 -18
  176. package/dist-mjs/date-fns/parse/_lib/parsers/LocalDayParser.mjs +2 -18
  177. package/dist-mjs/date-fns/parse/_lib/parsers/LocalWeekParser.mjs +2 -16
  178. package/dist-mjs/date-fns/parse/_lib/parsers/LocalWeekYearParser.mjs +4 -25
  179. package/dist-mjs/date-fns/parse/_lib/parsers/MinuteParser.mjs +1 -1
  180. package/dist-mjs/date-fns/parse/_lib/parsers/MonthParser.mjs +3 -20
  181. package/dist-mjs/date-fns/parse/_lib/parsers/QuarterParser.mjs +2 -17
  182. package/dist-mjs/date-fns/parse/_lib/parsers/SecondParser.mjs +1 -1
  183. package/dist-mjs/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.mjs +2 -18
  184. package/dist-mjs/date-fns/parse/_lib/parsers/StandAloneMonthParser.mjs +3 -20
  185. package/dist-mjs/date-fns/parse/_lib/parsers/StandAloneQuarterParser.mjs +2 -17
  186. package/dist-mjs/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.mjs +1 -1
  187. package/dist-mjs/date-fns/parse/_lib/parsers/TimestampSecondsParser.mjs +1 -1
  188. package/dist-mjs/date-fns/parse/_lib/parsers/YearParser.mjs +2 -5
  189. package/dist-mjs/date-fns/parse/_lib/utils.mjs +2 -6
  190. package/dist-mjs/date-fns/parse/index.mjs +4 -13
  191. package/dist-mjs/date-fns/parseISO/index.mjs +4 -14
  192. package/dist-mjs/date-fns/previousDay/index.mjs +1 -1
  193. package/dist-mjs/date-fns/previousFriday/index.mjs +1 -1
  194. package/dist-mjs/date-fns/previousMonday/index.mjs +1 -1
  195. package/dist-mjs/date-fns/previousSaturday/index.mjs +1 -1
  196. package/dist-mjs/date-fns/previousSunday/index.mjs +1 -1
  197. package/dist-mjs/date-fns/previousThursday/index.mjs +1 -1
  198. package/dist-mjs/date-fns/previousTuesday/index.mjs +1 -1
  199. package/dist-mjs/date-fns/previousWednesday/index.mjs +1 -1
  200. package/dist-mjs/date-fns/roundToNearestHours/index.mjs +1 -1
  201. package/dist-mjs/date-fns/roundToNearestMinutes/index.mjs +1 -1
  202. package/dist-mjs/date-fns/set/index.mjs +1 -1
  203. package/dist-mjs/date-fns/setDate/index.mjs +1 -1
  204. package/dist-mjs/date-fns/setDay/index.mjs +1 -1
  205. package/dist-mjs/date-fns/setDayOfYear/index.mjs +1 -1
  206. package/dist-mjs/date-fns/setDefaultOptions/index.mjs +2 -5
  207. package/dist-mjs/date-fns/setHours/index.mjs +1 -1
  208. package/dist-mjs/date-fns/setISODay/index.mjs +1 -1
  209. package/dist-mjs/date-fns/setISOWeek/index.mjs +1 -1
  210. package/dist-mjs/date-fns/setISOWeekYear/index.mjs +1 -1
  211. package/dist-mjs/date-fns/setMinutes/index.mjs +1 -1
  212. package/dist-mjs/date-fns/setMonth/index.mjs +1 -1
  213. package/dist-mjs/date-fns/setQuarter/index.mjs +1 -1
  214. package/dist-mjs/date-fns/setSeconds/index.mjs +1 -1
  215. package/dist-mjs/date-fns/setWeek/index.mjs +1 -1
  216. package/dist-mjs/date-fns/setWeekYear/index.mjs +1 -1
  217. package/dist-mjs/date-fns/setYear/index.mjs +1 -1
  218. package/dist-mjs/date-fns/startOfDay/index.mjs +1 -1
  219. package/dist-mjs/date-fns/startOfDecade/index.mjs +1 -1
  220. package/dist-mjs/date-fns/startOfHour/index.mjs +1 -1
  221. package/dist-mjs/date-fns/startOfISOWeek/index.mjs +1 -1
  222. package/dist-mjs/date-fns/startOfISOWeekYear/index.mjs +1 -1
  223. package/dist-mjs/date-fns/startOfMinute/index.mjs +1 -1
  224. package/dist-mjs/date-fns/startOfMonth/index.mjs +1 -1
  225. package/dist-mjs/date-fns/startOfQuarter/index.mjs +1 -1
  226. package/dist-mjs/date-fns/startOfSecond/index.mjs +1 -1
  227. package/dist-mjs/date-fns/startOfWeek/index.mjs +1 -1
  228. package/dist-mjs/date-fns/startOfWeekYear/index.mjs +1 -1
  229. package/dist-mjs/date-fns/startOfYear/index.mjs +1 -1
  230. package/dist-mjs/date-fns/sub/index.mjs +2 -10
  231. package/dist-mjs/date-fns/subBusinessDays/index.mjs +1 -1
  232. package/dist-mjs/date-fns/subDays/index.mjs +1 -1
  233. package/dist-mjs/date-fns/subHours/index.mjs +1 -1
  234. package/dist-mjs/date-fns/subISOWeekYears/index.mjs +1 -1
  235. package/dist-mjs/date-fns/subMilliseconds/index.mjs +1 -1
  236. package/dist-mjs/date-fns/subMinutes/index.mjs +1 -1
  237. package/dist-mjs/date-fns/subMonths/index.mjs +1 -1
  238. package/dist-mjs/date-fns/subQuarters/index.mjs +1 -1
  239. package/dist-mjs/date-fns/subSeconds/index.mjs +1 -1
  240. package/dist-mjs/date-fns/subWeeks/index.mjs +1 -1
  241. package/dist-mjs/date-fns/subYears/index.mjs +1 -1
  242. package/dist-mjs/date-fns/toDate/index.mjs +5 -5
  243. package/dist-mjs/date-fns/transpose/index.mjs +3 -12
  244. package/dist-types/date-fns/_lib/defaultLocale/index.d.ts +1 -1
  245. package/dist-types/date-fns/_lib/defaultOptions/index.d.ts +1 -1
  246. package/dist-types/date-fns/_lib/format/formatters/index.d.ts +3 -3
  247. package/dist-types/date-fns/_lib/format/longFormatters/index.d.ts +1 -1
  248. package/dist-types/date-fns/_lib/getRoundingMethod/index.d.ts +1 -1
  249. package/dist-types/date-fns/add/index.d.ts +1 -1
  250. package/dist-types/date-fns/areIntervalsOverlapping/index.d.ts +1 -1
  251. package/dist-types/date-fns/clamp/index.d.ts +1 -1
  252. package/dist-types/date-fns/differenceInCalendarWeeks/index.d.ts +2 -2
  253. package/dist-types/date-fns/differenceInHours/index.d.ts +1 -1
  254. package/dist-types/date-fns/differenceInMinutes/index.d.ts +1 -1
  255. package/dist-types/date-fns/differenceInQuarters/index.d.ts +1 -1
  256. package/dist-types/date-fns/differenceInSeconds/index.d.ts +1 -1
  257. package/dist-types/date-fns/differenceInWeeks/index.d.ts +1 -1
  258. package/dist-types/date-fns/eachDayOfInterval/index.d.ts +1 -1
  259. package/dist-types/date-fns/eachHourOfInterval/index.d.ts +1 -1
  260. package/dist-types/date-fns/eachMinuteOfInterval/index.d.ts +1 -1
  261. package/dist-types/date-fns/eachMonthOfInterval/index.d.ts +1 -1
  262. package/dist-types/date-fns/eachQuarterOfInterval/index.d.ts +1 -1
  263. package/dist-types/date-fns/eachWeekOfInterval/index.d.ts +2 -2
  264. package/dist-types/date-fns/eachWeekendOfInterval/index.d.ts +1 -1
  265. package/dist-types/date-fns/eachYearOfInterval/index.d.ts +1 -1
  266. package/dist-types/date-fns/endOfWeek/index.d.ts +2 -2
  267. package/dist-types/date-fns/format/index.d.ts +4 -4
  268. package/dist-types/date-fns/formatDistance/index.d.ts +2 -2
  269. package/dist-types/date-fns/formatDistanceStrict/index.d.ts +3 -3
  270. package/dist-types/date-fns/formatDistanceToNow/index.d.ts +1 -1
  271. package/dist-types/date-fns/formatDistanceToNowStrict/index.d.ts +1 -1
  272. package/dist-types/date-fns/formatDuration/index.d.ts +2 -2
  273. package/dist-types/date-fns/formatISO/index.d.ts +1 -1
  274. package/dist-types/date-fns/formatISO9075/index.d.ts +1 -1
  275. package/dist-types/date-fns/formatISODuration/index.d.ts +1 -1
  276. package/dist-types/date-fns/formatRelative/index.d.ts +2 -2
  277. package/dist-types/date-fns/fp/_lib/convertToFP/index.d.ts +1 -1
  278. package/dist-types/date-fns/fp/index.d.ts +263 -263
  279. package/dist-types/date-fns/getDefaultOptions/index.d.ts +1 -1
  280. package/dist-types/date-fns/getOverlappingDaysInIntervals/index.d.ts +1 -1
  281. package/dist-types/date-fns/getWeek/index.d.ts +2 -2
  282. package/dist-types/date-fns/getWeekOfMonth/index.d.ts +2 -2
  283. package/dist-types/date-fns/getWeekYear/index.d.ts +2 -2
  284. package/dist-types/date-fns/getWeeksInMonth/index.d.ts +2 -2
  285. package/dist-types/date-fns/index.d.ts +246 -246
  286. package/dist-types/date-fns/interval/index.d.ts +1 -1
  287. package/dist-types/date-fns/intervalToDuration/index.d.ts +1 -1
  288. package/dist-types/date-fns/intlFormat/index.d.ts +1 -1
  289. package/dist-types/date-fns/intlFormatDistance/index.d.ts +1 -1
  290. package/dist-types/date-fns/isMatch/index.d.ts +2 -2
  291. package/dist-types/date-fns/isSameWeek/index.d.ts +2 -2
  292. package/dist-types/date-fns/isThisWeek/index.d.ts +2 -2
  293. package/dist-types/date-fns/isWithinInterval/index.d.ts +1 -1
  294. package/dist-types/date-fns/lastDayOfWeek/index.d.ts +2 -2
  295. package/dist-types/date-fns/lightFormat/index.d.ts +1 -1
  296. package/dist-types/date-fns/locale/_lib/buildFormatLongFn/index.d.ts +1 -1
  297. package/dist-types/date-fns/locale/_lib/buildLocalizeFn/index.d.ts +3 -11
  298. package/dist-types/date-fns/locale/_lib/buildMatchFn/index.d.ts +3 -16
  299. package/dist-types/date-fns/locale/_lib/buildMatchPatternFn/index.d.ts +1 -1
  300. package/dist-types/date-fns/locale/en-US/_lib/formatDistance/index.d.ts +1 -1
  301. package/dist-types/date-fns/locale/en-US/_lib/formatLong/index.d.ts +1 -1
  302. package/dist-types/date-fns/locale/en-US/_lib/formatRelative/index.d.ts +1 -1
  303. package/dist-types/date-fns/locale/en-US/_lib/localize/index.d.ts +1 -1
  304. package/dist-types/date-fns/locale/en-US/_lib/match/index.d.ts +1 -1
  305. package/dist-types/date-fns/locale/en-US/index.d.ts +1 -1
  306. package/dist-types/date-fns/locale/index.d.ts +2 -2
  307. package/dist-types/date-fns/locale/types.d.ts +9 -9
  308. package/dist-types/date-fns/milliseconds/index.d.ts +2 -2
  309. package/dist-types/date-fns/nextDay/index.d.ts +1 -1
  310. package/dist-types/date-fns/parse/_lib/Parser.d.ts +4 -4
  311. package/dist-types/date-fns/parse/_lib/Setter.d.ts +1 -1
  312. package/dist-types/date-fns/parse/_lib/parsers/AMPMMidnightParser.d.ts +3 -3
  313. package/dist-types/date-fns/parse/_lib/parsers/AMPMParser.d.ts +3 -3
  314. package/dist-types/date-fns/parse/_lib/parsers/DateParser.d.ts +3 -3
  315. package/dist-types/date-fns/parse/_lib/parsers/DayOfYearParser.d.ts +3 -3
  316. package/dist-types/date-fns/parse/_lib/parsers/DayParser.d.ts +3 -3
  317. package/dist-types/date-fns/parse/_lib/parsers/DayPeriodParser.d.ts +3 -3
  318. package/dist-types/date-fns/parse/_lib/parsers/EraParser.d.ts +4 -4
  319. package/dist-types/date-fns/parse/_lib/parsers/ExtendedYearParser.d.ts +2 -2
  320. package/dist-types/date-fns/parse/_lib/parsers/FractionOfSecondParser.d.ts +2 -2
  321. package/dist-types/date-fns/parse/_lib/parsers/Hour0To11Parser.d.ts +3 -3
  322. package/dist-types/date-fns/parse/_lib/parsers/Hour0to23Parser.d.ts +3 -3
  323. package/dist-types/date-fns/parse/_lib/parsers/Hour1To24Parser.d.ts +3 -3
  324. package/dist-types/date-fns/parse/_lib/parsers/Hour1to12Parser.d.ts +3 -3
  325. package/dist-types/date-fns/parse/_lib/parsers/ISODayParser.d.ts +3 -3
  326. package/dist-types/date-fns/parse/_lib/parsers/ISOTimezoneParser.d.ts +2 -2
  327. package/dist-types/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.d.ts +2 -2
  328. package/dist-types/date-fns/parse/_lib/parsers/ISOWeekParser.d.ts +3 -3
  329. package/dist-types/date-fns/parse/_lib/parsers/ISOWeekYearParser.d.ts +2 -2
  330. package/dist-types/date-fns/parse/_lib/parsers/LocalDayParser.d.ts +3 -3
  331. package/dist-types/date-fns/parse/_lib/parsers/LocalWeekParser.d.ts +3 -3
  332. package/dist-types/date-fns/parse/_lib/parsers/LocalWeekYearParser.d.ts +4 -4
  333. package/dist-types/date-fns/parse/_lib/parsers/MinuteParser.d.ts +3 -3
  334. package/dist-types/date-fns/parse/_lib/parsers/MonthParser.d.ts +3 -3
  335. package/dist-types/date-fns/parse/_lib/parsers/QuarterParser.d.ts +3 -3
  336. package/dist-types/date-fns/parse/_lib/parsers/SecondParser.d.ts +3 -3
  337. package/dist-types/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.d.ts +3 -3
  338. package/dist-types/date-fns/parse/_lib/parsers/StandAloneMonthParser.d.ts +3 -3
  339. package/dist-types/date-fns/parse/_lib/parsers/StandAloneQuarterParser.d.ts +3 -3
  340. package/dist-types/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.d.ts +2 -2
  341. package/dist-types/date-fns/parse/_lib/parsers/TimestampSecondsParser.d.ts +2 -2
  342. package/dist-types/date-fns/parse/_lib/parsers/YearParser.d.ts +3 -3
  343. package/dist-types/date-fns/parse/_lib/parsers/index.d.ts +1 -1
  344. package/dist-types/date-fns/parse/_lib/types.d.ts +2 -2
  345. package/dist-types/date-fns/parse/_lib/utils.d.ts +2 -2
  346. package/dist-types/date-fns/parse/index.d.ts +4 -4
  347. package/dist-types/date-fns/previousDay/index.d.ts +1 -1
  348. package/dist-types/date-fns/roundToNearestHours/index.d.ts +1 -1
  349. package/dist-types/date-fns/roundToNearestMinutes/index.d.ts +1 -1
  350. package/dist-types/date-fns/set/index.d.ts +1 -1
  351. package/dist-types/date-fns/setDay/index.d.ts +2 -2
  352. package/dist-types/date-fns/setDefaultOptions/index.d.ts +1 -1
  353. package/dist-types/date-fns/setWeek/index.d.ts +2 -2
  354. package/dist-types/date-fns/setWeekYear/index.d.ts +2 -2
  355. package/dist-types/date-fns/startOfWeek/index.d.ts +2 -2
  356. package/dist-types/date-fns/startOfWeekYear/index.d.ts +2 -2
  357. package/dist-types/date-fns/sub/index.d.ts +1 -1
  358. package/dist-types/date-fns/transpose/index.d.ts +1 -1
  359. package/dist-types/date-fns/types.d.ts +6 -6
  360. package/package.json +1 -1
  361. package/src/date-fns/CHANGELOG.md +36 -76
  362. package/src/date-fns/_lib/addLeadingZeros/index.ts +2 -2
  363. package/src/date-fns/_lib/defaultLocale/index.ts +1 -1
  364. package/src/date-fns/_lib/defaultOptions/index.ts +2 -9
  365. package/src/date-fns/_lib/format/formatters/index.ts +233 -238
  366. package/src/date-fns/_lib/format/lightFormatters/index.ts +10 -12
  367. package/src/date-fns/_lib/format/longFormatters/index.ts +28 -31
  368. package/src/date-fns/_lib/getRoundingMethod/index.ts +1 -1
  369. package/src/date-fns/_lib/getTimezoneOffsetInMilliseconds/index.ts +2 -4
  370. package/src/date-fns/_lib/protectedTokens/index.ts +3 -7
  371. package/src/date-fns/_lib/test/index.ts +5 -5
  372. package/src/date-fns/_test/dst/addBusinessDays/basic.ts +6 -7
  373. package/src/date-fns/_test/dst/eachDayOfInterval/basic.ts +9 -10
  374. package/src/date-fns/_test/dst/formatDistanceStrict/cairo.ts +4 -11
  375. package/src/date-fns/_test/dst/formatDistanceStrict/melbourne.ts +6 -10
  376. package/src/date-fns/_test/dst/getOverlappingDaysInIntervals/basic.ts +2 -2
  377. package/src/date-fns/_test/dst/parseISO/basic.ts +13 -20
  378. package/src/date-fns/_test/dst/parseISO/samoa.ts +7 -11
  379. package/src/date-fns/_test/dst/parseISO/sydney.ts +27 -28
  380. package/src/date-fns/_test/dst/tzOffsetTransitions.ts +6 -9
  381. package/src/date-fns/_test/formatISO/india.ts +6 -10
  382. package/src/date-fns/_test/formatRFC3339/australia.ts +8 -18
  383. package/src/date-fns/_test/formatRFC3339/india.ts +8 -18
  384. package/src/date-fns/_test/formatRFC3339/newfoundland.ts +9 -20
  385. package/src/date-fns/_test/formatRFC3339/newzealand.ts +9 -20
  386. package/src/date-fns/_test/formatRFC3339/poland.ts +9 -20
  387. package/src/date-fns/add/index.ts +9 -22
  388. package/src/date-fns/addBusinessDays/index.ts +6 -9
  389. package/src/date-fns/addDays/index.ts +3 -6
  390. package/src/date-fns/addHours/index.ts +3 -6
  391. package/src/date-fns/addISOWeekYears/index.ts +3 -6
  392. package/src/date-fns/addMilliseconds/index.ts +3 -6
  393. package/src/date-fns/addMinutes/index.ts +3 -6
  394. package/src/date-fns/addMonths/index.ts +4 -11
  395. package/src/date-fns/addQuarters/index.ts +2 -5
  396. package/src/date-fns/addSeconds/index.ts +2 -5
  397. package/src/date-fns/addWeeks/index.ts +2 -5
  398. package/src/date-fns/addYears/index.ts +2 -5
  399. package/src/date-fns/areIntervalsOverlapping/index.ts +7 -12
  400. package/src/date-fns/clamp/index.ts +4 -7
  401. package/src/date-fns/closestIndexTo/index.ts +1 -1
  402. package/src/date-fns/closestTo/index.ts +2 -2
  403. package/src/date-fns/compareAsc/index.ts +1 -1
  404. package/src/date-fns/compareDesc/index.ts +1 -1
  405. package/src/date-fns/constructFrom/index.ts +1 -1
  406. package/src/date-fns/constructNow/index.ts +2 -4
  407. package/src/date-fns/daysToWeeks/index.ts +1 -1
  408. package/src/date-fns/differenceInBusinessDays/index.ts +6 -6
  409. package/src/date-fns/differenceInCalendarDays/index.ts +5 -7
  410. package/src/date-fns/differenceInCalendarISOWeekYears/index.ts +1 -1
  411. package/src/date-fns/differenceInCalendarISOWeeks/index.ts +5 -7
  412. package/src/date-fns/differenceInCalendarMonths/index.ts +1 -1
  413. package/src/date-fns/differenceInCalendarQuarters/index.ts +2 -2
  414. package/src/date-fns/differenceInCalendarWeeks/index.ts +7 -11
  415. package/src/date-fns/differenceInCalendarYears/index.ts +1 -1
  416. package/src/date-fns/differenceInDays/index.ts +4 -9
  417. package/src/date-fns/differenceInHours/index.ts +5 -6
  418. package/src/date-fns/differenceInISOWeekYears/index.ts +6 -10
  419. package/src/date-fns/differenceInMilliseconds/index.ts +1 -1
  420. package/src/date-fns/differenceInMinutes/index.ts +5 -6
  421. package/src/date-fns/differenceInMonths/index.ts +6 -12
  422. package/src/date-fns/differenceInQuarters/index.ts +3 -3
  423. package/src/date-fns/differenceInSeconds/index.ts +3 -3
  424. package/src/date-fns/differenceInWeeks/index.ts +3 -3
  425. package/src/date-fns/differenceInYears/index.ts +3 -3
  426. package/src/date-fns/eachDayOfInterval/index.ts +2 -2
  427. package/src/date-fns/eachHourOfInterval/index.ts +3 -3
  428. package/src/date-fns/eachMinuteOfInterval/index.ts +4 -4
  429. package/src/date-fns/eachMonthOfInterval/index.ts +2 -2
  430. package/src/date-fns/eachQuarterOfInterval/index.ts +6 -10
  431. package/src/date-fns/eachWeekOfInterval/index.ts +7 -19
  432. package/src/date-fns/eachWeekendOfInterval/index.ts +4 -6
  433. package/src/date-fns/eachWeekendOfMonth/index.ts +4 -6
  434. package/src/date-fns/eachWeekendOfYear/index.ts +4 -6
  435. package/src/date-fns/eachYearOfInterval/index.ts +2 -2
  436. package/src/date-fns/endOfDay/index.ts +2 -4
  437. package/src/date-fns/endOfDecade/index.ts +2 -4
  438. package/src/date-fns/endOfHour/index.ts +2 -4
  439. package/src/date-fns/endOfISOWeek/index.ts +2 -4
  440. package/src/date-fns/endOfISOWeekYear/index.ts +4 -6
  441. package/src/date-fns/endOfMinute/index.ts +2 -4
  442. package/src/date-fns/endOfMonth/index.ts +2 -4
  443. package/src/date-fns/endOfQuarter/index.ts +2 -4
  444. package/src/date-fns/endOfSecond/index.ts +2 -4
  445. package/src/date-fns/endOfToday/index.ts +1 -1
  446. package/src/date-fns/endOfWeek/index.ts +4 -6
  447. package/src/date-fns/endOfYear/index.ts +2 -4
  448. package/src/date-fns/format/index.ts +17 -24
  449. package/src/date-fns/formatDistance/index.ts +30 -33
  450. package/src/date-fns/formatDistanceStrict/index.ts +33 -49
  451. package/src/date-fns/formatDistanceToNow/index.ts +3 -3
  452. package/src/date-fns/formatDistanceToNowStrict/index.ts +4 -5
  453. package/src/date-fns/formatDuration/index.ts +10 -24
  454. package/src/date-fns/formatISO/index.ts +16 -19
  455. package/src/date-fns/formatISO9075/index.ts +13 -13
  456. package/src/date-fns/formatISODuration/index.ts +2 -9
  457. package/src/date-fns/formatRFC3339/index.ts +10 -12
  458. package/src/date-fns/formatRFC7231/index.ts +7 -22
  459. package/src/date-fns/formatRelative/index.ts +16 -18
  460. package/src/date-fns/fp/_lib/convertToFP/index.ts +1 -1
  461. package/src/date-fns/fp/add/index.ts +2 -2
  462. package/src/date-fns/fp/addBusinessDays/index.ts +2 -2
  463. package/src/date-fns/fp/addDays/index.ts +2 -2
  464. package/src/date-fns/fp/addHours/index.ts +2 -2
  465. package/src/date-fns/fp/addISOWeekYears/index.ts +2 -2
  466. package/src/date-fns/fp/addMilliseconds/index.ts +2 -2
  467. package/src/date-fns/fp/addMinutes/index.ts +2 -2
  468. package/src/date-fns/fp/addMonths/index.ts +2 -2
  469. package/src/date-fns/fp/addQuarters/index.ts +2 -2
  470. package/src/date-fns/fp/addSeconds/index.ts +2 -2
  471. package/src/date-fns/fp/addWeeks/index.ts +2 -2
  472. package/src/date-fns/fp/addYears/index.ts +2 -2
  473. package/src/date-fns/fp/areIntervalsOverlapping/index.ts +2 -2
  474. package/src/date-fns/fp/areIntervalsOverlappingWithOptions/index.ts +2 -2
  475. package/src/date-fns/fp/clamp/index.ts +2 -2
  476. package/src/date-fns/fp/closestIndexTo/index.ts +2 -2
  477. package/src/date-fns/fp/closestTo/index.ts +2 -2
  478. package/src/date-fns/fp/compareAsc/index.ts +2 -2
  479. package/src/date-fns/fp/compareDesc/index.ts +2 -2
  480. package/src/date-fns/fp/constructFrom/index.ts +2 -2
  481. package/src/date-fns/fp/daysToWeeks/index.ts +2 -2
  482. package/src/date-fns/fp/differenceInBusinessDays/index.ts +2 -2
  483. package/src/date-fns/fp/differenceInCalendarDays/index.ts +2 -2
  484. package/src/date-fns/fp/differenceInCalendarISOWeekYears/index.ts +2 -2
  485. package/src/date-fns/fp/differenceInCalendarISOWeeks/index.ts +2 -2
  486. package/src/date-fns/fp/differenceInCalendarMonths/index.ts +2 -2
  487. package/src/date-fns/fp/differenceInCalendarQuarters/index.ts +2 -2
  488. package/src/date-fns/fp/differenceInCalendarWeeks/index.ts +2 -2
  489. package/src/date-fns/fp/differenceInCalendarWeeksWithOptions/index.ts +2 -2
  490. package/src/date-fns/fp/differenceInCalendarYears/index.ts +2 -2
  491. package/src/date-fns/fp/differenceInDays/index.ts +2 -2
  492. package/src/date-fns/fp/differenceInHours/index.ts +2 -2
  493. package/src/date-fns/fp/differenceInHoursWithOptions/index.ts +2 -2
  494. package/src/date-fns/fp/differenceInISOWeekYears/index.ts +2 -2
  495. package/src/date-fns/fp/differenceInMilliseconds/index.ts +2 -2
  496. package/src/date-fns/fp/differenceInMinutes/index.ts +2 -2
  497. package/src/date-fns/fp/differenceInMinutesWithOptions/index.ts +2 -2
  498. package/src/date-fns/fp/differenceInMonths/index.ts +2 -2
  499. package/src/date-fns/fp/differenceInQuarters/index.ts +2 -2
  500. package/src/date-fns/fp/differenceInQuartersWithOptions/index.ts +2 -2
  501. package/src/date-fns/fp/differenceInSeconds/index.ts +2 -2
  502. package/src/date-fns/fp/differenceInSecondsWithOptions/index.ts +2 -2
  503. package/src/date-fns/fp/differenceInWeeks/index.ts +2 -2
  504. package/src/date-fns/fp/differenceInWeeksWithOptions/index.ts +2 -2
  505. package/src/date-fns/fp/differenceInYears/index.ts +2 -2
  506. package/src/date-fns/fp/eachDayOfInterval/index.ts +2 -2
  507. package/src/date-fns/fp/eachDayOfIntervalWithOptions/index.ts +2 -2
  508. package/src/date-fns/fp/eachHourOfInterval/index.ts +2 -2
  509. package/src/date-fns/fp/eachHourOfIntervalWithOptions/index.ts +2 -2
  510. package/src/date-fns/fp/eachMinuteOfInterval/index.ts +2 -2
  511. package/src/date-fns/fp/eachMinuteOfIntervalWithOptions/index.ts +2 -2
  512. package/src/date-fns/fp/eachMonthOfInterval/index.ts +2 -2
  513. package/src/date-fns/fp/eachMonthOfIntervalWithOptions/index.ts +2 -2
  514. package/src/date-fns/fp/eachQuarterOfInterval/index.ts +2 -2
  515. package/src/date-fns/fp/eachQuarterOfIntervalWithOptions/index.ts +2 -2
  516. package/src/date-fns/fp/eachWeekOfInterval/index.ts +2 -2
  517. package/src/date-fns/fp/eachWeekOfIntervalWithOptions/index.ts +2 -2
  518. package/src/date-fns/fp/eachWeekendOfInterval/index.ts +2 -2
  519. package/src/date-fns/fp/eachWeekendOfMonth/index.ts +2 -2
  520. package/src/date-fns/fp/eachWeekendOfYear/index.ts +2 -2
  521. package/src/date-fns/fp/eachYearOfInterval/index.ts +2 -2
  522. package/src/date-fns/fp/eachYearOfIntervalWithOptions/index.ts +2 -2
  523. package/src/date-fns/fp/endOfDay/index.ts +2 -2
  524. package/src/date-fns/fp/endOfDecade/index.ts +2 -2
  525. package/src/date-fns/fp/endOfHour/index.ts +2 -2
  526. package/src/date-fns/fp/endOfISOWeek/index.ts +2 -2
  527. package/src/date-fns/fp/endOfISOWeekYear/index.ts +2 -2
  528. package/src/date-fns/fp/endOfMinute/index.ts +2 -2
  529. package/src/date-fns/fp/endOfMonth/index.ts +2 -2
  530. package/src/date-fns/fp/endOfQuarter/index.ts +2 -2
  531. package/src/date-fns/fp/endOfSecond/index.ts +2 -2
  532. package/src/date-fns/fp/endOfWeek/index.ts +2 -2
  533. package/src/date-fns/fp/endOfWeekWithOptions/index.ts +2 -2
  534. package/src/date-fns/fp/endOfYear/index.ts +2 -2
  535. package/src/date-fns/fp/format/index.ts +2 -2
  536. package/src/date-fns/fp/formatDistance/index.ts +2 -2
  537. package/src/date-fns/fp/formatDistanceStrict/index.ts +2 -2
  538. package/src/date-fns/fp/formatDistanceStrictWithOptions/index.ts +2 -2
  539. package/src/date-fns/fp/formatDistanceWithOptions/index.ts +2 -2
  540. package/src/date-fns/fp/formatDuration/index.ts +2 -2
  541. package/src/date-fns/fp/formatDurationWithOptions/index.ts +2 -2
  542. package/src/date-fns/fp/formatISO/index.ts +2 -2
  543. package/src/date-fns/fp/formatISO9075/index.ts +2 -2
  544. package/src/date-fns/fp/formatISO9075WithOptions/index.ts +2 -2
  545. package/src/date-fns/fp/formatISODuration/index.ts +2 -2
  546. package/src/date-fns/fp/formatISOWithOptions/index.ts +2 -2
  547. package/src/date-fns/fp/formatRFC3339/index.ts +2 -2
  548. package/src/date-fns/fp/formatRFC3339WithOptions/index.ts +2 -2
  549. package/src/date-fns/fp/formatRFC7231/index.ts +2 -2
  550. package/src/date-fns/fp/formatRelative/index.ts +2 -2
  551. package/src/date-fns/fp/formatRelativeWithOptions/index.ts +2 -2
  552. package/src/date-fns/fp/formatWithOptions/index.ts +2 -2
  553. package/src/date-fns/fp/fromUnixTime/index.ts +2 -2
  554. package/src/date-fns/fp/getDate/index.ts +2 -2
  555. package/src/date-fns/fp/getDay/index.ts +2 -2
  556. package/src/date-fns/fp/getDayOfYear/index.ts +2 -2
  557. package/src/date-fns/fp/getDaysInMonth/index.ts +2 -2
  558. package/src/date-fns/fp/getDaysInYear/index.ts +2 -2
  559. package/src/date-fns/fp/getDecade/index.ts +2 -2
  560. package/src/date-fns/fp/getHours/index.ts +2 -2
  561. package/src/date-fns/fp/getISODay/index.ts +2 -2
  562. package/src/date-fns/fp/getISOWeek/index.ts +2 -2
  563. package/src/date-fns/fp/getISOWeekYear/index.ts +2 -2
  564. package/src/date-fns/fp/getISOWeeksInYear/index.ts +2 -2
  565. package/src/date-fns/fp/getMilliseconds/index.ts +2 -2
  566. package/src/date-fns/fp/getMinutes/index.ts +2 -2
  567. package/src/date-fns/fp/getMonth/index.ts +2 -2
  568. package/src/date-fns/fp/getOverlappingDaysInIntervals/index.ts +2 -2
  569. package/src/date-fns/fp/getQuarter/index.ts +2 -2
  570. package/src/date-fns/fp/getSeconds/index.ts +2 -2
  571. package/src/date-fns/fp/getTime/index.ts +2 -2
  572. package/src/date-fns/fp/getUnixTime/index.ts +2 -2
  573. package/src/date-fns/fp/getWeek/index.ts +2 -2
  574. package/src/date-fns/fp/getWeekOfMonth/index.ts +2 -2
  575. package/src/date-fns/fp/getWeekOfMonthWithOptions/index.ts +2 -2
  576. package/src/date-fns/fp/getWeekWithOptions/index.ts +2 -2
  577. package/src/date-fns/fp/getWeekYear/index.ts +2 -2
  578. package/src/date-fns/fp/getWeekYearWithOptions/index.ts +2 -2
  579. package/src/date-fns/fp/getWeeksInMonth/index.ts +2 -2
  580. package/src/date-fns/fp/getWeeksInMonthWithOptions/index.ts +2 -2
  581. package/src/date-fns/fp/getYear/index.ts +2 -2
  582. package/src/date-fns/fp/hoursToMilliseconds/index.ts +2 -2
  583. package/src/date-fns/fp/hoursToMinutes/index.ts +2 -2
  584. package/src/date-fns/fp/hoursToSeconds/index.ts +2 -2
  585. package/src/date-fns/fp/index.ts +263 -263
  586. package/src/date-fns/fp/interval/index.ts +2 -2
  587. package/src/date-fns/fp/intervalToDuration/index.ts +2 -2
  588. package/src/date-fns/fp/intervalWithOptions/index.ts +2 -2
  589. package/src/date-fns/fp/intlFormat/index.ts +2 -2
  590. package/src/date-fns/fp/intlFormatDistance/index.ts +2 -2
  591. package/src/date-fns/fp/intlFormatDistanceWithOptions/index.ts +2 -2
  592. package/src/date-fns/fp/isAfter/index.ts +2 -2
  593. package/src/date-fns/fp/isBefore/index.ts +2 -2
  594. package/src/date-fns/fp/isDate/index.ts +2 -2
  595. package/src/date-fns/fp/isEqual/index.ts +2 -2
  596. package/src/date-fns/fp/isExists/index.ts +2 -2
  597. package/src/date-fns/fp/isFirstDayOfMonth/index.ts +2 -2
  598. package/src/date-fns/fp/isFriday/index.ts +2 -2
  599. package/src/date-fns/fp/isLastDayOfMonth/index.ts +2 -2
  600. package/src/date-fns/fp/isLeapYear/index.ts +2 -2
  601. package/src/date-fns/fp/isMatch/index.ts +2 -2
  602. package/src/date-fns/fp/isMatchWithOptions/index.ts +2 -2
  603. package/src/date-fns/fp/isMonday/index.ts +2 -2
  604. package/src/date-fns/fp/isSameDay/index.ts +2 -2
  605. package/src/date-fns/fp/isSameHour/index.ts +2 -2
  606. package/src/date-fns/fp/isSameISOWeek/index.ts +2 -2
  607. package/src/date-fns/fp/isSameISOWeekYear/index.ts +2 -2
  608. package/src/date-fns/fp/isSameMinute/index.ts +2 -2
  609. package/src/date-fns/fp/isSameMonth/index.ts +2 -2
  610. package/src/date-fns/fp/isSameQuarter/index.ts +2 -2
  611. package/src/date-fns/fp/isSameSecond/index.ts +2 -2
  612. package/src/date-fns/fp/isSameWeek/index.ts +2 -2
  613. package/src/date-fns/fp/isSameWeekWithOptions/index.ts +2 -2
  614. package/src/date-fns/fp/isSameYear/index.ts +2 -2
  615. package/src/date-fns/fp/isSaturday/index.ts +2 -2
  616. package/src/date-fns/fp/isSunday/index.ts +2 -2
  617. package/src/date-fns/fp/isThursday/index.ts +2 -2
  618. package/src/date-fns/fp/isTuesday/index.ts +2 -2
  619. package/src/date-fns/fp/isValid/index.ts +2 -2
  620. package/src/date-fns/fp/isWednesday/index.ts +2 -2
  621. package/src/date-fns/fp/isWeekend/index.ts +2 -2
  622. package/src/date-fns/fp/isWithinInterval/index.ts +2 -2
  623. package/src/date-fns/fp/lastDayOfDecade/index.ts +2 -2
  624. package/src/date-fns/fp/lastDayOfISOWeek/index.ts +2 -2
  625. package/src/date-fns/fp/lastDayOfISOWeekYear/index.ts +2 -2
  626. package/src/date-fns/fp/lastDayOfMonth/index.ts +2 -2
  627. package/src/date-fns/fp/lastDayOfQuarter/index.ts +2 -2
  628. package/src/date-fns/fp/lastDayOfWeek/index.ts +2 -2
  629. package/src/date-fns/fp/lastDayOfWeekWithOptions/index.ts +2 -2
  630. package/src/date-fns/fp/lastDayOfYear/index.ts +2 -2
  631. package/src/date-fns/fp/lightFormat/index.ts +2 -2
  632. package/src/date-fns/fp/max/index.ts +2 -2
  633. package/src/date-fns/fp/milliseconds/index.ts +2 -2
  634. package/src/date-fns/fp/millisecondsToHours/index.ts +2 -2
  635. package/src/date-fns/fp/millisecondsToMinutes/index.ts +2 -2
  636. package/src/date-fns/fp/millisecondsToSeconds/index.ts +2 -2
  637. package/src/date-fns/fp/min/index.ts +2 -2
  638. package/src/date-fns/fp/minutesToHours/index.ts +2 -2
  639. package/src/date-fns/fp/minutesToMilliseconds/index.ts +2 -2
  640. package/src/date-fns/fp/minutesToSeconds/index.ts +2 -2
  641. package/src/date-fns/fp/monthsToQuarters/index.ts +2 -2
  642. package/src/date-fns/fp/monthsToYears/index.ts +2 -2
  643. package/src/date-fns/fp/nextDay/index.ts +2 -2
  644. package/src/date-fns/fp/nextFriday/index.ts +2 -2
  645. package/src/date-fns/fp/nextMonday/index.ts +2 -2
  646. package/src/date-fns/fp/nextSaturday/index.ts +2 -2
  647. package/src/date-fns/fp/nextSunday/index.ts +2 -2
  648. package/src/date-fns/fp/nextThursday/index.ts +2 -2
  649. package/src/date-fns/fp/nextTuesday/index.ts +2 -2
  650. package/src/date-fns/fp/nextWednesday/index.ts +2 -2
  651. package/src/date-fns/fp/parse/index.ts +2 -2
  652. package/src/date-fns/fp/parseISO/index.ts +2 -2
  653. package/src/date-fns/fp/parseISOWithOptions/index.ts +2 -2
  654. package/src/date-fns/fp/parseJSON/index.ts +2 -2
  655. package/src/date-fns/fp/parseWithOptions/index.ts +2 -2
  656. package/src/date-fns/fp/previousDay/index.ts +2 -2
  657. package/src/date-fns/fp/previousFriday/index.ts +2 -2
  658. package/src/date-fns/fp/previousMonday/index.ts +2 -2
  659. package/src/date-fns/fp/previousSaturday/index.ts +2 -2
  660. package/src/date-fns/fp/previousSunday/index.ts +2 -2
  661. package/src/date-fns/fp/previousThursday/index.ts +2 -2
  662. package/src/date-fns/fp/previousTuesday/index.ts +2 -2
  663. package/src/date-fns/fp/previousWednesday/index.ts +2 -2
  664. package/src/date-fns/fp/quartersToMonths/index.ts +2 -2
  665. package/src/date-fns/fp/quartersToYears/index.ts +2 -2
  666. package/src/date-fns/fp/roundToNearestHours/index.ts +2 -2
  667. package/src/date-fns/fp/roundToNearestHoursWithOptions/index.ts +2 -2
  668. package/src/date-fns/fp/roundToNearestMinutes/index.ts +2 -2
  669. package/src/date-fns/fp/roundToNearestMinutesWithOptions/index.ts +2 -2
  670. package/src/date-fns/fp/secondsToHours/index.ts +2 -2
  671. package/src/date-fns/fp/secondsToMilliseconds/index.ts +2 -2
  672. package/src/date-fns/fp/secondsToMinutes/index.ts +2 -2
  673. package/src/date-fns/fp/set/index.ts +2 -2
  674. package/src/date-fns/fp/setDate/index.ts +2 -2
  675. package/src/date-fns/fp/setDay/index.ts +2 -2
  676. package/src/date-fns/fp/setDayOfYear/index.ts +2 -2
  677. package/src/date-fns/fp/setDayWithOptions/index.ts +2 -2
  678. package/src/date-fns/fp/setHours/index.ts +2 -2
  679. package/src/date-fns/fp/setISODay/index.ts +2 -2
  680. package/src/date-fns/fp/setISOWeek/index.ts +2 -2
  681. package/src/date-fns/fp/setISOWeekYear/index.ts +2 -2
  682. package/src/date-fns/fp/setMilliseconds/index.ts +2 -2
  683. package/src/date-fns/fp/setMinutes/index.ts +2 -2
  684. package/src/date-fns/fp/setMonth/index.ts +2 -2
  685. package/src/date-fns/fp/setQuarter/index.ts +2 -2
  686. package/src/date-fns/fp/setSeconds/index.ts +2 -2
  687. package/src/date-fns/fp/setWeek/index.ts +2 -2
  688. package/src/date-fns/fp/setWeekWithOptions/index.ts +2 -2
  689. package/src/date-fns/fp/setWeekYear/index.ts +2 -2
  690. package/src/date-fns/fp/setWeekYearWithOptions/index.ts +2 -2
  691. package/src/date-fns/fp/setYear/index.ts +2 -2
  692. package/src/date-fns/fp/startOfDay/index.ts +2 -2
  693. package/src/date-fns/fp/startOfDecade/index.ts +2 -2
  694. package/src/date-fns/fp/startOfHour/index.ts +2 -2
  695. package/src/date-fns/fp/startOfISOWeek/index.ts +2 -2
  696. package/src/date-fns/fp/startOfISOWeekYear/index.ts +2 -2
  697. package/src/date-fns/fp/startOfMinute/index.ts +2 -2
  698. package/src/date-fns/fp/startOfMonth/index.ts +2 -2
  699. package/src/date-fns/fp/startOfQuarter/index.ts +2 -2
  700. package/src/date-fns/fp/startOfSecond/index.ts +2 -2
  701. package/src/date-fns/fp/startOfWeek/index.ts +2 -2
  702. package/src/date-fns/fp/startOfWeekWithOptions/index.ts +2 -2
  703. package/src/date-fns/fp/startOfWeekYear/index.ts +2 -2
  704. package/src/date-fns/fp/startOfWeekYearWithOptions/index.ts +2 -2
  705. package/src/date-fns/fp/startOfYear/index.ts +2 -2
  706. package/src/date-fns/fp/sub/index.ts +2 -2
  707. package/src/date-fns/fp/subBusinessDays/index.ts +2 -2
  708. package/src/date-fns/fp/subDays/index.ts +2 -2
  709. package/src/date-fns/fp/subHours/index.ts +2 -2
  710. package/src/date-fns/fp/subISOWeekYears/index.ts +2 -2
  711. package/src/date-fns/fp/subMilliseconds/index.ts +2 -2
  712. package/src/date-fns/fp/subMinutes/index.ts +2 -2
  713. package/src/date-fns/fp/subMonths/index.ts +2 -2
  714. package/src/date-fns/fp/subQuarters/index.ts +2 -2
  715. package/src/date-fns/fp/subSeconds/index.ts +2 -2
  716. package/src/date-fns/fp/subWeeks/index.ts +2 -2
  717. package/src/date-fns/fp/subYears/index.ts +2 -2
  718. package/src/date-fns/fp/toDate/index.ts +2 -2
  719. package/src/date-fns/fp/transpose/index.ts +2 -2
  720. package/src/date-fns/fp/types.ts +2 -13
  721. package/src/date-fns/fp/weeksToDays/index.ts +2 -2
  722. package/src/date-fns/fp/yearsToDays/index.ts +2 -2
  723. package/src/date-fns/fp/yearsToMonths/index.ts +2 -2
  724. package/src/date-fns/fp/yearsToQuarters/index.ts +2 -2
  725. package/src/date-fns/fromUnixTime/index.ts +1 -1
  726. package/src/date-fns/getDate/index.ts +2 -4
  727. package/src/date-fns/getDay/index.ts +2 -4
  728. package/src/date-fns/getDayOfYear/index.ts +4 -6
  729. package/src/date-fns/getDaysInMonth/index.ts +3 -5
  730. package/src/date-fns/getDaysInYear/index.ts +4 -6
  731. package/src/date-fns/getDecade/index.ts +2 -4
  732. package/src/date-fns/getDefaultOptions/index.ts +2 -5
  733. package/src/date-fns/getHours/index.ts +2 -4
  734. package/src/date-fns/getISODay/index.ts +2 -4
  735. package/src/date-fns/getISOWeek/index.ts +5 -7
  736. package/src/date-fns/getISOWeekYear/index.ts +4 -6
  737. package/src/date-fns/getISOWeeksInYear/index.ts +4 -6
  738. package/src/date-fns/getMilliseconds/index.ts +2 -4
  739. package/src/date-fns/getMinutes/index.ts +2 -4
  740. package/src/date-fns/getMonth/index.ts +2 -4
  741. package/src/date-fns/getOverlappingDaysInIntervals/index.ts +6 -12
  742. package/src/date-fns/getQuarter/index.ts +2 -4
  743. package/src/date-fns/getSeconds/index.ts +2 -4
  744. package/src/date-fns/getTime/index.ts +2 -4
  745. package/src/date-fns/getUnixTime/index.ts +2 -4
  746. package/src/date-fns/getWeek/index.ts +7 -17
  747. package/src/date-fns/getWeekOfMonth/index.ts +6 -8
  748. package/src/date-fns/getWeekYear/index.ts +6 -13
  749. package/src/date-fns/getWeeksInMonth/index.ts +6 -14
  750. package/src/date-fns/getYear/index.ts +2 -4
  751. package/src/date-fns/hoursToMilliseconds/index.ts +1 -1
  752. package/src/date-fns/hoursToMinutes/index.ts +1 -1
  753. package/src/date-fns/hoursToSeconds/index.ts +1 -1
  754. package/src/date-fns/index.ts +246 -246
  755. package/src/date-fns/interval/index.ts +5 -6
  756. package/src/date-fns/intervalToDuration/index.ts +10 -12
  757. package/src/date-fns/intlFormat/index.ts +5 -9
  758. package/src/date-fns/intlFormatDistance/index.ts +30 -41
  759. package/src/date-fns/isAfter/index.ts +1 -1
  760. package/src/date-fns/isBefore/index.ts +1 -1
  761. package/src/date-fns/isDate/index.ts +1 -3
  762. package/src/date-fns/isEqual/index.ts +1 -1
  763. package/src/date-fns/isExists/index.ts +1 -5
  764. package/src/date-fns/isFirstDayOfMonth/index.ts +2 -4
  765. package/src/date-fns/isFriday/index.ts +2 -4
  766. package/src/date-fns/isFuture/index.ts +2 -4
  767. package/src/date-fns/isLastDayOfMonth/index.ts +4 -6
  768. package/src/date-fns/isLeapYear/index.ts +2 -4
  769. package/src/date-fns/isMatch/index.ts +5 -14
  770. package/src/date-fns/isMonday/index.ts +2 -4
  771. package/src/date-fns/isPast/index.ts +2 -4
  772. package/src/date-fns/isSameDay/index.ts +1 -1
  773. package/src/date-fns/isSameHour/index.ts +1 -1
  774. package/src/date-fns/isSameISOWeek/index.ts +1 -1
  775. package/src/date-fns/isSameISOWeekYear/index.ts +1 -1
  776. package/src/date-fns/isSameMinute/index.ts +1 -1
  777. package/src/date-fns/isSameMonth/index.ts +2 -5
  778. package/src/date-fns/isSameQuarter/index.ts +1 -1
  779. package/src/date-fns/isSameSecond/index.ts +1 -1
  780. package/src/date-fns/isSameWeek/index.ts +3 -5
  781. package/src/date-fns/isSameYear/index.ts +1 -1
  782. package/src/date-fns/isSaturday/index.ts +2 -4
  783. package/src/date-fns/isSunday/index.ts +2 -4
  784. package/src/date-fns/isThisHour/index.ts +3 -5
  785. package/src/date-fns/isThisISOWeek/index.ts +3 -5
  786. package/src/date-fns/isThisMinute/index.ts +3 -5
  787. package/src/date-fns/isThisMonth/index.ts +3 -5
  788. package/src/date-fns/isThisQuarter/index.ts +3 -5
  789. package/src/date-fns/isThisSecond/index.ts +3 -5
  790. package/src/date-fns/isThisWeek/index.ts +4 -6
  791. package/src/date-fns/isThisYear/index.ts +3 -5
  792. package/src/date-fns/isThursday/index.ts +2 -4
  793. package/src/date-fns/isToday/index.ts +3 -5
  794. package/src/date-fns/isTomorrow/index.ts +4 -6
  795. package/src/date-fns/isTuesday/index.ts +2 -4
  796. package/src/date-fns/isValid/index.ts +3 -3
  797. package/src/date-fns/isWednesday/index.ts +2 -4
  798. package/src/date-fns/isWeekend/index.ts +2 -4
  799. package/src/date-fns/isWithinInterval/index.ts +3 -6
  800. package/src/date-fns/isYesterday/index.ts +4 -6
  801. package/src/date-fns/lastDayOfDecade/index.ts +2 -4
  802. package/src/date-fns/lastDayOfISOWeek/index.ts +2 -4
  803. package/src/date-fns/lastDayOfISOWeekYear/index.ts +4 -6
  804. package/src/date-fns/lastDayOfMonth/index.ts +2 -4
  805. package/src/date-fns/lastDayOfQuarter/index.ts +2 -4
  806. package/src/date-fns/lastDayOfWeek/index.ts +4 -6
  807. package/src/date-fns/lastDayOfYear/index.ts +2 -4
  808. package/src/date-fns/lightFormat/index.ts +8 -15
  809. package/src/date-fns/locale/_lib/buildFormatLongFn/index.ts +3 -7
  810. package/src/date-fns/locale/_lib/buildLocalizeFn/index.ts +25 -48
  811. package/src/date-fns/locale/_lib/buildMatchFn/index.ts +20 -58
  812. package/src/date-fns/locale/_lib/buildMatchPatternFn/index.ts +3 -7
  813. package/src/date-fns/locale/en-US/_lib/formatDistance/index.ts +36 -36
  814. package/src/date-fns/locale/en-US/_lib/formatLong/index.ts +15 -15
  815. package/src/date-fns/locale/en-US/_lib/formatRelative/index.ts +3 -8
  816. package/src/date-fns/locale/en-US/_lib/localize/index.ts +84 -105
  817. package/src/date-fns/locale/en-US/_lib/match/index.ts +16 -42
  818. package/src/date-fns/locale/en-US/index.ts +7 -7
  819. package/src/date-fns/locale/index.ts +2 -2
  820. package/src/date-fns/locale/types.ts +39 -75
  821. package/src/date-fns/max/index.ts +3 -9
  822. package/src/date-fns/milliseconds/index.ts +3 -11
  823. package/src/date-fns/millisecondsToHours/index.ts +1 -1
  824. package/src/date-fns/millisecondsToMinutes/index.ts +1 -1
  825. package/src/date-fns/millisecondsToSeconds/index.ts +1 -1
  826. package/src/date-fns/min/index.ts +2 -4
  827. package/src/date-fns/minutesToHours/index.ts +1 -1
  828. package/src/date-fns/minutesToMilliseconds/index.ts +1 -1
  829. package/src/date-fns/minutesToSeconds/index.ts +1 -1
  830. package/src/date-fns/monthsToQuarters/index.ts +1 -1
  831. package/src/date-fns/monthsToYears/index.ts +1 -1
  832. package/src/date-fns/nextDay/index.ts +4 -7
  833. package/src/date-fns/nextFriday/index.ts +2 -4
  834. package/src/date-fns/nextMonday/index.ts +2 -4
  835. package/src/date-fns/nextSaturday/index.ts +2 -4
  836. package/src/date-fns/nextSunday/index.ts +2 -4
  837. package/src/date-fns/nextThursday/index.ts +2 -4
  838. package/src/date-fns/nextTuesday/index.ts +2 -4
  839. package/src/date-fns/nextWednesday/index.ts +2 -4
  840. package/src/date-fns/parse/_lib/Parser.ts +7 -22
  841. package/src/date-fns/parse/_lib/Setter.ts +6 -16
  842. package/src/date-fns/parse/_lib/parsers/AMPMMidnightParser.ts +24 -32
  843. package/src/date-fns/parse/_lib/parsers/AMPMParser.ts +24 -32
  844. package/src/date-fns/parse/_lib/parsers/DateParser.ts +11 -34
  845. package/src/date-fns/parse/_lib/parsers/DayOfYearParser.ts +11 -35
  846. package/src/date-fns/parse/_lib/parsers/DayParser.ts +25 -30
  847. package/src/date-fns/parse/_lib/parsers/DayPeriodParser.ts +24 -32
  848. package/src/date-fns/parse/_lib/parsers/EraParser.ts +16 -23
  849. package/src/date-fns/parse/_lib/parsers/ExtendedYearParser.ts +6 -10
  850. package/src/date-fns/parse/_lib/parsers/FractionOfSecondParser.ts +6 -11
  851. package/src/date-fns/parse/_lib/parsers/Hour0To11Parser.ts +10 -14
  852. package/src/date-fns/parse/_lib/parsers/Hour0to23Parser.ts +10 -14
  853. package/src/date-fns/parse/_lib/parsers/Hour1To24Parser.ts +10 -14
  854. package/src/date-fns/parse/_lib/parsers/Hour1to12Parser.ts +10 -14
  855. package/src/date-fns/parse/_lib/parsers/ISODayParser.ts +35 -55
  856. package/src/date-fns/parse/_lib/parsers/ISOTimezoneParser.ts +17 -33
  857. package/src/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.ts +17 -33
  858. package/src/date-fns/parse/_lib/parsers/ISOWeekParser.ts +12 -31
  859. package/src/date-fns/parse/_lib/parsers/ISOWeekYearParser.ts +8 -28
  860. package/src/date-fns/parse/_lib/parsers/LocalDayParser.ts +29 -55
  861. package/src/date-fns/parse/_lib/parsers/LocalWeekParser.ts +12 -31
  862. package/src/date-fns/parse/_lib/parsers/LocalWeekYearParser.ts +17 -46
  863. package/src/date-fns/parse/_lib/parsers/MinuteParser.ts +10 -14
  864. package/src/date-fns/parse/_lib/parsers/MonthParser.ts +24 -46
  865. package/src/date-fns/parse/_lib/parsers/QuarterParser.ts +25 -44
  866. package/src/date-fns/parse/_lib/parsers/SecondParser.ts +10 -14
  867. package/src/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.ts +29 -55
  868. package/src/date-fns/parse/_lib/parsers/StandAloneMonthParser.ts +24 -46
  869. package/src/date-fns/parse/_lib/parsers/StandAloneQuarterParser.ts +25 -44
  870. package/src/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.ts +6 -10
  871. package/src/date-fns/parse/_lib/parsers/TimestampSecondsParser.ts +6 -10
  872. package/src/date-fns/parse/_lib/parsers/YearParser.ts +14 -29
  873. package/src/date-fns/parse/_lib/parsers/index.ts +32 -32
  874. package/src/date-fns/parse/_lib/types.ts +2 -8
  875. package/src/date-fns/parse/_lib/utils.ts +22 -45
  876. package/src/date-fns/parse/index.ts +24 -51
  877. package/src/date-fns/parseISO/index.ts +17 -58
  878. package/src/date-fns/parseJSON/index.ts +3 -3
  879. package/src/date-fns/previousDay/index.ts +4 -7
  880. package/src/date-fns/previousFriday/index.ts +2 -4
  881. package/src/date-fns/previousMonday/index.ts +2 -4
  882. package/src/date-fns/previousSaturday/index.ts +2 -4
  883. package/src/date-fns/previousSunday/index.ts +2 -4
  884. package/src/date-fns/previousThursday/index.ts +2 -4
  885. package/src/date-fns/previousTuesday/index.ts +2 -4
  886. package/src/date-fns/previousWednesday/index.ts +2 -4
  887. package/src/date-fns/quartersToMonths/index.ts +1 -1
  888. package/src/date-fns/quartersToYears/index.ts +1 -1
  889. package/src/date-fns/roundToNearestHours/index.ts +7 -17
  890. package/src/date-fns/roundToNearestMinutes/index.ts +7 -14
  891. package/src/date-fns/secondsToHours/index.ts +1 -1
  892. package/src/date-fns/secondsToMilliseconds/index.ts +1 -1
  893. package/src/date-fns/secondsToMinutes/index.ts +1 -1
  894. package/src/date-fns/set/index.ts +5 -8
  895. package/src/date-fns/setDate/index.ts +2 -5
  896. package/src/date-fns/setDay/index.ts +6 -10
  897. package/src/date-fns/setDayOfYear/index.ts +2 -5
  898. package/src/date-fns/setDefaultOptions/index.ts +3 -8
  899. package/src/date-fns/setHours/index.ts +2 -5
  900. package/src/date-fns/setISODay/index.ts +4 -7
  901. package/src/date-fns/setISOWeek/index.ts +3 -6
  902. package/src/date-fns/setISOWeekYear/index.ts +5 -8
  903. package/src/date-fns/setMilliseconds/index.ts +1 -1
  904. package/src/date-fns/setMinutes/index.ts +2 -5
  905. package/src/date-fns/setMonth/index.ts +4 -7
  906. package/src/date-fns/setQuarter/index.ts +3 -6
  907. package/src/date-fns/setSeconds/index.ts +2 -5
  908. package/src/date-fns/setWeek/index.ts +4 -11
  909. package/src/date-fns/setWeekYear/index.ts +7 -14
  910. package/src/date-fns/setYear/index.ts +3 -6
  911. package/src/date-fns/startOfDay/index.ts +2 -4
  912. package/src/date-fns/startOfDecade/index.ts +2 -4
  913. package/src/date-fns/startOfHour/index.ts +2 -4
  914. package/src/date-fns/startOfISOWeek/index.ts +2 -4
  915. package/src/date-fns/startOfISOWeekYear/index.ts +4 -6
  916. package/src/date-fns/startOfMinute/index.ts +2 -4
  917. package/src/date-fns/startOfMonth/index.ts +2 -4
  918. package/src/date-fns/startOfQuarter/index.ts +2 -4
  919. package/src/date-fns/startOfSecond/index.ts +2 -4
  920. package/src/date-fns/startOfToday/index.ts +1 -1
  921. package/src/date-fns/startOfWeek/index.ts +4 -6
  922. package/src/date-fns/startOfWeekYear/index.ts +6 -10
  923. package/src/date-fns/startOfYear/index.ts +3 -5
  924. package/src/date-fns/sub/index.ts +6 -17
  925. package/src/date-fns/subBusinessDays/index.ts +2 -5
  926. package/src/date-fns/subDays/index.ts +2 -5
  927. package/src/date-fns/subHours/index.ts +2 -5
  928. package/src/date-fns/subISOWeekYears/index.ts +2 -5
  929. package/src/date-fns/subMilliseconds/index.ts +2 -5
  930. package/src/date-fns/subMinutes/index.ts +2 -5
  931. package/src/date-fns/subMonths/index.ts +2 -5
  932. package/src/date-fns/subQuarters/index.ts +2 -5
  933. package/src/date-fns/subSeconds/index.ts +2 -5
  934. package/src/date-fns/subWeeks/index.ts +2 -5
  935. package/src/date-fns/subYears/index.ts +2 -5
  936. package/src/date-fns/toDate/index.ts +14 -19
  937. package/src/date-fns/transpose/index.ts +6 -21
  938. package/src/date-fns/types.ts +6 -6
  939. package/src/date-fns/weeksToDays/index.ts +1 -1
  940. package/src/date-fns/yearsToDays/index.ts +1 -1
  941. package/src/date-fns/yearsToMonths/index.ts +1 -1
  942. package/src/date-fns/yearsToQuarters/index.ts +1 -1
  943. package/src/date-fns/_lib/addLeadingZeros/test.mts +0 -12
  944. package/src/date-fns/_lib/getRoundingMethod/test.mts +0 -50
  945. package/src/date-fns/_lib/getTimezoneOffsetInMilliseconds/test.mts +0 -25
  946. package/src/date-fns/add/test.mts +0 -98
  947. package/src/date-fns/addBusinessDays/test.mts +0 -75
  948. package/src/date-fns/addDays/test.mts +0 -113
  949. package/src/date-fns/addHours/test.mts +0 -33
  950. package/src/date-fns/addISOWeekYears/test.mts +0 -44
  951. package/src/date-fns/addMilliseconds/test.mts +0 -39
  952. package/src/date-fns/addMinutes/test.mts +0 -33
  953. package/src/date-fns/addMonths/test.mts +0 -138
  954. package/src/date-fns/addQuarters/test.mts +0 -47
  955. package/src/date-fns/addSeconds/test.mts +0 -33
  956. package/src/date-fns/addWeeks/test.mts +0 -30
  957. package/src/date-fns/addYears/test.mts +0 -46
  958. package/src/date-fns/areIntervalsOverlapping/test.mts +0 -231
  959. package/src/date-fns/clamp/test.mts +0 -36
  960. package/src/date-fns/closestIndexTo/test.mts +0 -57
  961. package/src/date-fns/closestTo/test.mts +0 -59
  962. package/src/date-fns/compareAsc/test.mts +0 -70
  963. package/src/date-fns/compareDesc/test.mts +0 -70
  964. package/src/date-fns/constructFrom/test.mts +0 -47
  965. package/src/date-fns/constructNow/test.mts +0 -37
  966. package/src/date-fns/daysToWeeks/test.mts +0 -36
  967. package/src/date-fns/differenceInBusinessDays/test.mts +0 -129
  968. package/src/date-fns/differenceInCalendarDays/test.mts +0 -216
  969. package/src/date-fns/differenceInCalendarISOWeekYears/test.mts +0 -111
  970. package/src/date-fns/differenceInCalendarISOWeeks/test.mts +0 -104
  971. package/src/date-fns/differenceInCalendarMonths/test.mts +0 -97
  972. package/src/date-fns/differenceInCalendarQuarters/test.mts +0 -97
  973. package/src/date-fns/differenceInCalendarWeeks/test.mts +0 -151
  974. package/src/date-fns/differenceInCalendarYears/test.mts +0 -97
  975. package/src/date-fns/differenceInDays/test.mts +0 -207
  976. package/src/date-fns/differenceInHours/test.mts +0 -149
  977. package/src/date-fns/differenceInISOWeekYears/test.mts +0 -108
  978. package/src/date-fns/differenceInMilliseconds/test.mts +0 -62
  979. package/src/date-fns/differenceInMinutes/test.mts +0 -141
  980. package/src/date-fns/differenceInMonths/test.mts +0 -171
  981. package/src/date-fns/differenceInQuarters/test.mts +0 -148
  982. package/src/date-fns/differenceInSeconds/test.mts +0 -156
  983. package/src/date-fns/differenceInWeeks/test.mts +0 -149
  984. package/src/date-fns/differenceInYears/test.mts +0 -139
  985. package/src/date-fns/eachDayOfInterval/test.mts +0 -164
  986. package/src/date-fns/eachHourOfInterval/test.mts +0 -154
  987. package/src/date-fns/eachMinuteOfInterval/test.mts +0 -159
  988. package/src/date-fns/eachMonthOfInterval/test.mts +0 -163
  989. package/src/date-fns/eachQuarterOfInterval/test.mts +0 -148
  990. package/src/date-fns/eachWeekOfInterval/test.mts +0 -180
  991. package/src/date-fns/eachWeekendOfInterval/test.mts +0 -67
  992. package/src/date-fns/eachWeekendOfMonth/test.mts +0 -23
  993. package/src/date-fns/eachWeekendOfYear/test.mts +0 -18
  994. package/src/date-fns/eachYearOfInterval/test.mts +0 -148
  995. package/src/date-fns/endOfDay/test.mts +0 -27
  996. package/src/date-fns/endOfDecade/test.mts +0 -36
  997. package/src/date-fns/endOfHour/test.mts +0 -26
  998. package/src/date-fns/endOfISOWeek/test.mts +0 -27
  999. package/src/date-fns/endOfISOWeekYear/test.mts +0 -38
  1000. package/src/date-fns/endOfMinute/test.mts +0 -26
  1001. package/src/date-fns/endOfMonth/test.mts +0 -41
  1002. package/src/date-fns/endOfQuarter/test.mts +0 -27
  1003. package/src/date-fns/endOfSecond/test.mts +0 -26
  1004. package/src/date-fns/endOfToday/test.mts +0 -21
  1005. package/src/date-fns/endOfTomorrow/test.mts +0 -31
  1006. package/src/date-fns/endOfWeek/test.mts +0 -86
  1007. package/src/date-fns/endOfYear/test.mts +0 -27
  1008. package/src/date-fns/endOfYesterday/test.mts +0 -31
  1009. package/src/date-fns/format/test.mts +0 -994
  1010. package/src/date-fns/formatDistance/test.mts +0 -253
  1011. package/src/date-fns/formatDistanceStrict/test.mts +0 -437
  1012. package/src/date-fns/formatDistanceToNow/test.mts +0 -200
  1013. package/src/date-fns/formatDistanceToNowStrict/test.mts +0 -381
  1014. package/src/date-fns/formatDuration/test.mts +0 -66
  1015. package/src/date-fns/formatISO/test.mts +0 -58
  1016. package/src/date-fns/formatISO9075/test.mts +0 -35
  1017. package/src/date-fns/formatISODuration/test.mts +0 -75
  1018. package/src/date-fns/formatRFC3339/test.mts +0 -44
  1019. package/src/date-fns/formatRFC7231/test.mts +0 -18
  1020. package/src/date-fns/formatRelative/test.mts +0 -118
  1021. package/src/date-fns/fp/_lib/convertToFP/test.mts +0 -120
  1022. package/src/date-fns/fromUnixTime/test.mts +0 -14
  1023. package/src/date-fns/getDate/test.mts +0 -19
  1024. package/src/date-fns/getDay/test.mts +0 -19
  1025. package/src/date-fns/getDayOfYear/test.mts +0 -27
  1026. package/src/date-fns/getDaysInMonth/test.mts +0 -33
  1027. package/src/date-fns/getDaysInYear/test.mts +0 -35
  1028. package/src/date-fns/getDecade/test.mts +0 -24
  1029. package/src/date-fns/getDefaultOptions/test.mts +0 -58
  1030. package/src/date-fns/getHours/test.mts +0 -19
  1031. package/src/date-fns/getISODay/test.mts +0 -24
  1032. package/src/date-fns/getISOWeek/test.mts +0 -54
  1033. package/src/date-fns/getISOWeekYear/test.mts +0 -27
  1034. package/src/date-fns/getISOWeeksInYear/test.mts +0 -37
  1035. package/src/date-fns/getMilliseconds/test.mts +0 -23
  1036. package/src/date-fns/getMinutes/test.mts +0 -19
  1037. package/src/date-fns/getMonth/test.mts +0 -19
  1038. package/src/date-fns/getOverlappingDaysInIntervals/test.mts +0 -249
  1039. package/src/date-fns/getQuarter/test.mts +0 -19
  1040. package/src/date-fns/getSeconds/test.mts +0 -21
  1041. package/src/date-fns/getTime/test.mts +0 -21
  1042. package/src/date-fns/getUnixTime/test.mts +0 -26
  1043. package/src/date-fns/getWeek/test.mts +0 -56
  1044. package/src/date-fns/getWeekOfMonth/test.mts +0 -75
  1045. package/src/date-fns/getWeekYear/test.mts +0 -49
  1046. package/src/date-fns/getWeeksInMonth/test.mts +0 -53
  1047. package/src/date-fns/getYear/test.mts +0 -19
  1048. package/src/date-fns/hoursToMilliseconds/test.mts +0 -23
  1049. package/src/date-fns/hoursToMinutes/test.mts +0 -25
  1050. package/src/date-fns/hoursToSeconds/test.mts +0 -25
  1051. package/src/date-fns/interval/test.mts +0 -45
  1052. package/src/date-fns/intervalToDuration/test.mts +0 -227
  1053. package/src/date-fns/intlFormat/test.mts +0 -94
  1054. package/src/date-fns/intlFormatDistance/test.mts +0 -794
  1055. package/src/date-fns/isAfter/test.mts +0 -51
  1056. package/src/date-fns/isBefore/test.mts +0 -51
  1057. package/src/date-fns/isDate/test.mts +0 -74
  1058. package/src/date-fns/isEqual/test.mts +0 -43
  1059. package/src/date-fns/isExists/test.mts +0 -14
  1060. package/src/date-fns/isFirstDayOfMonth/test.mts +0 -25
  1061. package/src/date-fns/isFriday/test.mts +0 -24
  1062. package/src/date-fns/isFuture/test.mts +0 -34
  1063. package/src/date-fns/isLastDayOfMonth/test.mts +0 -25
  1064. package/src/date-fns/isLeapYear/test.mts +0 -35
  1065. package/src/date-fns/isMatch/test.mts +0 -25
  1066. package/src/date-fns/isMonday/test.mts +0 -24
  1067. package/src/date-fns/isPast/test.mts +0 -34
  1068. package/src/date-fns/isSameDay/test.mts +0 -43
  1069. package/src/date-fns/isSameHour/test.mts +0 -43
  1070. package/src/date-fns/isSameISOWeek/test.mts +0 -49
  1071. package/src/date-fns/isSameISOWeekYear/test.mts +0 -60
  1072. package/src/date-fns/isSameMinute/test.mts +0 -43
  1073. package/src/date-fns/isSameMonth/test.mts +0 -43
  1074. package/src/date-fns/isSameQuarter/test.mts +0 -49
  1075. package/src/date-fns/isSameSecond/test.mts +0 -43
  1076. package/src/date-fns/isSameWeek/test.mts +0 -79
  1077. package/src/date-fns/isSameYear/test.mts +0 -43
  1078. package/src/date-fns/isSaturday/test.mts +0 -24
  1079. package/src/date-fns/isSunday/test.mts +0 -24
  1080. package/src/date-fns/isThisHour/test.mts +0 -38
  1081. package/src/date-fns/isThisISOWeek/test.mts +0 -36
  1082. package/src/date-fns/isThisMinute/test.mts +0 -40
  1083. package/src/date-fns/isThisMonth/test.mts +0 -36
  1084. package/src/date-fns/isThisQuarter/test.mts +0 -36
  1085. package/src/date-fns/isThisSecond/test.mts +0 -40
  1086. package/src/date-fns/isThisWeek/test.mts +0 -41
  1087. package/src/date-fns/isThisYear/test.mts +0 -34
  1088. package/src/date-fns/isThursday/test.mts +0 -24
  1089. package/src/date-fns/isToday/test.mts +0 -34
  1090. package/src/date-fns/isTomorrow/test.mts +0 -36
  1091. package/src/date-fns/isTuesday/test.mts +0 -24
  1092. package/src/date-fns/isValid/test.mts +0 -24
  1093. package/src/date-fns/isWednesday/test.mts +0 -24
  1094. package/src/date-fns/isWeekend/test.mts +0 -24
  1095. package/src/date-fns/isWithinInterval/test.mts +0 -92
  1096. package/src/date-fns/isYesterday/test.mts +0 -36
  1097. package/src/date-fns/lastDayOfDecade/test.mts +0 -36
  1098. package/src/date-fns/lastDayOfISOWeek/test.mts +0 -27
  1099. package/src/date-fns/lastDayOfISOWeekYear/test.mts +0 -38
  1100. package/src/date-fns/lastDayOfMonth/test.mts +0 -41
  1101. package/src/date-fns/lastDayOfQuarter/test.mts +0 -27
  1102. package/src/date-fns/lastDayOfWeek/test.mts +0 -86
  1103. package/src/date-fns/lastDayOfYear/test.mts +0 -27
  1104. package/src/date-fns/lightFormat/test.mts +0 -138
  1105. package/src/date-fns/max/test.mts +0 -44
  1106. package/src/date-fns/milliseconds/test.mts +0 -62
  1107. package/src/date-fns/millisecondsToHours/test.mts +0 -24
  1108. package/src/date-fns/millisecondsToMinutes/test.mts +0 -24
  1109. package/src/date-fns/millisecondsToSeconds/test.mts +0 -24
  1110. package/src/date-fns/min/test.mts +0 -44
  1111. package/src/date-fns/minutesToHours/test.mts +0 -24
  1112. package/src/date-fns/minutesToMilliseconds/test.mts +0 -23
  1113. package/src/date-fns/minutesToSeconds/test.mts +0 -23
  1114. package/src/date-fns/monthsToQuarters/test.mts +0 -24
  1115. package/src/date-fns/monthsToYears/test.mts +0 -24
  1116. package/src/date-fns/nextDay/test.mts +0 -44
  1117. package/src/date-fns/nextFriday/test.mts +0 -24
  1118. package/src/date-fns/nextMonday/test.mts +0 -24
  1119. package/src/date-fns/nextSaturday/test.mts +0 -24
  1120. package/src/date-fns/nextSunday/test.mts +0 -24
  1121. package/src/date-fns/nextThursday/test.mts +0 -24
  1122. package/src/date-fns/nextTuesday/test.mts +0 -23
  1123. package/src/date-fns/nextWednesday/test.mts +0 -24
  1124. package/src/date-fns/parse/test.mts +0 -2474
  1125. package/src/date-fns/parseISO/test.mts +0 -362
  1126. package/src/date-fns/parseJSON/test.mts +0 -129
  1127. package/src/date-fns/previousDay/test.mts +0 -42
  1128. package/src/date-fns/previousFriday/test.mts +0 -22
  1129. package/src/date-fns/previousMonday/test.mts +0 -22
  1130. package/src/date-fns/previousSaturday/test.mts +0 -22
  1131. package/src/date-fns/previousSunday/test.mts +0 -22
  1132. package/src/date-fns/previousThursday/test.mts +0 -22
  1133. package/src/date-fns/previousTuesday/test.mts +0 -22
  1134. package/src/date-fns/previousWednesday/test.mts +0 -22
  1135. package/src/date-fns/quartersToMonths/test.mts +0 -24
  1136. package/src/date-fns/quartersToYears/test.mts +0 -24
  1137. package/src/date-fns/roundToNearestHours/test.mts +0 -208
  1138. package/src/date-fns/roundToNearestMinutes/test.mts +0 -215
  1139. package/src/date-fns/secondsToHours/test.mts +0 -24
  1140. package/src/date-fns/secondsToMilliseconds/test.mts +0 -14
  1141. package/src/date-fns/secondsToMinutes/test.mts +0 -24
  1142. package/src/date-fns/set/test.mts +0 -121
  1143. package/src/date-fns/setDate/test.mts +0 -30
  1144. package/src/date-fns/setDay/test.mts +0 -112
  1145. package/src/date-fns/setDayOfYear/test.mts +0 -30
  1146. package/src/date-fns/setDefaultOptions/test.mts +0 -466
  1147. package/src/date-fns/setHours/test.mts +0 -30
  1148. package/src/date-fns/setISODay/test.mts +0 -59
  1149. package/src/date-fns/setISOWeek/test.mts +0 -41
  1150. package/src/date-fns/setISOWeekYear/test.mts +0 -53
  1151. package/src/date-fns/setMilliseconds/test.mts +0 -39
  1152. package/src/date-fns/setMinutes/test.mts +0 -33
  1153. package/src/date-fns/setMonth/test.mts +0 -46
  1154. package/src/date-fns/setQuarter/test.mts +0 -46
  1155. package/src/date-fns/setSeconds/test.mts +0 -39
  1156. package/src/date-fns/setWeek/test.mts +0 -63
  1157. package/src/date-fns/setWeekYear/test.mts +0 -75
  1158. package/src/date-fns/setYear/test.mts +0 -30
  1159. package/src/date-fns/startOfDay/test.mts +0 -27
  1160. package/src/date-fns/startOfDecade/test.mts +0 -32
  1161. package/src/date-fns/startOfHour/test.mts +0 -27
  1162. package/src/date-fns/startOfISOWeek/test.mts +0 -27
  1163. package/src/date-fns/startOfISOWeekYear/test.mts +0 -43
  1164. package/src/date-fns/startOfMinute/test.mts +0 -27
  1165. package/src/date-fns/startOfMonth/test.mts +0 -27
  1166. package/src/date-fns/startOfQuarter/test.mts +0 -27
  1167. package/src/date-fns/startOfSecond/test.mts +0 -27
  1168. package/src/date-fns/startOfToday/test.mts +0 -21
  1169. package/src/date-fns/startOfTomorrow/test.mts +0 -31
  1170. package/src/date-fns/startOfWeek/test.mts +0 -86
  1171. package/src/date-fns/startOfWeekYear/test.mts +0 -60
  1172. package/src/date-fns/startOfYear/test.mts +0 -38
  1173. package/src/date-fns/startOfYesterday/test.mts +0 -31
  1174. package/src/date-fns/sub/test.mts +0 -83
  1175. package/src/date-fns/subBusinessDays/test.mts +0 -43
  1176. package/src/date-fns/subDays/test.mts +0 -30
  1177. package/src/date-fns/subHours/test.mts +0 -33
  1178. package/src/date-fns/subISOWeekYears/test.mts +0 -44
  1179. package/src/date-fns/subMilliseconds/test.mts +0 -39
  1180. package/src/date-fns/subMinutes/test.mts +0 -33
  1181. package/src/date-fns/subMonths/test.mts +0 -47
  1182. package/src/date-fns/subQuarters/test.mts +0 -47
  1183. package/src/date-fns/subSeconds/test.mts +0 -33
  1184. package/src/date-fns/subWeeks/test.mts +0 -30
  1185. package/src/date-fns/subYears/test.mts +0 -46
  1186. package/src/date-fns/toDate/test.mts +0 -35
  1187. package/src/date-fns/weeksToDays/test.mts +0 -24
  1188. package/src/date-fns/yearsToDays/test.mts +0 -24
  1189. package/src/date-fns/yearsToMonths/test.mts +0 -24
  1190. package/src/date-fns/yearsToQuarters/test.mts +0 -24
@@ -1,2474 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { parse } from "./index";
3
-
4
- describe("parse", () => {
5
- const referenceDate = new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 900);
6
-
7
- it("escapes characters between the single quote characters", () => {
8
- const result = parse(
9
- "2018 hello world July 2nd",
10
- "yyyy 'hello world' MMMM do",
11
- referenceDate,
12
- );
13
- expect(result).toEqual(new Date(2018, 6 /* Jul */, 2));
14
- });
15
-
16
- it('two single quote characters are transformed into a "real" single quote', () => {
17
- const result = parse("'5 o'clock'", "''h 'o''clock'''", referenceDate);
18
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 5));
19
- });
20
-
21
- it("accepts new line charactor", () => {
22
- const result = parse(
23
- "2014-04-04\n05:00:00",
24
- "yyyy-MM-dd'\n'HH:mm:ss",
25
- referenceDate,
26
- );
27
- expect(result).toEqual(new Date(2014, 3 /* Apr */, 4, 5));
28
- });
29
-
30
- describe("era", () => {
31
- it("abbreviated", () => {
32
- const result = parse("10000 BC", "yyyyy G", referenceDate);
33
- expect(result).toEqual(new Date(-9999, 0 /* Jan */, 1));
34
- });
35
-
36
- it("wide", () => {
37
- const result = parse("2018 Anno Domini", "yyyy GGGG", referenceDate);
38
- expect(result).toEqual(new Date(2018, 0 /* Jan */, 1));
39
- });
40
-
41
- it("narrow", () => {
42
- const result = parse("44 B", "y GGGGG", referenceDate);
43
- expect(result).toEqual(new Date(-43, 0 /* Jan */, 1));
44
- });
45
-
46
- it("with week-numbering year", () => {
47
- const result = parse("44 B", "Y GGGGG", referenceDate);
48
- expect(result).toEqual(new Date(-44, 11 /* Dec */, 30));
49
- });
50
-
51
- it("parses stand-alone BC", () => {
52
- const result = parse("BC", "G", referenceDate);
53
- const expectedResult = new Date(0);
54
- expectedResult.setFullYear(0, 0 /* Jan */, 1);
55
- expectedResult.setHours(0, 0, 0, 0);
56
- expect(result).toEqual(expectedResult);
57
- });
58
-
59
- it("parses stand-alone AD", () => {
60
- const result = parse("AD", "G", referenceDate);
61
- const expectedResult = new Date(0);
62
- expectedResult.setFullYear(1, 0 /* Jan */, 1);
63
- expectedResult.setHours(0, 0, 0, 0);
64
- expect(result).toEqual(expectedResult);
65
- });
66
-
67
- describe("validation", () => {
68
- [
69
- ["G", "BC"],
70
- ["R", "2019"],
71
- ["u", "2019"],
72
- ["t", "512969520"],
73
- ["T", "512969520900"],
74
- ].forEach(([token, example]) => {
75
- it(`throws an error when G is used after ${token}`, () => {
76
- const block = () =>
77
- parse(`${example} 420`, `${token} G`, referenceDate);
78
- expect(block).toThrow(RangeError);
79
- expect(block).toThrow(
80
- new RegExp(
81
- `The format string mustn't contain \`${token}\` and \`G\` at the same time`,
82
- ),
83
- );
84
- });
85
- });
86
- });
87
- });
88
-
89
- describe("calendar year", () => {
90
- it("numeric", () => {
91
- const result = parse("2017", "y", referenceDate);
92
- expect(result).toEqual(new Date(2017, 0 /* Jan */, 1));
93
- });
94
-
95
- it("ordinal", () => {
96
- const result = parse("2017th", "yo", referenceDate);
97
- expect(result).toEqual(new Date(2017, 0 /* Jan */, 1));
98
- });
99
-
100
- describe("two-digit numeric year", () => {
101
- it("works as expected", () => {
102
- const result = parse("02", "yy", referenceDate);
103
- expect(result).toEqual(new Date(2002, 0 /* Jan */, 1));
104
- });
105
-
106
- it("gets the 100 year range from `referenceDate`", () => {
107
- const result = parse("02", "yy", new Date(1860, 6 /* Jul */, 2));
108
- expect(result).toEqual(new Date(1902, 0 /* Jan */, 1));
109
- });
110
- });
111
-
112
- it("three-digit zero-padding", () => {
113
- const result = parse("123", "yyy", referenceDate);
114
- expect(result).toEqual(new Date(123, 0 /* Jan */, 1));
115
- });
116
-
117
- it("four-digit zero-padding", () => {
118
- const result = parse("0044", "yyyy", referenceDate);
119
- const expectedResult = new Date(0);
120
- expectedResult.setFullYear(44, 0 /* Jan */, 1);
121
- expectedResult.setHours(0, 0, 0, 0);
122
- expect(result).toEqual(expectedResult);
123
- });
124
-
125
- it("specified amount of digits", () => {
126
- const result = parse("000001", "yyyyyy", referenceDate);
127
- const expectedResult = new Date(0);
128
- expectedResult.setFullYear(1, 0 /* Jan */, 1);
129
- expectedResult.setHours(0, 0, 0, 0);
130
- expect(result).toEqual(expectedResult);
131
- });
132
-
133
- describe("validation", () => {
134
- [
135
- ["y", "2019"],
136
- ["Y", "2019"],
137
- ["R", "2019"],
138
- ["u", "2019"],
139
- ["w", "1"],
140
- ["I", "1"],
141
- ["i", "1"],
142
- ["e", "1"],
143
- ["c", "1"],
144
- ["t", "512969520"],
145
- ["T", "512969520900"],
146
- ].forEach(([token, example]) => {
147
- it(`throws an error when y is used after ${token}`, () => {
148
- const block = () =>
149
- parse(`${example} 2019`, `${token} y`, referenceDate);
150
- expect(block).toThrow(RangeError);
151
- expect(block).toThrow(
152
- new RegExp(
153
- `The format string mustn't contain \`${token}\` and \`y\` at the same time`,
154
- ),
155
- );
156
- });
157
- });
158
- });
159
- });
160
-
161
- describe("local week-numbering year", () => {
162
- it("numeric", () => {
163
- const result = parse("2002", "Y", referenceDate);
164
- expect(result).toEqual(new Date(2001, 11 /* Dec */, 30));
165
- });
166
-
167
- it("ordinal", () => {
168
- const result = parse("12345th", "Yo", referenceDate);
169
- expect(result).toEqual(new Date(12344, 11 /* Dec */, 31));
170
- });
171
-
172
- describe("two-digit numeric year", () => {
173
- it("works as expected", () => {
174
- const result = parse("02", "YY", referenceDate, {
175
- useAdditionalWeekYearTokens: true,
176
- });
177
- expect(result).toEqual(new Date(2001, 11 /* Dec */, 30));
178
- });
179
-
180
- it("gets the 100 year range from `referenceDate`", () => {
181
- const result = parse("02", "YY", new Date(1860, 6 /* Jul */, 2), {
182
- useAdditionalWeekYearTokens: true,
183
- });
184
- expect(result).toEqual(new Date(1901, 11 /* Dec */, 29));
185
- });
186
- });
187
-
188
- it("three-digit zero-padding", () => {
189
- const result = parse("123", "YYY", referenceDate);
190
- expect(result).toEqual(new Date(122, 11 /* Dec */, 27));
191
- });
192
-
193
- it("four-digit zero-padding", () => {
194
- const result = parse("2018", "YYYY", referenceDate, {
195
- useAdditionalWeekYearTokens: true,
196
- });
197
- expect(result).toEqual(new Date(2017, 11 /* Dec */, 31));
198
- });
199
-
200
- it("specified amount of digits", () => {
201
- const result = parse("000001", "YYYYYY", referenceDate);
202
- const expectedResult = new Date(0);
203
- expectedResult.setFullYear(0, 11 /* Dec */, 31);
204
- expectedResult.setHours(0, 0, 0, 0);
205
- expect(result).toEqual(expectedResult);
206
- });
207
-
208
- it("allows to specify `weekStartsOn` and `firstWeekContainsDate` in options", () => {
209
- const result = parse("2018", "Y", referenceDate, {
210
- weekStartsOn: 1 /* Mon */,
211
- firstWeekContainsDate: 4,
212
- });
213
- expect(result).toEqual(new Date(2018, 0 /* Jan */, 1));
214
- });
215
-
216
- describe("validation", () => {
217
- const tokensToValidate: Array<
218
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
219
- > = [
220
- ["y", "2019"],
221
- ["Y", "2019"],
222
- ["R", "2019"],
223
- ["u", "2019"],
224
- ["Q", "1"],
225
- ["q", "1"],
226
- ["M", "1"],
227
- ["L", "1"],
228
- ["I", "1"],
229
- ["d", "1"],
230
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
231
- ["i", "1"],
232
- ["t", "512969520"],
233
- ["T", "512969520900"],
234
- ];
235
- tokensToValidate.forEach(([token, example, options]) => {
236
- it(`throws an error when Y is used after ${token}`, () => {
237
- const block = () =>
238
- parse(`${example} 2019`, `${token} Y`, referenceDate, options);
239
- expect(block).toThrow(RangeError);
240
- expect(block).toThrow(
241
- new RegExp(
242
- `The format string mustn't contain \`${token}\` and \`Y\` at the same time`,
243
- ),
244
- );
245
- });
246
- });
247
- });
248
- });
249
-
250
- describe("ISO week-numbering year", () => {
251
- it("numeric", () => {
252
- const result = parse("-1234", "R", referenceDate);
253
- expect(result).toEqual(new Date(-1234, 0 /* Jan */, 3));
254
- });
255
-
256
- it("two-digit zero-padding", () => {
257
- const result = parse("-02", "RR", referenceDate);
258
- expect(result).toEqual(new Date(-3, 11 /* Dec */, 29));
259
- });
260
-
261
- it("three-digit zero-padding", () => {
262
- const result = parse("123", "RRR", referenceDate);
263
- expect(result).toEqual(new Date(123, 0 /* Jan */, 4));
264
- });
265
-
266
- it("four-digit zero-padding", () => {
267
- const result = parse("2018", "RRRR", referenceDate);
268
- expect(result).toEqual(new Date(2018, 0 /* Jan */, 1));
269
- });
270
-
271
- it("specified amount of digits", () => {
272
- const result = parse("000001", "RRRRRR", referenceDate);
273
- const expectedResult = new Date(0);
274
- expectedResult.setFullYear(1, 0 /* Jan */, 1);
275
- expectedResult.setHours(0, 0, 0, 0);
276
- expect(result).toEqual(expectedResult);
277
- });
278
-
279
- describe("validation", () => {
280
- const tokensToValidate: Array<
281
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
282
- > = [
283
- ["G", "AD"],
284
- ["y", "2019"],
285
- ["Y", "2019"],
286
- ["R", "2019"],
287
- ["u", "2019"],
288
- ["Q", "1"],
289
- ["q", "1"],
290
- ["M", "1"],
291
- ["L", "1"],
292
- ["w", "1"],
293
- ["d", "1"],
294
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
295
- ["e", "1"],
296
- ["c", "1"],
297
- ["t", "512969520"],
298
- ["T", "512969520900"],
299
- ];
300
- tokensToValidate.forEach(([token, example, options]) => {
301
- it(`throws an error when R is used after ${token}`, () => {
302
- const block = () =>
303
- parse(`${example} 2019`, `${token} R`, referenceDate, options);
304
- expect(block).toThrow(RangeError);
305
- expect(block).toThrow(
306
- new RegExp(
307
- `The format string mustn't contain \`${token}\` and \`R\` at the same time`,
308
- ),
309
- );
310
- });
311
- });
312
- });
313
- });
314
-
315
- describe("extended year", () => {
316
- it("numeric", () => {
317
- const result = parse("-1234", "u", referenceDate);
318
- expect(result).toEqual(new Date(-1234, 0 /* Jan */, 1));
319
- });
320
-
321
- it("two-digit zero-padding", () => {
322
- const result = parse("-02", "uu", referenceDate);
323
- expect(result).toEqual(new Date(-2, 0 /* Jan */, 1));
324
- });
325
-
326
- it("three-digit zero-padding", () => {
327
- const result = parse("123", "uuu", referenceDate);
328
- expect(result).toEqual(new Date(123, 0 /* Jan */, 1));
329
- });
330
-
331
- it("four-digit zero-padding", () => {
332
- const result = parse("2018", "uuuu", referenceDate);
333
- expect(result).toEqual(new Date(2018, 0 /* Jan */, 1));
334
- });
335
-
336
- it("specified amount of digits", () => {
337
- const result = parse("000001", "uuuuuu", referenceDate);
338
- const expectedResult = new Date(0);
339
- expectedResult.setFullYear(1, 0 /* Jan */, 1);
340
- expectedResult.setHours(0, 0, 0, 0);
341
- expect(result).toEqual(expectedResult);
342
- });
343
-
344
- describe("validation", () => {
345
- [
346
- ["G", "AD"],
347
- ["y", "2019"],
348
- ["Y", "2019"],
349
- ["R", "2019"],
350
- ["u", "2019"],
351
- ["w", "1"],
352
- ["I", "1"],
353
- ["i", "1"],
354
- ["e", "1"],
355
- ["c", "1"],
356
- ["t", "512969520"],
357
- ["T", "512969520900"],
358
- ].forEach(([token, example]) => {
359
- it(`throws an error when u is used after ${token}`, () => {
360
- const block = () =>
361
- parse(`${example} 2019`, `${token} u`, referenceDate);
362
- expect(block).toThrow(RangeError);
363
- expect(block).toThrow(
364
- new RegExp(
365
- `The format string mustn't contain \`${token}\` and \`u\` at the same time`,
366
- ),
367
- );
368
- });
369
- });
370
- });
371
- });
372
-
373
- describe("quarter with following year", () => {
374
- it("first quarter", () => {
375
- const result = parse("Q1/2020", "QQQ/yyyy", referenceDate);
376
- expect(result).toEqual(new Date(2020, 0 /* Jan */, 1));
377
- });
378
-
379
- it("second quarter", () => {
380
- const result = parse("Q2/2020", "QQQ/yyyy", referenceDate);
381
- expect(result).toEqual(new Date(2020, 3 /* Apr */, 1));
382
- });
383
-
384
- it("third quarter", () => {
385
- const result = parse("Q3/2020", "QQQ/yyyy", referenceDate);
386
- expect(result).toEqual(new Date(2020, 6 /* Jul */, 1));
387
- });
388
-
389
- it("fourth quarter", () => {
390
- const result = parse("Q4/2020", "QQQ/yyyy", referenceDate);
391
- expect(result).toEqual(new Date(2020, 9 /* Oct */, 1));
392
- });
393
- });
394
-
395
- describe("quarter (formatting)", () => {
396
- it("numeric", () => {
397
- const result = parse("1", "Q", referenceDate);
398
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
399
- });
400
-
401
- it("ordinal", () => {
402
- const result = parse("1st", "Qo", referenceDate);
403
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
404
- });
405
-
406
- it("zero-padding", () => {
407
- const result = parse("02", "QQ", referenceDate);
408
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
409
- });
410
-
411
- it("abbreviated", () => {
412
- const result = parse("Q3", "QQQ", referenceDate);
413
- expect(result).toEqual(new Date(1986, 6 /* Jul */, 1));
414
- });
415
-
416
- it("wide", () => {
417
- const result = parse("4st quarter", "QQQQ", referenceDate);
418
- expect(result).toEqual(new Date(1986, 9 /* Oct */, 1));
419
- });
420
-
421
- it("narrow", () => {
422
- const result = parse("1", "QQQQQ", referenceDate);
423
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
424
- });
425
-
426
- describe("validation", () => {
427
- const tokensToValidate: Array<
428
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
429
- > = [
430
- ["Y", "2019"],
431
- ["R", "2019"],
432
- ["Q", "1"],
433
- ["q", "1"],
434
- ["M", "1"],
435
- ["L", "1"],
436
- ["w", "1"],
437
- ["I", "1"],
438
- ["d", "1"],
439
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
440
- ["i", "1"],
441
- ["e", "1"],
442
- ["c", "1"],
443
- ["t", "512969520"],
444
- ["T", "512969520900"],
445
- ];
446
- tokensToValidate.forEach(([token, example, options]) => {
447
- it(`throws an error when Q is used after ${token}`, () => {
448
- const block = () =>
449
- parse(`${example} 1`, `${token} Q`, referenceDate, options);
450
- expect(block).toThrow(RangeError);
451
- expect(block).toThrow(
452
- new RegExp(
453
- `The format string mustn't contain \`${token}\` and \`Q\` at the same time`,
454
- ),
455
- );
456
- });
457
- });
458
- });
459
- });
460
-
461
- describe("quarter (stand-alone)", () => {
462
- it("numeric", () => {
463
- const result = parse("1", "q", referenceDate);
464
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
465
- });
466
-
467
- it("ordinal", () => {
468
- const result = parse("1th", "qo", referenceDate);
469
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
470
- });
471
-
472
- it("zero-padding", () => {
473
- const result = parse("02", "qq", referenceDate);
474
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
475
- });
476
-
477
- it("abbreviated", () => {
478
- const result = parse("Q3", "qqq", referenceDate);
479
- expect(result).toEqual(new Date(1986, 6 /* Jul */, 1));
480
- });
481
-
482
- it("wide", () => {
483
- const result = parse("4th quarter", "qqqq", referenceDate);
484
- expect(result).toEqual(new Date(1986, 9 /* Oct */, 1));
485
- });
486
-
487
- it("narrow", () => {
488
- const result = parse("1", "qqqqq", referenceDate);
489
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
490
- });
491
-
492
- describe("validation", () => {
493
- const tokensToValidate: Array<
494
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
495
- > = [
496
- ["Y", "2019"],
497
- ["R", "2019"],
498
- ["Q", "1"],
499
- ["q", "1"],
500
- ["M", "1"],
501
- ["L", "1"],
502
- ["w", "1"],
503
- ["I", "1"],
504
- ["d", "1"],
505
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
506
- ["i", "1"],
507
- ["e", "1"],
508
- ["c", "1"],
509
- ["t", "512969520"],
510
- ["T", "512969520900"],
511
- ];
512
- tokensToValidate.forEach(([token, example, options]) => {
513
- it(`throws an error when q is used after ${token}`, () => {
514
- const block = () =>
515
- parse(`${example} 1`, `${token} q`, referenceDate, options);
516
- expect(block).toThrow(RangeError);
517
- expect(block).toThrow(
518
- new RegExp(
519
- `The format string mustn't contain \`${token}\` and \`q\` at the same time`,
520
- ),
521
- );
522
- });
523
- });
524
- });
525
- });
526
-
527
- describe("month (formatting)", () => {
528
- it("numeric", () => {
529
- const result = parse("6", "M", referenceDate);
530
- expect(result).toEqual(new Date(1986, 5 /* Jun */, 1));
531
- });
532
-
533
- it("ordinal", () => {
534
- const result = parse("6th", "Mo", referenceDate);
535
- expect(result).toEqual(new Date(1986, 5 /* Jun */, 1));
536
- });
537
-
538
- it("zero-padding", () => {
539
- const result = parse("01", "MM", referenceDate);
540
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
541
- });
542
-
543
- it("abbreviated", () => {
544
- const result = parse("Nov", "MMM", referenceDate);
545
- expect(result).toEqual(new Date(1986, 10 /* Nov */, 1));
546
- });
547
-
548
- it("wide", () => {
549
- const result = parse("February", "MMMM", referenceDate);
550
- expect(result).toEqual(new Date(1986, 1 /* Feb */, 1));
551
- });
552
-
553
- it("narrow", () => {
554
- const result = parse("J", "MMMMM", referenceDate);
555
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
556
- });
557
-
558
- describe("validation", () => {
559
- const tokensToValidate: Array<
560
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
561
- > = [
562
- ["Y", "2019"],
563
- ["R", "2019"],
564
- ["Q", "1"],
565
- ["q", "1"],
566
- ["M", "1"],
567
- ["L", "1"],
568
- ["w", "1"],
569
- ["I", "1"],
570
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
571
- ["i", "1"],
572
- ["e", "1"],
573
- ["c", "1"],
574
- ["t", "512969520"],
575
- ["T", "512969520900"],
576
- ];
577
- tokensToValidate.forEach(([token, example, options]) => {
578
- it(`throws an error when M is used after ${token}`, () => {
579
- const block = () =>
580
- parse(`${example} 1`, `${token} M`, referenceDate, options);
581
- expect(block).toThrow(RangeError);
582
- expect(block).toThrow(
583
- new RegExp(
584
- `The format string mustn't contain \`${token}\` and \`M\` at the same time`,
585
- ),
586
- );
587
- });
588
- });
589
- });
590
- });
591
-
592
- describe("month (stand-alone)", () => {
593
- it("numeric", () => {
594
- const result = parse("6", "L", referenceDate);
595
- expect(result).toEqual(new Date(1986, 5 /* Jun */, 1));
596
- });
597
-
598
- it("ordinal", () => {
599
- const result = parse("6th", "Lo", referenceDate);
600
- expect(result).toEqual(new Date(1986, 5 /* Jun */, 1));
601
- });
602
-
603
- it("zero-padding", () => {
604
- const result = parse("01", "LL", referenceDate);
605
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
606
- });
607
-
608
- it("abbreviated", () => {
609
- const result = parse("Nov", "LLL", referenceDate);
610
- expect(result).toEqual(new Date(1986, 10 /* Nov */, 1));
611
- });
612
-
613
- it("wide", () => {
614
- const result = parse("February", "LLLL", referenceDate);
615
- expect(result).toEqual(new Date(1986, 1 /* Feb */, 1));
616
- });
617
-
618
- it("narrow", () => {
619
- const result = parse("J", "LLLLL", referenceDate);
620
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
621
- });
622
-
623
- describe("validation", () => {
624
- const tokensToValidate: Array<
625
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
626
- > = [
627
- ["Y", "2019"],
628
- ["R", "2019"],
629
- ["Q", "1"],
630
- ["q", "1"],
631
- ["M", "1"],
632
- ["L", "1"],
633
- ["w", "1"],
634
- ["I", "1"],
635
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
636
- ["i", "1"],
637
- ["e", "1"],
638
- ["c", "1"],
639
- ["t", "512969520"],
640
- ["T", "512969520900"],
641
- ];
642
- tokensToValidate.forEach(([token, example, options]) => {
643
- it(`throws an error when L is used after ${token}`, () => {
644
- const block = () =>
645
- parse(`${example} 1`, `${token} L`, referenceDate, options);
646
- expect(block).toThrow(RangeError);
647
- expect(block).toThrow(
648
- new RegExp(
649
- `The format string mustn't contain \`${token}\` and \`L\` at the same time`,
650
- ),
651
- );
652
- });
653
- });
654
- });
655
- });
656
-
657
- describe("local week of year", () => {
658
- it("numeric", () => {
659
- const result = parse("49", "w", referenceDate);
660
- expect(result).toEqual(new Date(1986, 10 /* Nov */, 30));
661
- });
662
-
663
- it("ordinal", () => {
664
- const result = parse("49th", "wo", referenceDate);
665
- expect(result).toEqual(new Date(1986, 10 /* Nov */, 30));
666
- });
667
-
668
- it("zero-padding", () => {
669
- const result = parse("01", "ww", referenceDate);
670
- expect(result).toEqual(new Date(1985, 11 /* Dec */, 29));
671
- });
672
-
673
- it("allows to specify `weekStartsOn` and `firstWeekContainsDate` in options", () => {
674
- const result = parse("49", "w", referenceDate, {
675
- weekStartsOn: 1 /* Mon */,
676
- firstWeekContainsDate: 4,
677
- });
678
- expect(result).toEqual(new Date(1986, 11 /* Dec */, 1));
679
- });
680
-
681
- describe("validation", () => {
682
- const tokensToValidate: Array<
683
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
684
- > = [
685
- ["y", "2019"],
686
- ["R", "2019"],
687
- ["u", "2019"],
688
- ["Q", "1"],
689
- ["q", "1"],
690
- ["M", "1"],
691
- ["L", "1"],
692
- ["w", "1"],
693
- ["I", "1"],
694
- ["d", "1"],
695
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
696
- ["i", "1"],
697
- ["t", "512969520"],
698
- ["T", "512969520900"],
699
- ];
700
- tokensToValidate.forEach(([token, example, options]) => {
701
- it(`throws an error when w is used after ${token}`, () => {
702
- const block = () =>
703
- parse(`${example} 1`, `${token} w`, referenceDate, options);
704
- expect(block).toThrow(RangeError);
705
- expect(block).toThrow(
706
- new RegExp(
707
- `The format string mustn't contain \`${token}\` and \`w\` at the same time`,
708
- ),
709
- );
710
- });
711
- });
712
- });
713
- });
714
-
715
- describe("ISO week of year", () => {
716
- it("numeric", () => {
717
- const result = parse("49", "I", referenceDate);
718
- expect(result).toEqual(new Date(1986, 11 /* Dec */, 1));
719
- });
720
-
721
- it("ordinal", () => {
722
- const result = parse("49th", "Io", referenceDate);
723
- expect(result).toEqual(new Date(1986, 11 /* Dec */, 1));
724
- });
725
-
726
- it("zero-padding", () => {
727
- const result = parse("01", "II", referenceDate);
728
- expect(result).toEqual(new Date(1985, 11 /* Dec */, 30));
729
- });
730
-
731
- describe("validation", () => {
732
- const tokensToValidate: Array<
733
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
734
- > = [
735
- ["y", "2019"],
736
- ["Y", "2019"],
737
- ["u", "2019"],
738
- ["Q", "1"],
739
- ["q", "1"],
740
- ["M", "1"],
741
- ["L", "1"],
742
- ["w", "1"],
743
- ["I", "1"],
744
- ["d", "1"],
745
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
746
- ["e", "1"],
747
- ["c", "1"],
748
- ["t", "512969520"],
749
- ["T", "512969520900"],
750
- ];
751
- tokensToValidate.forEach(([token, example, options]) => {
752
- it(`throws an error when I is used after ${token}`, () => {
753
- const block = () =>
754
- parse(`${example} 1`, `${token} I`, referenceDate, options);
755
- expect(block).toThrow(RangeError);
756
- expect(block).toThrow(
757
- new RegExp(
758
- `The format string mustn't contain \`${token}\` and \`I\` at the same time`,
759
- ),
760
- );
761
- });
762
- });
763
- });
764
- });
765
-
766
- describe("day of month", () => {
767
- it("numeric", () => {
768
- const result = parse("28", "d", referenceDate);
769
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 28));
770
- });
771
-
772
- it("ordinal", () => {
773
- const result = parse("28th", "do", referenceDate);
774
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 28));
775
- });
776
-
777
- it("zero-padding", () => {
778
- const result = parse("01", "dd", referenceDate);
779
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
780
- });
781
-
782
- describe("validation", () => {
783
- const tokensToValidate: Array<
784
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
785
- > = [
786
- ["Y", "2019"],
787
- ["R", "2019"],
788
- ["Q", "1"],
789
- ["q", "1"],
790
- ["w", "1"],
791
- ["I", "1"],
792
- ["d", "1"],
793
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
794
- ["i", "1"],
795
- ["e", "1"],
796
- ["c", "1"],
797
- ["t", "512969520"],
798
- ["T", "512969520900"],
799
- ];
800
- tokensToValidate.forEach(([token, example, options]) => {
801
- it(`throws an error when d is used after ${token}`, () => {
802
- const block = () =>
803
- parse(`${example} 1`, `${token} d`, referenceDate, options);
804
- expect(block).toThrow(RangeError);
805
- expect(block).toThrow(
806
- new RegExp(
807
- `The format string mustn't contain \`${token}\` and \`d\` at the same time`,
808
- ),
809
- );
810
- });
811
- });
812
- });
813
- });
814
-
815
- describe("day of year", () => {
816
- it("numeric", () => {
817
- const result = parse("200", "D", referenceDate, {
818
- useAdditionalDayOfYearTokens: true,
819
- });
820
- expect(result).toEqual(new Date(1986, 6 /* Jul */, 19));
821
- });
822
-
823
- it("ordinal", () => {
824
- const result = parse("200th", "Do", referenceDate);
825
- expect(result).toEqual(new Date(1986, 6 /* Jul */, 19));
826
- });
827
-
828
- it("two-digit zero-padding", () => {
829
- const result = parse("01", "DD", referenceDate, {
830
- useAdditionalDayOfYearTokens: true,
831
- });
832
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
833
- });
834
-
835
- it("three-digit zero-padding", () => {
836
- const result = parse("001", "DDD", referenceDate);
837
- expect(result).toEqual(new Date(1986, 0 /* Jan */, 1));
838
- });
839
-
840
- it("specified amount of digits", () => {
841
- const result = parse("000200", "DDDDDD", referenceDate);
842
- expect(result).toEqual(new Date(1986, 6 /* Jul */, 19));
843
- });
844
-
845
- describe("validation", () => {
846
- [
847
- ["Y", "2019"],
848
- ["R", "2019"],
849
- ["Q", "1"],
850
- ["q", "1"],
851
- ["M", "1"],
852
- ["L", "1"],
853
- ["w", "1"],
854
- ["I", "1"],
855
- ["d", "1"],
856
- ["D", "1"],
857
- ["E", "Mon"],
858
- ["i", "1"],
859
- ["e", "1"],
860
- ["c", "1"],
861
- ["t", "512969520"],
862
- ["T", "512969520900"],
863
- ].forEach(([token, example, _options]) => {
864
- it(`throws an error when D is used after ${token}`, () => {
865
- const block = () =>
866
- parse(`${example} 1`, `${token} D`, referenceDate, {
867
- useAdditionalDayOfYearTokens: true,
868
- });
869
- expect(block).toThrow(RangeError);
870
- expect(block).toThrow(
871
- new RegExp(
872
- `The format string mustn't contain \`${token}\` and \`D\` at the same time`,
873
- ),
874
- );
875
- });
876
- });
877
- });
878
- });
879
-
880
- describe("day of week (formatting)", () => {
881
- it("abbreviated", () => {
882
- const result = parse("Mon", "E", referenceDate);
883
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
884
- });
885
-
886
- it("wide", () => {
887
- const result = parse("Tuesday", "EEEE", referenceDate);
888
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
889
- });
890
-
891
- it("narrow", () => {
892
- const result = parse("W", "EEEEE", referenceDate);
893
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 2));
894
- });
895
-
896
- it("short", () => {
897
- const result = parse("Th", "EEEEEE", referenceDate);
898
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 3));
899
- });
900
-
901
- it("allows to specify which day is the first day of the week", () => {
902
- const result = parse("Thursday", "EEEE", referenceDate, {
903
- weekStartsOn: /* Fri */ 5,
904
- });
905
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 10));
906
- });
907
-
908
- describe("validation", () => {
909
- const tokensToValidate: Array<
910
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
911
- > = [
912
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
913
- ["E", "Mon"],
914
- ["i", "1"],
915
- ["e", "1"],
916
- ["c", "1"],
917
- ["t", "512969520"],
918
- ["T", "512969520900"],
919
- ];
920
- tokensToValidate.forEach(([token, example, options]) => {
921
- it(`throws an error when E is used after ${token}`, () => {
922
- const block = () =>
923
- parse(`${example} Mon`, `${token} E`, referenceDate, options);
924
- expect(block).toThrow(RangeError);
925
- expect(block).toThrow(
926
- new RegExp(
927
- `The format string mustn't contain \`${token}\` and \`E\` at the same time`,
928
- ),
929
- );
930
- });
931
- });
932
- });
933
- });
934
-
935
- describe("ISO day of week (formatting)", () => {
936
- it("numeric", () => {
937
- const result = parse("1", "i", referenceDate);
938
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
939
- });
940
-
941
- it("ordinal", () => {
942
- const result = parse("1st", "io", referenceDate);
943
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
944
- });
945
-
946
- it("zero-padding", () => {
947
- const result = parse("02", "ii", referenceDate);
948
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
949
- });
950
-
951
- it("abbreviated", () => {
952
- const result = parse("Wed", "iii", referenceDate);
953
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 2));
954
- });
955
-
956
- it("wide", () => {
957
- const result = parse("Thursday", "iiii", referenceDate);
958
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 3));
959
- });
960
-
961
- it("narrow", () => {
962
- const result = parse("S", "iiiii", referenceDate);
963
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 6));
964
- });
965
-
966
- it("short", () => {
967
- const result = parse("Fr", "iiiiii", referenceDate);
968
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4));
969
- });
970
-
971
- describe("validation", () => {
972
- const tokensToValidate: Array<
973
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
974
- > = [
975
- ["y", "2019"],
976
- ["Y", "2019"],
977
- ["u", "2019"],
978
- ["Q", "1"],
979
- ["q", "1"],
980
- ["M", "1"],
981
- ["L", "1"],
982
- ["w", "1"],
983
- ["d", "1"],
984
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
985
- ["E", "Mon"],
986
- ["i", "1"],
987
- ["e", "1"],
988
- ["c", "1"],
989
- ["t", "512969520"],
990
- ["T", "512969520900"],
991
- ];
992
- tokensToValidate.forEach(([token, example, options]) => {
993
- it(`throws an error when i is used after ${token}`, () => {
994
- const block = () =>
995
- parse(`${example} 1`, `${token} i`, referenceDate, options);
996
- expect(block).toThrow(RangeError);
997
- expect(block).toThrow(
998
- new RegExp(
999
- `The format string mustn't contain \`${token}\` and \`i\` at the same time`,
1000
- ),
1001
- );
1002
- });
1003
- });
1004
- });
1005
- });
1006
-
1007
- describe("local day of week (formatting)", () => {
1008
- it("numeric", () => {
1009
- const result = parse("2", "e", referenceDate);
1010
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
1011
- });
1012
-
1013
- it("ordinal", () => {
1014
- const result = parse("2nd", "eo", referenceDate);
1015
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
1016
- });
1017
-
1018
- it("zero-padding", () => {
1019
- const result = parse("03", "ee", referenceDate);
1020
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
1021
- });
1022
-
1023
- it("abbreviated", () => {
1024
- const result = parse("Wed", "eee", referenceDate);
1025
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 2));
1026
- });
1027
-
1028
- it("wide", () => {
1029
- const result = parse("Thursday", "eeee", referenceDate);
1030
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 3));
1031
- });
1032
-
1033
- it("narrow", () => {
1034
- const result = parse("S", "eeeee", referenceDate);
1035
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 30));
1036
- });
1037
-
1038
- it("short", () => {
1039
- const result = parse("Fr", "eeeeee", referenceDate);
1040
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4));
1041
- });
1042
-
1043
- it("allows to specify which day is the first day of the week", () => {
1044
- const result = parse("7th", "eo", referenceDate, {
1045
- weekStartsOn: /* Fri */ 5,
1046
- });
1047
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 10));
1048
- });
1049
-
1050
- describe("validation", () => {
1051
- const tokensToValidate: Array<
1052
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
1053
- > = [
1054
- ["y", "2019"],
1055
- ["R", "2019"],
1056
- ["u", "2019"],
1057
- ["Q", "1"],
1058
- ["q", "1"],
1059
- ["M", "1"],
1060
- ["L", "1"],
1061
- ["I", "1"],
1062
- ["d", "1"],
1063
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
1064
- ["E", "Mon"],
1065
- ["i", "1"],
1066
- ["e", "1"],
1067
- ["c", "1"],
1068
- ["t", "512969520"],
1069
- ["T", "512969520900"],
1070
- ];
1071
- tokensToValidate.forEach(([token, example, options]) => {
1072
- it(`throws an error when e is used after ${token}`, () => {
1073
- const block = () =>
1074
- parse(`${example} 1`, `${token} e`, referenceDate, options);
1075
- expect(block).toThrow(RangeError);
1076
- expect(block).toThrow(
1077
- new RegExp(
1078
- `The format string mustn't contain \`${token}\` and \`e\` at the same time`,
1079
- ),
1080
- );
1081
- });
1082
- });
1083
- });
1084
- });
1085
-
1086
- describe("local day of week (stand-alone)", () => {
1087
- it("numeric", () => {
1088
- const result = parse("2", "c", referenceDate);
1089
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
1090
- });
1091
-
1092
- it("ordinal", () => {
1093
- const result = parse("2nd", "co", referenceDate);
1094
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 31));
1095
- });
1096
-
1097
- it("zero-padding", () => {
1098
- const result = parse("03", "cc", referenceDate);
1099
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 1));
1100
- });
1101
-
1102
- it("abbreviated", () => {
1103
- const result = parse("Wed", "ccc", referenceDate);
1104
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 2));
1105
- });
1106
-
1107
- it("wide", () => {
1108
- const result = parse("Thursday", "cccc", referenceDate);
1109
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 3));
1110
- });
1111
-
1112
- it("narrow", () => {
1113
- const result = parse("S", "ccccc", referenceDate);
1114
- expect(result).toEqual(new Date(1986, 2 /* Mar */, 30));
1115
- });
1116
-
1117
- it("short", () => {
1118
- const result = parse("Fr", "cccccc", referenceDate);
1119
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4));
1120
- });
1121
-
1122
- it("allows to specify which day is the first day of the week", () => {
1123
- const result = parse("7th", "co", referenceDate, {
1124
- weekStartsOn: /* Fri */ 5,
1125
- });
1126
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 10));
1127
- });
1128
-
1129
- describe("validation", () => {
1130
- const tokensToValidate: Array<
1131
- [string, string, { useAdditionalDayOfYearTokens: boolean }?]
1132
- > = [
1133
- ["y", "2019"],
1134
- ["R", "2019"],
1135
- ["u", "2019"],
1136
- ["Q", "1"],
1137
- ["q", "1"],
1138
- ["M", "1"],
1139
- ["L", "1"],
1140
- ["I", "1"],
1141
- ["d", "1"],
1142
- ["D", "1", { useAdditionalDayOfYearTokens: true }],
1143
- ["E", "Mon"],
1144
- ["i", "1"],
1145
- ["e", "1"],
1146
- ["c", "1"],
1147
- ["t", "512969520"],
1148
- ["T", "512969520900"],
1149
- ];
1150
- tokensToValidate.forEach(([token, example, options]) => {
1151
- it(`throws an error when c is used after ${token}`, () => {
1152
- const block = () =>
1153
- parse(`${example} 1`, `${token} c`, referenceDate, options);
1154
- expect(block).toThrow(RangeError);
1155
- expect(block).toThrow(
1156
- new RegExp(
1157
- `The format string mustn't contain \`${token}\` and \`c\` at the same time`,
1158
- ),
1159
- );
1160
- });
1161
- });
1162
- });
1163
- });
1164
-
1165
- describe("AM, PM", () => {
1166
- it("abbreviated", () => {
1167
- const result = parse("5 AM", "h a", referenceDate);
1168
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 5));
1169
- });
1170
-
1171
- it("12 AM", () => {
1172
- const result = parse("12 AM", "h aa", referenceDate);
1173
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 0));
1174
- });
1175
-
1176
- it("12 PM", () => {
1177
- const result = parse("12 PM", "h aaa", referenceDate);
1178
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1179
- });
1180
-
1181
- it("wide", () => {
1182
- const result = parse("5 p.m.", "h aaaa", referenceDate);
1183
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 17));
1184
- });
1185
-
1186
- it("narrow", () => {
1187
- const result = parse("11 a", "h aaaaa", referenceDate);
1188
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 11));
1189
- });
1190
-
1191
- describe("validation", () => {
1192
- [
1193
- ["a", "AM"],
1194
- ["b", "AM"],
1195
- ["B", "in the morning"],
1196
- ["H", "1"],
1197
- ["k", "1"],
1198
- ["t", "512969520"],
1199
- ["T", "512969520900"],
1200
- ].forEach(([token, example]) => {
1201
- it(`throws an error when a is used after ${token}`, () => {
1202
- const block = () =>
1203
- parse(`${example} AM`, `${token} a`, referenceDate);
1204
- expect(block).toThrow(RangeError);
1205
- expect(block).toThrow(
1206
- new RegExp(
1207
- `The format string mustn't contain \`${token}\` and \`a\` at the same time`,
1208
- ),
1209
- );
1210
- });
1211
- });
1212
- });
1213
- });
1214
-
1215
- describe("AM, PM, noon, midnight", () => {
1216
- it("abbreviated", () => {
1217
- const result = parse("noon", "b", referenceDate);
1218
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1219
- });
1220
-
1221
- it("wide", () => {
1222
- const result = parse("midnight", "bbbb", referenceDate);
1223
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 0));
1224
- });
1225
-
1226
- it("narrow", () => {
1227
- const result = parse("mi", "bbbbb", referenceDate);
1228
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 0));
1229
- });
1230
-
1231
- describe("validation", () => {
1232
- [
1233
- ["a", "AM"],
1234
- ["b", "AM"],
1235
- ["B", "in the morning"],
1236
- ["H", "1"],
1237
- ["k", "1"],
1238
- ["t", "512969520"],
1239
- ["T", "512969520900"],
1240
- ].forEach(([token, example]) => {
1241
- it(`throws an error when b is used after ${token}`, () => {
1242
- const block = () =>
1243
- parse(`${example} AM`, `${token} b`, referenceDate);
1244
- expect(block).toThrow(RangeError);
1245
- expect(block).toThrow(
1246
- new RegExp(
1247
- `The format string mustn't contain \`${token}\` and \`b\` at the same time`,
1248
- ),
1249
- );
1250
- });
1251
- });
1252
- });
1253
- });
1254
-
1255
- describe("flexible day period", () => {
1256
- it("abbreviated", () => {
1257
- const result = parse("2 at night", "h B", referenceDate);
1258
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 2));
1259
- });
1260
-
1261
- it("wide", () => {
1262
- const result = parse("12 in the afternoon", "h BBBB", referenceDate);
1263
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1264
- });
1265
-
1266
- it("narrow", () => {
1267
- const result = parse("5 in the evening", "h BBBBB", referenceDate);
1268
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 17));
1269
- });
1270
-
1271
- describe("validation", () => {
1272
- [
1273
- ["a", "AM"],
1274
- ["b", "AM"],
1275
- ["B", "in the morning"],
1276
- ["t", "512969520"],
1277
- ["T", "512969520900"],
1278
- ].forEach(([token, example]) => {
1279
- it(`throws an error when B is used after ${token}`, () => {
1280
- const block = () =>
1281
- parse(`${example} in the morning`, `${token} B`, referenceDate);
1282
- expect(block).toThrow(RangeError);
1283
- expect(block).toThrow(
1284
- new RegExp(
1285
- `The format string mustn't contain \`${token}\` and \`B\` at the same time`,
1286
- ),
1287
- );
1288
- });
1289
- });
1290
- });
1291
- });
1292
-
1293
- describe("hour [1-12]", () => {
1294
- it("numeric", () => {
1295
- const result = parse("1", "h", referenceDate);
1296
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 1));
1297
- });
1298
-
1299
- it("ordinal", () => {
1300
- const result = parse("1st", "ho", referenceDate);
1301
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 1));
1302
- });
1303
-
1304
- it("zero-padding", () => {
1305
- const result = parse("01", "hh", referenceDate);
1306
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 1));
1307
- });
1308
-
1309
- describe("validation", () => {
1310
- [
1311
- ["h", "1"],
1312
- ["H", "1"],
1313
- ["K", "1"],
1314
- ["k", "1"],
1315
- ["t", "512969520"],
1316
- ["T", "512969520900"],
1317
- ].forEach(([token, example]) => {
1318
- it(`throws an error when h is used after ${token}`, () => {
1319
- const block = () =>
1320
- parse(`${example} 1`, `${token} h`, referenceDate);
1321
- expect(block).toThrow(RangeError);
1322
- expect(block).toThrow(
1323
- new RegExp(
1324
- `The format string mustn't contain \`${token}\` and \`h\` at the same time`,
1325
- ),
1326
- );
1327
- });
1328
- });
1329
- });
1330
- });
1331
-
1332
- describe("hour [0-23]", () => {
1333
- it("numeric", () => {
1334
- const result = parse("12", "H", referenceDate);
1335
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1336
- });
1337
-
1338
- it("ordinal", () => {
1339
- const result = parse("12th", "Ho", referenceDate);
1340
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1341
- });
1342
-
1343
- it("zero-padding", () => {
1344
- const result = parse("00", "HH", referenceDate);
1345
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 0));
1346
- });
1347
-
1348
- describe("validation", () => {
1349
- [
1350
- ["a", "AM"],
1351
- ["b", "AM"],
1352
- ["h", "1"],
1353
- ["H", "1"],
1354
- ["K", "1"],
1355
- ["k", "1"],
1356
- ["t", "512969520"],
1357
- ["T", "512969520900"],
1358
- ].forEach(([token, example]) => {
1359
- it(`throws an error when H is used after ${token}`, () => {
1360
- const block = () =>
1361
- parse(`${example} 1`, `${token} H`, referenceDate);
1362
- expect(block).toThrow(RangeError);
1363
- expect(block).toThrow(
1364
- new RegExp(
1365
- `The format string mustn't contain \`${token}\` and \`H\` at the same time`,
1366
- ),
1367
- );
1368
- });
1369
- });
1370
- });
1371
- });
1372
-
1373
- describe("hour [0-11]", () => {
1374
- it("numeric", () => {
1375
- const result = parse("1", "K", referenceDate);
1376
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 1));
1377
- });
1378
-
1379
- it("ordinal", () => {
1380
- const result = parse("1st", "Ko", referenceDate);
1381
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 1));
1382
- });
1383
-
1384
- it("zero-padding", () => {
1385
- const result = parse("1", "KK", referenceDate);
1386
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 1));
1387
- });
1388
-
1389
- describe("validation", () => {
1390
- [
1391
- ["h", "1"],
1392
- ["H", "1"],
1393
- ["K", "1"],
1394
- ["k", "1"],
1395
- ["t", "512969520"],
1396
- ["T", "512969520900"],
1397
- ].forEach(([token, example]) => {
1398
- it(`throws an error when K is used after ${token}`, () => {
1399
- const block = () =>
1400
- parse(`${example} 1`, `${token} K`, referenceDate);
1401
- expect(block).toThrow(RangeError);
1402
- expect(block).toThrow(
1403
- new RegExp(
1404
- `The format string mustn't contain \`${token}\` and \`K\` at the same time`,
1405
- ),
1406
- );
1407
- });
1408
- });
1409
- });
1410
- });
1411
-
1412
- describe("hour [1-24]", () => {
1413
- it("numeric", () => {
1414
- const result = parse("12", "k", referenceDate);
1415
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1416
- });
1417
-
1418
- it("ordinal", () => {
1419
- const result = parse("12th", "ko", referenceDate);
1420
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 12));
1421
- });
1422
-
1423
- it("zero-padding", () => {
1424
- const result = parse("24", "kk", referenceDate);
1425
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 0));
1426
- });
1427
-
1428
- describe("validation", () => {
1429
- [
1430
- ["a", "AM"],
1431
- ["b", "AM"],
1432
- ["h", "1"],
1433
- ["H", "1"],
1434
- ["K", "1"],
1435
- ["k", "1"],
1436
- ["t", "512969520"],
1437
- ["T", "512969520900"],
1438
- ].forEach(([token, example]) => {
1439
- it(`throws an error when k is used after ${token}`, () => {
1440
- const block = () =>
1441
- parse(`${example} 1`, `${token} k`, referenceDate);
1442
- expect(block).toThrow(RangeError);
1443
- expect(block).toThrow(
1444
- new RegExp(
1445
- `The format string mustn't contain \`${token}\` and \`k\` at the same time`,
1446
- ),
1447
- );
1448
- });
1449
- });
1450
- });
1451
- });
1452
-
1453
- describe("minute", () => {
1454
- it("numeric", () => {
1455
- const result = parse("25", "m", referenceDate);
1456
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 25));
1457
- });
1458
-
1459
- it("ordinal", () => {
1460
- const result = parse("25th", "mo", referenceDate);
1461
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 25));
1462
- });
1463
-
1464
- it("zero-padding", () => {
1465
- const result = parse("05", "mm", referenceDate);
1466
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 5));
1467
- });
1468
-
1469
- describe("validation", () => {
1470
- [
1471
- ["m", "1"],
1472
- ["t", "512969520"],
1473
- ["T", "512969520900"],
1474
- ].forEach(([token, example]) => {
1475
- it(`throws an error when m is used after ${token}`, () => {
1476
- const block = () =>
1477
- parse(`${example} 1`, `${token} m`, referenceDate);
1478
- expect(block).toThrow(RangeError);
1479
- expect(block).toThrow(
1480
- new RegExp(
1481
- `The format string mustn't contain \`${token}\` and \`m\` at the same time`,
1482
- ),
1483
- );
1484
- });
1485
- });
1486
- });
1487
- });
1488
-
1489
- describe("second", () => {
1490
- it("numeric", () => {
1491
- const result = parse("25", "s", referenceDate);
1492
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 25));
1493
- });
1494
-
1495
- it("ordinal", () => {
1496
- const result = parse("25th", "so", referenceDate);
1497
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 25));
1498
- });
1499
-
1500
- it("zero-padding", () => {
1501
- const result = parse("05", "ss", referenceDate);
1502
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 5));
1503
- });
1504
-
1505
- describe("validation", () => {
1506
- [
1507
- ["s", "1"],
1508
- ["t", "512969520"],
1509
- ["T", "512969520900"],
1510
- ].forEach(([token, example]) => {
1511
- it(`throws an error when s is used after ${token}`, () => {
1512
- const block = () =>
1513
- parse(`${example} 1`, `${token} s`, referenceDate);
1514
- expect(block).toThrow(RangeError);
1515
- expect(block).toThrow(
1516
- new RegExp(
1517
- `The format string mustn't contain \`${token}\` and \`s\` at the same time`,
1518
- ),
1519
- );
1520
- });
1521
- });
1522
- });
1523
- });
1524
-
1525
- describe("fraction of second", () => {
1526
- it("1/10 of second", () => {
1527
- const result = parse("1", "S", referenceDate);
1528
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 100));
1529
- });
1530
-
1531
- it("1/100 of second", () => {
1532
- const result = parse("12", "SS", referenceDate);
1533
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 120));
1534
- });
1535
-
1536
- it("millisecond", () => {
1537
- const result = parse("123", "SSS", referenceDate);
1538
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 123));
1539
- });
1540
-
1541
- it("specified amount of digits", () => {
1542
- const result = parse("567890", "SSSSSS", referenceDate);
1543
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 567));
1544
- });
1545
-
1546
- describe("validation", () => {
1547
- [
1548
- ["S", "1"],
1549
- ["t", "512969520"],
1550
- ["T", "512969520900"],
1551
- ].forEach(([token, example]) => {
1552
- it(`throws an error when S is used after ${token}`, () => {
1553
- const block = () =>
1554
- parse(`${example} 1`, `${token} S`, referenceDate);
1555
- expect(block).toThrow(RangeError);
1556
- expect(block).toThrow(
1557
- new RegExp(
1558
- `The format string mustn't contain \`${token}\` and \`S\` at the same time`,
1559
- ),
1560
- );
1561
- });
1562
- });
1563
- });
1564
- });
1565
-
1566
- describe("timezone (ISO-8601 w/ Z)", () => {
1567
- describe("X", () => {
1568
- it("hours and minutes", () => {
1569
- const result = parse(
1570
- "2016-11-25T16:38:38.123-0530",
1571
- "yyyy-MM-dd'T'HH:mm:ss.SSSX",
1572
- referenceDate,
1573
- );
1574
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1575
- });
1576
-
1577
- it("GMT", () => {
1578
- const result = parse(
1579
- "2016-11-25T16:38:38.123Z",
1580
- "yyyy-MM-dd'T'HH:mm:ss.SSSX",
1581
- referenceDate,
1582
- );
1583
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1584
- });
1585
-
1586
- it("hours", () => {
1587
- const result = parse(
1588
- "2016-11-25T16:38:38.123+05",
1589
- "yyyy-MM-dd'T'HH:mm:ss.SSSX",
1590
- referenceDate,
1591
- );
1592
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123+05:00"));
1593
- });
1594
- });
1595
-
1596
- describe("XX", () => {
1597
- it("hours and minutes", () => {
1598
- const result = parse(
1599
- "2016-11-25T16:38:38.123-0530",
1600
- "yyyy-MM-dd'T'HH:mm:ss.SSSXX",
1601
- referenceDate,
1602
- );
1603
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1604
- });
1605
-
1606
- it("GMT", () => {
1607
- const result = parse(
1608
- "2016-11-25T16:38:38.123Z",
1609
- "yyyy-MM-dd'T'HH:mm:ss.SSSXX",
1610
- referenceDate,
1611
- );
1612
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1613
- });
1614
- });
1615
-
1616
- describe("XXX", () => {
1617
- it("hours and minutes", () => {
1618
- const result = parse(
1619
- "2016-11-25T16:38:38.123-05:30",
1620
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
1621
- referenceDate,
1622
- );
1623
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1624
- });
1625
-
1626
- it("GMT", () => {
1627
- const result = parse(
1628
- "2016-11-25T16:38:38.123Z",
1629
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
1630
- referenceDate,
1631
- );
1632
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1633
- });
1634
- });
1635
-
1636
- describe("XXXX", () => {
1637
- it("hours and minutes", () => {
1638
- const result = parse(
1639
- "2016-11-25T16:38:38.123-0530",
1640
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXXX",
1641
- referenceDate,
1642
- );
1643
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1644
- });
1645
-
1646
- it("GMT", () => {
1647
- const result = parse(
1648
- "2016-11-25T16:38:38.123Z",
1649
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXXX",
1650
- referenceDate,
1651
- );
1652
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1653
- });
1654
-
1655
- it("hours, minutes and seconds", () => {
1656
- const result = parse(
1657
- "2016-11-25T16:38:38.123+053045",
1658
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXXX",
1659
- referenceDate,
1660
- );
1661
- expect(result).toEqual(new Date("2016-11-25T16:37:53.123+05:30"));
1662
- });
1663
- });
1664
-
1665
- describe("XXXXX", () => {
1666
- it("hours and minutes", () => {
1667
- const result = parse(
1668
- "2016-11-25T16:38:38.123-05:30",
1669
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX",
1670
- referenceDate,
1671
- );
1672
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1673
- });
1674
-
1675
- it("GMT", () => {
1676
- const result = parse(
1677
- "2016-11-25T16:38:38.123Z",
1678
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX",
1679
- referenceDate,
1680
- );
1681
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1682
- });
1683
-
1684
- it("hours, minutes and seconds", () => {
1685
- const result = parse(
1686
- "2016-11-25T16:38:38.123+05:30:45",
1687
- "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX",
1688
- referenceDate,
1689
- );
1690
- expect(result).toEqual(new Date("2016-11-25T16:37:53.123+05:30"));
1691
- });
1692
- });
1693
-
1694
- describe("validation", () => {
1695
- [
1696
- ["X", "-0530"],
1697
- ["x", "-0530"],
1698
- ["t", "512969520"],
1699
- ["T", "512969520900"],
1700
- ].forEach(([token, example]) => {
1701
- it(`throws an error when X is used after ${token}`, () => {
1702
- const block = () =>
1703
- parse(`${example} -0530`, `${token} X`, referenceDate);
1704
- expect(block).toThrow(RangeError);
1705
- expect(block).toThrow(
1706
- new RegExp(
1707
- `The format string mustn't contain \`${token}\` and \`X\` at the same time`,
1708
- ),
1709
- );
1710
- });
1711
- });
1712
- });
1713
- });
1714
-
1715
- describe("timezone (ISO-8601 w/o Z)", () => {
1716
- describe("x", () => {
1717
- it("hours and minutes", () => {
1718
- const result = parse(
1719
- "2016-11-25T16:38:38.123-0530",
1720
- "yyyy-MM-dd'T'HH:mm:ss.SSSx",
1721
- referenceDate,
1722
- );
1723
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1724
- });
1725
-
1726
- it("GMT", () => {
1727
- const result = parse(
1728
- "2016-11-25T16:38:38.123+0000",
1729
- "yyyy-MM-dd'T'HH:mm:ss.SSSx",
1730
- referenceDate,
1731
- );
1732
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1733
- });
1734
-
1735
- it("hours", () => {
1736
- const result = parse(
1737
- "2016-11-25T16:38:38.123+05",
1738
- "yyyy-MM-dd'T'HH:mm:ss.SSSx",
1739
- referenceDate,
1740
- );
1741
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123+05:00"));
1742
- });
1743
- });
1744
-
1745
- describe("xx", () => {
1746
- it("hours and minutes", () => {
1747
- const result = parse(
1748
- "2016-11-25T16:38:38.123-0530",
1749
- "yyyy-MM-dd'T'HH:mm:ss.SSSxx",
1750
- referenceDate,
1751
- );
1752
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1753
- });
1754
-
1755
- it("GMT", () => {
1756
- const result = parse(
1757
- "2016-11-25T16:38:38.123+0000",
1758
- "yyyy-MM-dd'T'HH:mm:ss.SSSxx",
1759
- referenceDate,
1760
- );
1761
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1762
- });
1763
- });
1764
-
1765
- describe("xxx", () => {
1766
- it("hours and minutes", () => {
1767
- const result = parse(
1768
- "2016-11-25T16:38:38.123-05:30",
1769
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxx",
1770
- referenceDate,
1771
- );
1772
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1773
- });
1774
-
1775
- it("GMT", () => {
1776
- const result = parse(
1777
- "2016-11-25T16:38:38.123+00:00",
1778
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxx",
1779
- referenceDate,
1780
- );
1781
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1782
- });
1783
- });
1784
-
1785
- describe("xxxx", () => {
1786
- it("hours and minutes", () => {
1787
- const result = parse(
1788
- "2016-11-25T16:38:38.123-0530",
1789
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxxx",
1790
- referenceDate,
1791
- );
1792
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1793
- });
1794
-
1795
- it("GMT", () => {
1796
- const result = parse(
1797
- "2016-11-25T16:38:38.123+0000",
1798
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxxx",
1799
- referenceDate,
1800
- );
1801
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1802
- });
1803
-
1804
- it("hours, minutes and seconds", () => {
1805
- const result = parse(
1806
- "2016-11-25T16:38:38.123+053045",
1807
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxxx",
1808
- referenceDate,
1809
- );
1810
- expect(result).toEqual(new Date("2016-11-25T16:37:53.123+05:30"));
1811
- });
1812
- });
1813
-
1814
- describe("xxxxx", () => {
1815
- it("hours and minutes", () => {
1816
- const result = parse(
1817
- "2016-11-25T16:38:38.123-05:30",
1818
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxxxx",
1819
- referenceDate,
1820
- );
1821
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123-05:30"));
1822
- });
1823
-
1824
- it("GMT", () => {
1825
- const result = parse(
1826
- "2016-11-25T16:38:38.123+00:00",
1827
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxxxx",
1828
- referenceDate,
1829
- );
1830
- expect(result).toEqual(new Date("2016-11-25T16:38:38.123Z"));
1831
- });
1832
-
1833
- it("hours, minutes and seconds", () => {
1834
- const result = parse(
1835
- "2016-11-25T16:38:38.123+05:30:45",
1836
- "yyyy-MM-dd'T'HH:mm:ss.SSSxxxxx",
1837
- referenceDate,
1838
- );
1839
- expect(result).toEqual(new Date("2016-11-25T16:37:53.123+05:30"));
1840
- });
1841
- });
1842
-
1843
- describe("validation", () => {
1844
- [
1845
- ["X", "-0530"],
1846
- ["x", "-0530"],
1847
- ["t", "512969520"],
1848
- ["T", "512969520900"],
1849
- ].forEach(([token, example]) => {
1850
- it(`throws an error when x is used after ${token}`, () => {
1851
- const block = () =>
1852
- parse(`${example} -0530`, `${token} x`, referenceDate);
1853
- expect(block).toThrow(RangeError);
1854
- expect(block).toThrow(
1855
- new RegExp(
1856
- `The format string mustn't contain \`${token}\` and \`x\` at the same time`,
1857
- ),
1858
- );
1859
- });
1860
- });
1861
- });
1862
- });
1863
-
1864
- describe("seconds timestamp", () => {
1865
- it("numeric", () => {
1866
- const result = parse("512969520", "t", referenceDate);
1867
- expect(result).toEqual(new Date(512969520000));
1868
- });
1869
-
1870
- it("specified amount of digits", () => {
1871
- const result = parse(
1872
- "00000000000512969520",
1873
- "tttttttttttttttttttt",
1874
- referenceDate,
1875
- );
1876
- expect(result).toEqual(new Date(512969520000));
1877
- });
1878
-
1879
- it(`throws an error when it is used after any token`, () => {
1880
- const block = () => parse(`1 512969520`, `h t`, referenceDate);
1881
- expect(block).toThrow(RangeError);
1882
- expect(block).toThrow(
1883
- new RegExp(
1884
- `The format string mustn't contain \`t\` and any other token at the same time`,
1885
- ),
1886
- );
1887
- });
1888
- });
1889
-
1890
- describe("milliseconds timestamp", () => {
1891
- it("numeric", () => {
1892
- const result = parse("512969520900", "T", referenceDate);
1893
- expect(result).toEqual(new Date(512969520900));
1894
- });
1895
-
1896
- it("specified amount of digits", () => {
1897
- const result = parse(
1898
- "00000000512969520900",
1899
- "TTTTTTTTTTTTTTTTTTTT",
1900
- referenceDate,
1901
- );
1902
- expect(result).toEqual(new Date(512969520900));
1903
- });
1904
-
1905
- it(`throws an error when it is used after any token`, () => {
1906
- const block = () => parse(`1 512969520900`, `h T`, referenceDate);
1907
- expect(block).toThrow(RangeError);
1908
- expect(block).toThrow(
1909
- new RegExp(
1910
- `The format string mustn't contain \`T\` and any other token at the same time`,
1911
- ),
1912
- );
1913
- });
1914
- });
1915
-
1916
- describe("common formats", () => {
1917
- it("ISO-8601", () => {
1918
- const result = parse(
1919
- "20161105T040404",
1920
- "yyyyMMdd'T'HHmmss",
1921
- referenceDate,
1922
- );
1923
- expect(result).toEqual(new Date(2016, 10 /* Nov */, 5, 4, 4, 4, 0));
1924
- });
1925
-
1926
- it("ISO week-numbering date", () => {
1927
- const result = parse(
1928
- "2016W474T153005",
1929
- "RRRR'W'IIi'T'HHmmss",
1930
- referenceDate,
1931
- );
1932
- expect(result).toEqual(new Date(2016, 10 /* Nov */, 24, 15, 30, 5, 0));
1933
- });
1934
-
1935
- it("ISO day of year date", () => {
1936
- const result = parse("2010123T235959", "yyyyDDD'T'HHmmss", referenceDate);
1937
- expect(result).toEqual(new Date(2010, 4 /* May */, 3, 23, 59, 59, 0));
1938
- });
1939
-
1940
- it("Date.prototype.toString()", () => {
1941
- const dateString = "Wed Jul 02 2014 05:30:15 GMT+0600";
1942
- const formatString = "EEE MMM dd yyyy HH:mm:ss 'GMT'xx";
1943
- const result = parse(dateString, formatString, referenceDate);
1944
- expect(result).toEqual(new Date(dateString));
1945
- });
1946
-
1947
- it("Date.prototype.toISOString()", () => {
1948
- const dateString = "2014-07-02T05:30:15.123+06:00";
1949
- const formatString = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx";
1950
- const result = parse(dateString, formatString, referenceDate);
1951
- expect(result).toEqual(new Date(dateString));
1952
- });
1953
-
1954
- it("middle-endian", () => {
1955
- const result = parse(
1956
- "5 a.m. 07/02/2016",
1957
- "h aaaa MM/dd/yyyy",
1958
- referenceDate,
1959
- );
1960
- expect(result).toEqual(new Date(2016, 6 /* Jul */, 2, 5, 0, 0, 0));
1961
- });
1962
-
1963
- it("little-endian", () => {
1964
- const result = parse("02.07.1995", "dd.MM.yyyy", referenceDate);
1965
- expect(result).toEqual(new Date(1995, 6 /* Jul */, 2, 0, 0, 0, 0));
1966
- });
1967
- });
1968
-
1969
- describe("priority", () => {
1970
- it("units of lower priority don't overwrite values of higher priority", () => {
1971
- const dateString = "+06:00 123 15 30 05 02 07 2014";
1972
- const formatString = "xxx SSS ss mm HH dd MM yyyy";
1973
- const result = parse(dateString, formatString, referenceDate);
1974
- expect(result).toEqual(new Date("2014-07-02T05:30:15.123+06:00"));
1975
- });
1976
- });
1977
-
1978
- describe("with `options.strictValidation` = true", () => {
1979
- describe("calendar year", () => {
1980
- it("returns `Invalid Date` for year zero", () => {
1981
- const result = parse("0", "y", referenceDate);
1982
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
1983
- });
1984
-
1985
- it("works correctly for two-digit year zero", () => {
1986
- const result = parse("00", "yy", referenceDate);
1987
- expect(result).toEqual(new Date(2000, 0 /* Jan */, 1));
1988
- });
1989
- });
1990
-
1991
- describe("local week-numbering year", () => {
1992
- it("returns `Invalid Date` for year zero", () => {
1993
- const result = parse("0", "Y", referenceDate);
1994
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
1995
- });
1996
-
1997
- it("works correctly for two-digit year zero", () => {
1998
- const result = parse("00", "YY", referenceDate, {
1999
- useAdditionalWeekYearTokens: true,
2000
- });
2001
- expect(result).toEqual(new Date(1999, 11 /* Dec */, 26));
2002
- });
2003
- });
2004
-
2005
- describe("quarter (formatting)", () => {
2006
- it("returns `Invalid Date` for invalid quarter", () => {
2007
- const result = parse("0", "Q", referenceDate);
2008
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2009
- });
2010
- });
2011
-
2012
- describe("quarter (stand-alone)", () => {
2013
- it("returns `Invalid Date` for invalid quarter", () => {
2014
- const result = parse("5", "q", referenceDate);
2015
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2016
- });
2017
- });
2018
-
2019
- describe("month (formatting)", () => {
2020
- it("returns `Invalid Date` for invalid month", () => {
2021
- const result = parse("00", "MM", referenceDate);
2022
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2023
- });
2024
- });
2025
-
2026
- describe("month (stand-alone)", () => {
2027
- it("returns `Invalid Date` for invalid month", () => {
2028
- const result = parse("13", "LL", referenceDate);
2029
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2030
- });
2031
- });
2032
-
2033
- describe("local week of year", () => {
2034
- it("returns `Invalid Date` for invalid week", () => {
2035
- const result = parse("0", "w", referenceDate);
2036
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2037
- });
2038
- });
2039
-
2040
- describe("ISO week of year", () => {
2041
- it("returns `Invalid Date` for invalid week", () => {
2042
- const result = parse("54", "II", referenceDate);
2043
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2044
- });
2045
- });
2046
-
2047
- describe("day of month", () => {
2048
- it("returns `Invalid Date` for invalid day of the month", () => {
2049
- const result = parse("30", "d", new Date(2012, 1 /* Feb */, 1));
2050
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2051
- });
2052
-
2053
- it("returns `Invalid Date` for 29th of February of non-leap year", () => {
2054
- const result = parse("29", "d", new Date(2014, 1 /* Feb */, 1));
2055
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2056
- });
2057
-
2058
- it("parses 29th of February of leap year", () => {
2059
- const result = parse("29", "d", new Date(2012, 1 /* Feb */, 1));
2060
- expect(result).toEqual(new Date(2012, 1 /* Feb */, 29));
2061
- });
2062
- });
2063
-
2064
- describe("day of year", () => {
2065
- it("returns `Invalid Date` for invalid day of the year", () => {
2066
- const result = parse("0", "D", referenceDate, {
2067
- useAdditionalDayOfYearTokens: true,
2068
- });
2069
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2070
- });
2071
-
2072
- it("returns `Invalid Date` for 366th day of non-leap year", () => {
2073
- const result = parse("366", "D", new Date(2014, 1 /* Feb */, 1), {
2074
- useAdditionalDayOfYearTokens: true,
2075
- });
2076
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2077
- });
2078
-
2079
- it("parses 366th day of leap year", () => {
2080
- const result = parse("366", "D", new Date(2012, 1 /* Feb */, 1), {
2081
- useAdditionalDayOfYearTokens: true,
2082
- });
2083
- expect(result).toEqual(new Date(2012, 11 /* Dec */, 31));
2084
- });
2085
- });
2086
-
2087
- describe("ISO day of week (formatting)", () => {
2088
- it("returns `Invalid Date` for day zero", () => {
2089
- const result = parse("0", "i", referenceDate);
2090
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2091
- });
2092
-
2093
- it("returns `Invalid Date` for eight day of week", () => {
2094
- const result = parse("8", "i", referenceDate);
2095
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2096
- });
2097
- });
2098
-
2099
- describe("local day of week (formatting)", () => {
2100
- it("returns `Invalid Date` for day zero", () => {
2101
- const result = parse("0", "e", referenceDate);
2102
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2103
- });
2104
-
2105
- it("returns `Invalid Date` for eight day of week", () => {
2106
- const result = parse("8", "e", referenceDate);
2107
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2108
- });
2109
- });
2110
-
2111
- describe("local day of week (stand-alone)", () => {
2112
- it("returns `Invalid Date` for day zero", () => {
2113
- const result = parse("0", "c", referenceDate);
2114
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2115
- });
2116
-
2117
- it("returns `Invalid Date` for eight day of week", () => {
2118
- const result = parse("8", "c", referenceDate);
2119
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2120
- });
2121
- });
2122
-
2123
- describe("hour [1-12]", () => {
2124
- it("returns `Invalid Date` for hour zero", () => {
2125
- const result = parse("00", "hh", referenceDate);
2126
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2127
- });
2128
-
2129
- it("returns `Invalid Date` for invalid hour", () => {
2130
- const result = parse("13", "hh", referenceDate);
2131
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2132
- });
2133
- });
2134
-
2135
- describe("hour [0-23]", () => {
2136
- it("returns `Invalid Date` for invalid hour", () => {
2137
- const result = parse("24", "HH", referenceDate);
2138
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2139
- });
2140
- });
2141
-
2142
- describe("hour [0-11]", () => {
2143
- it("returns `Invalid Date` for invalid hour", () => {
2144
- const result = parse("12", "KK", referenceDate);
2145
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2146
- });
2147
- });
2148
-
2149
- describe("hour [1-24]", () => {
2150
- it("returns `Invalid Date` for hour zero", () => {
2151
- const result = parse("00", "kk", referenceDate);
2152
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2153
- });
2154
-
2155
- it("returns `Invalid Date` for invalid hour", () => {
2156
- const result = parse("25", "kk", referenceDate);
2157
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2158
- });
2159
- });
2160
-
2161
- describe("minute", () => {
2162
- it("returns `Invalid Date` for invalid minute", () => {
2163
- const result = parse("60", "mm", referenceDate);
2164
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2165
- });
2166
- });
2167
-
2168
- describe("second", () => {
2169
- it("returns `Invalid Date` for invalid second", () => {
2170
- const result = parse("60", "ss", referenceDate);
2171
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2172
- });
2173
- });
2174
- });
2175
-
2176
- describe("custom locale", () => {
2177
- it("allows to pass a custom locale", () => {
2178
- const customLocale = {
2179
- match: {
2180
- era: () => {
2181
- return {
2182
- value: 0,
2183
- rest: " it works!",
2184
- };
2185
- },
2186
- },
2187
- };
2188
- const result = parse("2018 foobar", "y G 'it works!'", referenceDate, {
2189
- // @ts-expect-error - It's oke to have incomplete locale
2190
- locale: customLocale,
2191
- });
2192
- expect(result).toEqual(new Date(-2017, 0 /* Jan */, 1));
2193
- });
2194
- });
2195
-
2196
- it("accepts a timestamp as `referenceDate`", () => {
2197
- const dateString = "6 p.m.";
2198
- const formatString = "h aaaa";
2199
- const result = parse(dateString, formatString, referenceDate.getTime());
2200
- expect(result).toEqual(new Date(1986, 3 /* Apr */, 4, 18));
2201
- });
2202
-
2203
- it("does not mutate `referenceDate`", () => {
2204
- const referenceDateClone1 = new Date(referenceDate.getTime());
2205
- const referenceDateClone2 = new Date(referenceDate.getTime());
2206
- const dateString = "6 p.m.";
2207
- const formatString = "h aaaa";
2208
- parse(dateString, formatString, referenceDateClone1);
2209
- expect(referenceDateClone1).toEqual(referenceDateClone2);
2210
- });
2211
-
2212
- describe("failure", () => {
2213
- it("returns `referenceDate` if `dateString` and `formatString` are empty strings", () => {
2214
- const dateString = "";
2215
- const formatString = "";
2216
- const result = parse(dateString, formatString, referenceDate);
2217
- expect(result).toEqual(referenceDate);
2218
- });
2219
-
2220
- it("returns `referenceDate` if no tokens in `formatString` are provided", () => {
2221
- const dateString = "not a token";
2222
- const formatString = "'not a token'";
2223
- const result = parse(dateString, formatString, referenceDate);
2224
- expect(result).toEqual(referenceDate);
2225
- });
2226
-
2227
- it("returns `Invalid Date` if `formatString` doesn't match `dateString`", () => {
2228
- const dateString = "2017-01-01";
2229
- const formatString = "yyyy/MM/dd";
2230
- const result = parse(dateString, formatString, referenceDate);
2231
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2232
- });
2233
-
2234
- it("returns `Invalid Date` if `formatString` tokens failed to parse a value", () => {
2235
- const dateString = "2017-01-01";
2236
- const formatString = "MMMM do yyyy";
2237
- const result = parse(dateString, formatString, referenceDate);
2238
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2239
- });
2240
-
2241
- it("returns `Invalid Date` if `formatString` is empty string but `dateString` is not", () => {
2242
- const dateString = "2017-01-01";
2243
- const formatString = "";
2244
- const result = parse(dateString, formatString, referenceDate);
2245
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2246
- });
2247
-
2248
- it("returns `Invalid Date` if `referenceDate` is `Invalid Date`", () => {
2249
- const dateString = "2014-07-02T05:30:15.123+06:00";
2250
- const formatString = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx";
2251
- const result = parse(dateString, formatString, new Date(NaN));
2252
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2253
- });
2254
- });
2255
-
2256
- describe("edge cases", () => {
2257
- it("returns Invalid Date if the string contains some remaining input after parsing", () => {
2258
- const result = parse("2016-11-05T040404", "yyyy-MM-dd", referenceDate);
2259
- expect(result instanceof Date && isNaN(result.getTime())).toBe(true);
2260
- });
2261
-
2262
- it("parses normally if the remaining input is just whitespace", () => {
2263
- const result = parse("2016-11-05 \n", "yyyy-MM-dd", referenceDate);
2264
- expect(result).toEqual(new Date(2016, 10 /* Nov */, 5));
2265
- });
2266
-
2267
- it("throws RangeError exception if the format string contains an unescaped latin alphabet character", () => {
2268
- expect(() =>
2269
- parse("2016-11-05-nnnn", "yyyy-MM-dd-nnnn", referenceDate),
2270
- ).toThrow(RangeError);
2271
- });
2272
- });
2273
-
2274
- describe("useAdditionalWeekYearTokens and useAdditionalDayOfYearTokens options", () => {
2275
- it("throws an error if D token is used", () => {
2276
- try {
2277
- parse("2016 5", "yyyy D", referenceDate);
2278
- } catch (e) {
2279
- expect(
2280
- e instanceof RangeError &&
2281
- e.message.startsWith("Use `d` instead of `D`"),
2282
- ).toBe(true);
2283
- }
2284
- });
2285
-
2286
- it("allows D token if useAdditionalDayOfYearTokens is set to true", () => {
2287
- const result = parse("2016 5", "yyyy D", referenceDate, {
2288
- useAdditionalDayOfYearTokens: true,
2289
- });
2290
- expect(result).toEqual(new Date(2016, 0, 5));
2291
- });
2292
-
2293
- it("throws an error if DD token is used", () => {
2294
- try {
2295
- parse("2016 05", "yyyy DD", referenceDate);
2296
- } catch (e) {
2297
- expect(
2298
- e instanceof RangeError &&
2299
- e.message.startsWith("Use `dd` instead of `DD`"),
2300
- ).toBe(true);
2301
- }
2302
- });
2303
-
2304
- it("allows DD token if useAdditionalDayOfYearTokens is set to true", () => {
2305
- const result = parse("2016 05", "yyyy DD", referenceDate, {
2306
- useAdditionalDayOfYearTokens: true,
2307
- });
2308
- expect(result).toEqual(new Date(2016, 0, 5));
2309
- });
2310
-
2311
- it("throws an error if YY token is used", () => {
2312
- try {
2313
- parse("16 1", "YY w", referenceDate);
2314
- } catch (e) {
2315
- expect(
2316
- e instanceof RangeError &&
2317
- e.message.startsWith("Use `yy` instead of `YY`"),
2318
- ).toBe(true);
2319
- }
2320
- });
2321
-
2322
- it("allows YY token if useAdditionalWeekYearTokens is set to true", () => {
2323
- const result = parse("16 1", "YY w", referenceDate, {
2324
- useAdditionalWeekYearTokens: true,
2325
- });
2326
- expect(result).toEqual(new Date(2015, 11, 27));
2327
- });
2328
-
2329
- it("throws an error if YYYY token is used", () => {
2330
- try {
2331
- parse("2016 1", "YYYY w", referenceDate);
2332
- } catch (e) {
2333
- expect(
2334
- e instanceof RangeError &&
2335
- e.message.startsWith("Use `yyyy` instead of `YYYY`"),
2336
- ).toBe(true);
2337
- }
2338
- });
2339
-
2340
- it("allows YYYY token if useAdditionalWeekYearTokens is set to true", () => {
2341
- const result = parse("2016 1", "YYYY w", referenceDate, {
2342
- useAdditionalWeekYearTokens: true,
2343
- });
2344
- expect(result).toEqual(new Date(2015, 11, 27));
2345
- });
2346
- });
2347
-
2348
- describe("long format", () => {
2349
- it("short date", () => {
2350
- const expected = new Date(1995, 4 /* May */, 26);
2351
- const dateString = "05/26/1995";
2352
- const formatString = "P";
2353
- const result = parse(dateString, formatString, referenceDate);
2354
- expect(result).toEqual(expected);
2355
- });
2356
-
2357
- it("medium date", () => {
2358
- const expected = new Date(1995, 4 /* May */, 26);
2359
- const dateString = "May 26, 1995";
2360
- const formatString = "PP";
2361
- const result = parse(dateString, formatString, referenceDate);
2362
- expect(result).toEqual(expected);
2363
- });
2364
-
2365
- it("long date", () => {
2366
- const expected = new Date(1995, 4 /* May */, 26);
2367
- const dateString = "May 26th, 1995";
2368
- const formatString = "PPP";
2369
- const result = parse(dateString, formatString, referenceDate);
2370
- expect(result).toEqual(expected);
2371
- });
2372
-
2373
- it("full date", () => {
2374
- const expected = new Date(1995, 4 /* May */, 26);
2375
- const dateString = "Friday, May 26th, 1995";
2376
- const formatString = "PPPP";
2377
- const result = parse(dateString, formatString, referenceDate);
2378
- expect(result).toEqual(expected);
2379
- });
2380
-
2381
- it("short time", () => {
2382
- const expected = new Date(
2383
- referenceDate.getFullYear(),
2384
- referenceDate.getMonth(),
2385
- referenceDate.getDate(),
2386
- 10,
2387
- 32,
2388
- );
2389
- const timeString = "10:32 AM";
2390
- const formatString = "p";
2391
- const result = parse(timeString, formatString, referenceDate);
2392
- expect(result).toEqual(expected);
2393
- });
2394
-
2395
- it("medium time", () => {
2396
- const expected = new Date(
2397
- referenceDate.getFullYear(),
2398
- referenceDate.getMonth(),
2399
- referenceDate.getDate(),
2400
- 10,
2401
- 32,
2402
- 55,
2403
- );
2404
- const timeString = "10:32:55 AM";
2405
- const formatString = "pp";
2406
- const result = parse(timeString, formatString, referenceDate);
2407
- expect(result).toEqual(expected);
2408
- });
2409
-
2410
- it("short date + short time", () => {
2411
- const expected = new Date(1995, 4 /* May */, 26, 10, 32);
2412
- const dateTimeString = "05/26/1995, 10:32 AM";
2413
- const formatString = "Pp";
2414
- const result = parse(dateTimeString, formatString, referenceDate);
2415
- expect(result).toEqual(expected);
2416
- });
2417
-
2418
- it("medium date + short time", () => {
2419
- const expected = new Date(1995, 4 /* May */, 26, 10, 32);
2420
- const dateTimeString = "May 26, 1995, 10:32 AM";
2421
- const formatString = "PPp";
2422
- const result = parse(dateTimeString, formatString, referenceDate);
2423
- expect(result).toEqual(expected);
2424
- });
2425
-
2426
- it("long date + short time", () => {
2427
- const expected = new Date(1995, 4 /* May */, 26, 10, 32);
2428
- const dateTimeString = "May 26th, 1995 at 10:32 AM";
2429
- const formatString = "PPPp";
2430
- const result = parse(dateTimeString, formatString, referenceDate);
2431
- expect(result).toEqual(expected);
2432
- });
2433
-
2434
- it("full date + short time", () => {
2435
- const expected = new Date(1995, 4 /* May */, 26, 10, 32);
2436
- const dateTimeString = "Friday, May 26th, 1995 at 10:32 AM";
2437
- const formatString = "PPPPp";
2438
- const result = parse(dateTimeString, formatString, referenceDate);
2439
- expect(result).toEqual(expected);
2440
- });
2441
-
2442
- it("short date + short time", () => {
2443
- const expected = new Date(1995, 4 /* May */, 26, 10, 32, 55);
2444
- const dateTimeString = "05/26/1995, 10:32:55 AM";
2445
- const formatString = "Ppp";
2446
- const result = parse(dateTimeString, formatString, referenceDate);
2447
- expect(result).toEqual(expected);
2448
- });
2449
-
2450
- it("medium date + short time", () => {
2451
- const expected = new Date(1995, 4 /* May */, 26, 10, 32, 55);
2452
- const dateTimeString = "May 26, 1995, 10:32:55 AM";
2453
- const formatString = "PPpp";
2454
- const result = parse(dateTimeString, formatString, referenceDate);
2455
- expect(result).toEqual(expected);
2456
- });
2457
-
2458
- it("long date + short time", () => {
2459
- const expected = new Date(1995, 4 /* May */, 26, 10, 32, 55);
2460
- const dateTimeString = "May 26th, 1995 at 10:32:55 AM";
2461
- const formatString = "PPPpp";
2462
- const result = parse(dateTimeString, formatString, referenceDate);
2463
- expect(result).toEqual(expected);
2464
- });
2465
-
2466
- it("full date + short time", () => {
2467
- const expected = new Date(1995, 4 /* May */, 26, 10, 32, 55);
2468
- const dateTimeString = "Friday, May 26th, 1995 at 10:32:55 AM";
2469
- const formatString = "PPPPpp";
2470
- const result = parse(dateTimeString, formatString, referenceDate);
2471
- expect(result).toEqual(expected);
2472
- });
2473
- });
2474
- });