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