chrono-node 2.6.3 → 2.6.5
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 +25 -3
- package/dist/cjs/calculation/mergingCalculation.js +2 -2
- package/dist/cjs/chrono.d.ts +3 -1
- package/dist/cjs/chrono.js +10 -4
- package/dist/cjs/chrono.js.map +1 -1
- package/dist/cjs/common/calculation/weekdays.d.ts +1 -1
- package/dist/cjs/common/calculation/weekdays.js +7 -7
- package/dist/cjs/common/casualReferences.js +7 -7
- package/dist/cjs/common/parsers/AbstractParserWithWordBoundary.d.ts +1 -1
- package/dist/cjs/common/parsers/AbstractTimeExpressionParser.js +16 -16
- package/dist/cjs/common/refiners/ExtractTimezoneAbbrRefiner.d.ts +1 -1
- package/dist/cjs/index.d.ts +8 -63
- package/dist/cjs/index.js +10 -31
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/locales/de/index.d.ts +5 -2
- package/dist/cjs/locales/de/index.js +9 -1
- package/dist/cjs/locales/de/index.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DECasualTimeParser.js +8 -8
- package/dist/cjs/locales/de/parsers/DESpecificTimeExpressionParser.js +9 -9
- package/dist/cjs/locales/en/configuration.d.ts +5 -0
- package/dist/cjs/locales/en/configuration.js +57 -0
- package/dist/cjs/locales/en/configuration.js.map +1 -0
- package/dist/cjs/locales/en/constants.d.ts +1 -1
- package/dist/cjs/locales/en/index.d.ts +5 -4
- package/dist/cjs/locales/en/index.js +14 -51
- package/dist/cjs/locales/en/index.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeExpressionParser.js +5 -5
- package/dist/cjs/locales/es/index.d.ts +5 -2
- package/dist/cjs/locales/es/index.js +9 -1
- package/dist/cjs/locales/es/index.js.map +1 -1
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js +5 -5
- package/dist/cjs/locales/fr/index.d.ts +5 -2
- package/dist/cjs/locales/fr/index.js +9 -1
- package/dist/cjs/locales/fr/index.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRCasualDateParser.js +2 -2
- package/dist/cjs/locales/fr/parsers/FRCasualTimeParser.js +6 -6
- package/dist/cjs/locales/fr/parsers/FRSpecificTimeExpressionParser.js +6 -6
- package/dist/cjs/locales/ja/index.d.ts +5 -2
- package/dist/cjs/locales/ja/index.js +9 -1
- package/dist/cjs/locales/ja/index.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.d.ts +1 -1
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js +27 -5
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPStandardParser.d.ts +1 -1
- package/dist/cjs/locales/nl/index.d.ts +5 -2
- package/dist/cjs/locales/nl/index.js +9 -1
- package/dist/cjs/locales/nl/index.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualDateTimeParser.js +5 -5
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js +5 -5
- package/dist/cjs/locales/nl/parsers/NLMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/nl/parsers/NLMonthNameParser.d.ts +1 -1
- package/dist/cjs/locales/pt/index.d.ts +5 -2
- package/dist/cjs/locales/pt/index.js +9 -1
- package/dist/cjs/locales/pt/index.js.map +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js +5 -5
- package/dist/cjs/locales/ru/index.d.ts +5 -2
- package/dist/cjs/locales/ru/index.js +9 -1
- package/dist/cjs/locales/ru/index.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RUCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/ru/parsers/RUMonthNameParser.d.ts +1 -1
- package/dist/cjs/locales/ru/parsers/RUTimeExpressionParser.js +5 -5
- package/dist/cjs/locales/uk/constants.d.ts +33 -0
- package/dist/cjs/locales/uk/constants.js +301 -0
- package/dist/cjs/locales/uk/constants.js.map +1 -0
- package/dist/cjs/locales/uk/index.d.ts +11 -0
- package/dist/cjs/locales/uk/index.js +66 -0
- package/dist/cjs/locales/uk/index.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.js +56 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.d.ts +7 -0
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js +77 -0
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.js +59 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.d.ts +7 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.js +45 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js +66 -0
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeExpressionParser.d.ts +12 -0
- package/dist/cjs/locales/uk/parsers/UKTimeExpressionParser.js +57 -0
- package/dist/cjs/locales/uk/parsers/UKTimeExpressionParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +22 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +29 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +22 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.js +50 -0
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.js.map +1 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateRangeRefiner.d.ts +4 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateRangeRefiner.js +13 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateRangeRefiner.js.map +1 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateTimeRefiner.d.ts +4 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateTimeRefiner.js +13 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateTimeRefiner.js.map +1 -0
- package/dist/cjs/locales/zh/hans/index.d.ts +5 -2
- package/dist/cjs/locales/zh/hans/index.js +10 -2
- package/dist/cjs/locales/zh/hans/index.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hant/index.d.ts +5 -2
- package/dist/cjs/locales/zh/hant/index.js +10 -2
- package/dist/cjs/locales/zh/hant/index.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +1 -1
- package/dist/cjs/results.d.ts +1 -1
- package/dist/cjs/timezone.d.ts +1 -1
- package/dist/cjs/timezone.js +11 -11
- package/dist/cjs/types.d.ts +58 -0
- package/dist/cjs/types.js +34 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/dayjs.js +3 -3
- package/dist/esm/calculation/mergingCalculation.js +1 -1
- package/dist/esm/chrono.d.ts +3 -1
- package/dist/esm/chrono.js +7 -4
- package/dist/esm/chrono.js.map +1 -1
- package/dist/esm/common/calculation/weekdays.d.ts +1 -1
- package/dist/esm/common/calculation/weekdays.js +1 -1
- package/dist/esm/common/casualReferences.js +1 -1
- package/dist/esm/common/parsers/AbstractParserWithWordBoundary.d.ts +1 -1
- package/dist/esm/common/parsers/AbstractTimeExpressionParser.js +1 -1
- package/dist/esm/common/refiners/ExtractTimezoneAbbrRefiner.d.ts +1 -1
- package/dist/esm/index.d.ts +8 -63
- package/dist/esm/index.js +6 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/locales/de/index.d.ts +5 -2
- package/dist/esm/locales/de/index.js +4 -0
- package/dist/esm/locales/de/index.js.map +1 -1
- package/dist/esm/locales/de/parsers/DECasualTimeParser.js +1 -1
- package/dist/esm/locales/de/parsers/DESpecificTimeExpressionParser.js +1 -1
- package/dist/esm/locales/en/configuration.d.ts +5 -0
- package/dist/esm/locales/en/configuration.js +51 -0
- package/dist/esm/locales/en/configuration.js.map +1 -0
- package/dist/esm/locales/en/constants.d.ts +1 -1
- package/dist/esm/locales/en/index.d.ts +5 -4
- package/dist/esm/locales/en/index.js +9 -48
- package/dist/esm/locales/en/index.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENTimeExpressionParser.js +1 -1
- package/dist/esm/locales/es/index.d.ts +5 -2
- package/dist/esm/locales/es/index.js +4 -0
- package/dist/esm/locales/es/index.js.map +1 -1
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.js +1 -1
- package/dist/esm/locales/fr/index.d.ts +5 -2
- package/dist/esm/locales/fr/index.js +4 -0
- package/dist/esm/locales/fr/index.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRCasualDateParser.js +1 -1
- package/dist/esm/locales/fr/parsers/FRCasualTimeParser.js +1 -1
- package/dist/esm/locales/fr/parsers/FRSpecificTimeExpressionParser.js +1 -1
- package/dist/esm/locales/ja/index.d.ts +5 -2
- package/dist/esm/locales/ja/index.js +4 -0
- package/dist/esm/locales/ja/index.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.d.ts +1 -1
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js +25 -3
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPStandardParser.d.ts +1 -1
- package/dist/esm/locales/nl/index.d.ts +5 -2
- package/dist/esm/locales/nl/index.js +4 -0
- package/dist/esm/locales/nl/index.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualDateTimeParser.js +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js +1 -1
- package/dist/esm/locales/nl/parsers/NLMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/esm/locales/nl/parsers/NLMonthNameParser.d.ts +1 -1
- package/dist/esm/locales/pt/index.d.ts +5 -2
- package/dist/esm/locales/pt/index.js +4 -0
- package/dist/esm/locales/pt/index.js.map +1 -1
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js +1 -1
- package/dist/esm/locales/ru/index.d.ts +5 -2
- package/dist/esm/locales/ru/index.js +4 -0
- package/dist/esm/locales/ru/index.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RUCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/ru/parsers/RUMonthNameParser.d.ts +1 -1
- package/dist/esm/locales/ru/parsers/RUTimeExpressionParser.js +1 -1
- package/dist/esm/locales/uk/constants.d.ts +33 -0
- package/dist/esm/locales/uk/constants.js +324 -0
- package/dist/esm/locales/uk/constants.js.map +1 -0
- package/dist/esm/locales/uk/index.d.ts +11 -0
- package/dist/esm/locales/uk/index.js +52 -0
- package/dist/esm/locales/uk/index.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.js +34 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.d.ts +7 -0
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js +52 -0
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.js +56 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.d.ts +7 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.js +42 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js +60 -0
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeExpressionParser.d.ts +12 -0
- package/dist/esm/locales/uk/parsers/UKTimeExpressionParser.js +54 -0
- package/dist/esm/locales/uk/parsers/UKTimeExpressionParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +19 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +26 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +19 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.js +47 -0
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.js.map +1 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateRangeRefiner.d.ts +4 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateRangeRefiner.js +7 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateRangeRefiner.js.map +1 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateTimeRefiner.d.ts +4 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateTimeRefiner.js +7 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateTimeRefiner.js.map +1 -0
- package/dist/esm/locales/zh/hans/index.d.ts +5 -2
- package/dist/esm/locales/zh/hans/index.js +5 -1
- package/dist/esm/locales/zh/hans/index.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.d.ts +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +1 -1
- package/dist/esm/locales/zh/hant/index.d.ts +5 -2
- package/dist/esm/locales/zh/hant/index.js +5 -1
- package/dist/esm/locales/zh/hant/index.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.d.ts +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +1 -1
- package/dist/esm/results.d.ts +1 -1
- package/dist/esm/timezone.d.ts +1 -1
- package/dist/esm/timezone.js +1 -1
- package/dist/esm/types.d.ts +58 -0
- package/dist/esm/types.js +31 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/dayjs.js +1 -1
- package/package.json +9 -1
- package/src/calculation/mergingCalculation.ts +1 -1
- package/src/chrono.ts +14 -8
- package/src/common/calculation/weekdays.ts +1 -1
- package/src/common/casualReferences.ts +1 -1
- package/src/common/parsers/AbstractParserWithWordBoundary.ts +1 -1
- package/src/common/parsers/AbstractTimeExpressionParser.ts +1 -1
- package/src/common/parsers/ISOFormatParser.ts +1 -1
- package/src/common/refiners/ExtractTimezoneAbbrRefiner.ts +3 -3
- package/src/configurations.ts +1 -1
- package/src/index.ts +7 -153
- package/src/locales/de/index.ts +6 -2
- package/src/locales/de/parsers/DECasualTimeParser.ts +1 -1
- package/src/locales/de/parsers/DESpecificTimeExpressionParser.ts +1 -1
- package/src/locales/en/configuration.ts +71 -0
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/index.ts +11 -65
- package/src/locales/en/parsers/ENTimeExpressionParser.ts +1 -1
- package/src/locales/es/index.ts +6 -2
- package/src/locales/es/parsers/ESCasualTimeParser.ts +1 -1
- package/src/locales/fr/index.ts +6 -2
- package/src/locales/fr/parsers/FRCasualDateParser.ts +1 -1
- package/src/locales/fr/parsers/FRCasualTimeParser.ts +1 -1
- package/src/locales/fr/parsers/FRSpecificTimeExpressionParser.ts +1 -1
- package/src/locales/ja/index.ts +6 -2
- package/src/locales/ja/parsers/JPCasualDateParser.ts +26 -3
- package/src/locales/nl/index.ts +6 -2
- package/src/locales/nl/parsers/NLCasualDateTimeParser.ts +1 -1
- package/src/locales/nl/parsers/NLCasualTimeParser.ts +1 -1
- package/src/locales/pt/index.ts +6 -2
- package/src/locales/pt/parsers/PTCasualTimeParser.ts +1 -1
- package/src/locales/ru/index.ts +6 -2
- package/src/locales/ru/parsers/RUTimeExpressionParser.ts +1 -1
- package/src/locales/uk/constants.ts +349 -0
- package/src/locales/uk/index.ts +90 -0
- package/src/locales/uk/parsers/UKCasualDateParser.ts +50 -0
- package/src/locales/uk/parsers/UKCasualTimeParser.ts +59 -0
- package/src/locales/uk/parsers/UKMonthNameLittleEndianParser.ts +72 -0
- package/src/locales/uk/parsers/UKMonthNameParser.ts +61 -0
- package/src/locales/uk/parsers/UKRelativeDateFormatParser.ts +85 -0
- package/src/locales/uk/parsers/UKTimeExpressionParser.ts +64 -0
- package/src/locales/uk/parsers/UKTimeUnitAgoFormatParser.ts +24 -0
- package/src/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.ts +34 -0
- package/src/locales/uk/parsers/UKTimeUnitWithinFormatParser.ts +27 -0
- package/src/locales/uk/parsers/UKWeekdayParser.ts +59 -0
- package/src/locales/uk/refiners/UKMergeDateRangeRefiner.ts +13 -0
- package/src/locales/uk/refiners/UKMergeDateTimeRefiner.ts +13 -0
- package/src/locales/zh/hans/index.ts +6 -2
- package/src/locales/zh/hant/index.ts +6 -2
- package/src/results.ts +1 -1
- package/src/timezone.ts +1 -1
- package/src/types.ts +150 -0
- package/src/utils/dayjs.ts +1 -1
- package/test/debugging.test.ts +17 -0
- package/test/en/en_month_name_little_endian.test.ts +12 -0
- package/test/en/en_time_units_within.test.ts +7 -0
- package/test/en/en_timezone_exp.test.ts +48 -4
- package/test/ja/ja_casual.test.ts +50 -13
- package/test/uk/uk_casual.test.ts +153 -0
- package/test/uk/uk_month.test.ts +70 -0
- package/test/uk/uk_month_name_little_endian.test.ts +148 -0
- package/test/uk/uk_relative.test.ts +74 -0
- package/test/uk/uk_time_exp.test.ts +111 -0
- package/test/uk/uk_time_units_ago.test.ts +48 -0
- package/test/uk/uk_time_units_casual_relative.test.ts +112 -0
- package/test/uk/uk_time_units_within.test.ts +16 -0
- package/test/uk/uk_weekday.test.ts +52 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export var Meridiem;
|
|
2
|
+
(function (Meridiem) {
|
|
3
|
+
Meridiem[Meridiem["AM"] = 0] = "AM";
|
|
4
|
+
Meridiem[Meridiem["PM"] = 1] = "PM";
|
|
5
|
+
})(Meridiem || (Meridiem = {}));
|
|
6
|
+
export var Weekday;
|
|
7
|
+
(function (Weekday) {
|
|
8
|
+
Weekday[Weekday["SUNDAY"] = 0] = "SUNDAY";
|
|
9
|
+
Weekday[Weekday["MONDAY"] = 1] = "MONDAY";
|
|
10
|
+
Weekday[Weekday["TUESDAY"] = 2] = "TUESDAY";
|
|
11
|
+
Weekday[Weekday["WEDNESDAY"] = 3] = "WEDNESDAY";
|
|
12
|
+
Weekday[Weekday["THURSDAY"] = 4] = "THURSDAY";
|
|
13
|
+
Weekday[Weekday["FRIDAY"] = 5] = "FRIDAY";
|
|
14
|
+
Weekday[Weekday["SATURDAY"] = 6] = "SATURDAY";
|
|
15
|
+
})(Weekday || (Weekday = {}));
|
|
16
|
+
export var Month;
|
|
17
|
+
(function (Month) {
|
|
18
|
+
Month[Month["JANUARY"] = 1] = "JANUARY";
|
|
19
|
+
Month[Month["FEBRUARY"] = 2] = "FEBRUARY";
|
|
20
|
+
Month[Month["MARCH"] = 3] = "MARCH";
|
|
21
|
+
Month[Month["APRIL"] = 4] = "APRIL";
|
|
22
|
+
Month[Month["MAY"] = 5] = "MAY";
|
|
23
|
+
Month[Month["JUNE"] = 6] = "JUNE";
|
|
24
|
+
Month[Month["JULY"] = 7] = "JULY";
|
|
25
|
+
Month[Month["AUGUST"] = 8] = "AUGUST";
|
|
26
|
+
Month[Month["SEPTEMBER"] = 9] = "SEPTEMBER";
|
|
27
|
+
Month[Month["OCTOBER"] = 10] = "OCTOBER";
|
|
28
|
+
Month[Month["NOVEMBER"] = 11] = "NOVEMBER";
|
|
29
|
+
Month[Month["DECEMBER"] = 12] = "DECEMBER";
|
|
30
|
+
})(Month || (Month = {}));
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAyHA,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAChB,mCAAM,CAAA;IACN,mCAAM,CAAA;AACV,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AAED,MAAM,CAAN,IAAY,OAQX;AARD,WAAY,OAAO;IACf,yCAAU,CAAA;IACV,yCAAU,CAAA;IACV,2CAAW,CAAA;IACX,+CAAa,CAAA;IACb,6CAAY,CAAA;IACZ,yCAAU,CAAA;IACV,6CAAY,CAAA;AAChB,CAAC,EARW,OAAO,KAAP,OAAO,QAQlB;AAED,MAAM,CAAN,IAAY,KAaX;AAbD,WAAY,KAAK;IACb,uCAAW,CAAA;IACX,yCAAY,CAAA;IACZ,mCAAS,CAAA;IACT,mCAAS,CAAA;IACT,+BAAO,CAAA;IACP,iCAAQ,CAAA;IACR,iCAAQ,CAAA;IACR,qCAAU,CAAA;IACV,2CAAa,CAAA;IACb,wCAAY,CAAA;IACZ,0CAAa,CAAA;IACb,0CAAa,CAAA;AACjB,CAAC,EAbW,KAAK,KAAL,KAAK,QAahB"}
|
package/dist/esm/utils/dayjs.js
CHANGED
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"preset": "ts-jest"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"version": "2.6.
|
|
18
|
+
"version": "2.6.5",
|
|
19
19
|
"directories": {
|
|
20
20
|
"source": "./src",
|
|
21
21
|
"test": "./test"
|
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
".": {
|
|
27
27
|
"require": "./dist/cjs/index.js",
|
|
28
28
|
"import": "./dist/esm/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./*": {
|
|
31
|
+
"require": "./dist/cjs/locales/*/index.js",
|
|
32
|
+
"import": "./dist/esm/locales/*/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./*/*": {
|
|
35
|
+
"require": "./dist/cjs/locales/*/*/index.js",
|
|
36
|
+
"import": "./dist/esm/locales/*/*/index.js"
|
|
29
37
|
}
|
|
30
38
|
},
|
|
31
39
|
"engines": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingComponents, ParsingResult } from "../results";
|
|
2
|
-
import { Meridiem } from "../
|
|
2
|
+
import { Meridiem } from "../types";
|
|
3
3
|
import { assignSimilarDate, implySimilarDate } from "../utils/dayjs";
|
|
4
4
|
|
|
5
5
|
export function mergeDateTimeResult(dateResult: ParsingResult, timeResult: ParsingResult): ParsingResult {
|
package/src/chrono.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReferenceWithTimezone, ParsingComponents, ParsingResult } from "./results";
|
|
2
|
-
import { Component, ParsedResult, ParsingOption, ParsingReference } from "./
|
|
2
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference } from "./types";
|
|
3
3
|
import { AsyncDebugBlock, DebugHandler } from "./debugging";
|
|
4
|
-
import
|
|
4
|
+
import ENDefaultConfiguration from "./locales/en/configuration";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Chrono configuration.
|
|
@@ -13,7 +13,7 @@ export interface Configuration {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* An abstraction for Chrono *Parser*.
|
|
17
17
|
*
|
|
18
18
|
* Each parser should recognize and handle a certain date format.
|
|
19
19
|
* Chrono uses multiple parses (and refiners) together for parsing the input.
|
|
@@ -48,8 +48,10 @@ export class Chrono {
|
|
|
48
48
|
parsers: Array<Parser>;
|
|
49
49
|
refiners: Array<Refiner>;
|
|
50
50
|
|
|
51
|
+
defaultConfig = new ENDefaultConfiguration();
|
|
52
|
+
|
|
51
53
|
constructor(configuration?: Configuration) {
|
|
52
|
-
configuration = configuration || createCasualConfiguration();
|
|
54
|
+
configuration = configuration || this.defaultConfig.createCasualConfiguration();
|
|
53
55
|
this.parsers = [...configuration.parsers];
|
|
54
56
|
this.refiners = [...configuration.refiners];
|
|
55
57
|
}
|
|
@@ -108,7 +110,7 @@ export class Chrono {
|
|
|
108
110
|
|
|
109
111
|
const result = parser.extract(context, match);
|
|
110
112
|
if (!result) {
|
|
111
|
-
// If
|
|
113
|
+
// If fails, move on by 1
|
|
112
114
|
remainingText = originalText.substring(match.index + 1);
|
|
113
115
|
match = pattern.exec(remainingText);
|
|
114
116
|
continue;
|
|
@@ -124,10 +126,14 @@ export class Chrono {
|
|
|
124
126
|
parsedResult = context.createParsingResult(match.index, match[0], result);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
const parsedIndex = parsedResult.index;
|
|
130
|
+
const parsedText = parsedResult.text;
|
|
131
|
+
context.debug(() =>
|
|
132
|
+
console.log(`${parser.constructor.name} extracted (at index=${parsedIndex}) '${parsedText}'`)
|
|
133
|
+
);
|
|
128
134
|
|
|
129
135
|
results.push(parsedResult);
|
|
130
|
-
remainingText = originalText.substring(
|
|
136
|
+
remainingText = originalText.substring(parsedIndex + parsedText.length);
|
|
131
137
|
match = pattern.exec(remainingText);
|
|
132
138
|
}
|
|
133
139
|
|
|
@@ -141,7 +147,7 @@ export class ParsingContext implements DebugHandler {
|
|
|
141
147
|
readonly reference: ReferenceWithTimezone;
|
|
142
148
|
|
|
143
149
|
/**
|
|
144
|
-
* @deprecated. Use reference.instant instead.
|
|
150
|
+
* @deprecated. Use `reference.instant` instead.
|
|
145
151
|
*/
|
|
146
152
|
readonly refDate: Date;
|
|
147
153
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
implySimilarTime,
|
|
8
8
|
implyTheNextDay,
|
|
9
9
|
} from "../utils/dayjs";
|
|
10
|
-
import { Meridiem } from "../
|
|
10
|
+
import { Meridiem } from "../types";
|
|
11
11
|
|
|
12
12
|
export function now(reference: ReferenceWithTimezone): ParsingComponents {
|
|
13
13
|
const targetDate = dayjs(reference.instant);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Parser, ParsingContext } from "../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../results";
|
|
3
|
-
import { Meridiem } from "../../
|
|
3
|
+
import { Meridiem } from "../../types";
|
|
4
4
|
|
|
5
5
|
// prettier-ignore
|
|
6
6
|
function primaryTimePattern(leftBoundary: string, primaryPrefix: string, primarySuffix: string, flags: string) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Map ABBR -> Offset in minute
|
|
2
2
|
import { ParsingContext, Refiner } from "../../chrono";
|
|
3
|
-
import { TimezoneAbbrMap } from "../../
|
|
3
|
+
import { TimezoneAbbrMap } from "../../types";
|
|
4
4
|
import { ParsingResult } from "../../results";
|
|
5
5
|
import { toTimezoneOffset } from "../../timezone";
|
|
6
6
|
|
|
@@ -42,7 +42,7 @@ export default class ExtractTimezoneAbbrRefiner implements Refiner {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// This is often because it's relative time with inferred timezone (e.g. in 1 hour, tomorrow)
|
|
45
|
-
// Then, we want to double
|
|
45
|
+
// Then, we want to double-check the abbr case (e.g. "GET" not "get")
|
|
46
46
|
if (timezoneAbbr != match[1]) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
@@ -50,7 +50,7 @@ export default class ExtractTimezoneAbbrRefiner implements Refiner {
|
|
|
50
50
|
|
|
51
51
|
if (result.start.isOnlyDate()) {
|
|
52
52
|
// If the time is not explicitly mentioned,
|
|
53
|
-
// Then, we also want to double
|
|
53
|
+
// Then, we also want to double-check the abbr case (e.g. "GET" not "get")
|
|
54
54
|
if (timezoneAbbr != match[1]) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
package/src/configurations.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Configuration } from "./chrono";
|
|
1
|
+
import { Configuration, Parser, Refiner } from "./chrono";
|
|
2
2
|
|
|
3
3
|
import ExtractTimezoneAbbrRefiner from "./common/refiners/ExtractTimezoneAbbrRefiner";
|
|
4
4
|
import ExtractTimezoneOffsetRefiner from "./common/refiners/ExtractTimezoneOffsetRefiner";
|
package/src/index.ts
CHANGED
|
@@ -1,158 +1,10 @@
|
|
|
1
|
-
import { DebugHandler, DebugConsume } from "./debugging";
|
|
2
1
|
import * as en from "./locales/en";
|
|
3
2
|
import { Chrono, Parser, Refiner } from "./chrono";
|
|
4
|
-
import
|
|
3
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "./results";
|
|
4
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "./types";
|
|
5
5
|
|
|
6
|
-
export { en, Chrono, Parser, Refiner, ParsingResult };
|
|
7
|
-
|
|
8
|
-
export interface ParsingOption {
|
|
9
|
-
/**
|
|
10
|
-
* To parse only forward dates (the results should be after the reference date).
|
|
11
|
-
* This effects date/time implication (e.g. weekday or time mentioning)
|
|
12
|
-
*/
|
|
13
|
-
forwardDate?: boolean;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Additional timezone keywords for the parsers to recognize.
|
|
17
|
-
* Any value provided will override the default handling of that value.
|
|
18
|
-
*/
|
|
19
|
-
timezones?: TimezoneAbbrMap;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Internal debug event handler.
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
debug?: DebugHandler | DebugConsume;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Some timezone abbreviations are ambiguous in that they refer to different offsets
|
|
30
|
-
* depending on the time of year — daylight savings time (DST), or non-DST. This interface
|
|
31
|
-
* allows defining such timezones
|
|
32
|
-
*/
|
|
33
|
-
export interface AmbiguousTimezoneMap {
|
|
34
|
-
timezoneOffsetDuringDst: number;
|
|
35
|
-
timezoneOffsetNonDst: number;
|
|
36
|
-
/**
|
|
37
|
-
* Return the start date of DST for the given year.
|
|
38
|
-
* timezone.ts contains helper methods for common such rules.
|
|
39
|
-
*/
|
|
40
|
-
dstStart: (year: number) => Date;
|
|
41
|
-
/**
|
|
42
|
-
* Return the end date of DST for the given year.
|
|
43
|
-
* timezone.ts contains helper methods for common such rules.
|
|
44
|
-
*/
|
|
45
|
-
dstEnd: (year: number) => Date;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A map describing how timezone abbreviations should map to time offsets.
|
|
50
|
-
* Supports both unambigous mappings abbreviation => offset,
|
|
51
|
-
* and ambiguous mappings, where the offset will depend on whether the
|
|
52
|
-
* time in question is during daylight savings time or not.
|
|
53
|
-
*/
|
|
54
|
-
export type TimezoneAbbrMap = { [key: string]: number | AmbiguousTimezoneMap };
|
|
55
|
-
|
|
56
|
-
export interface ParsingReference {
|
|
57
|
-
/**
|
|
58
|
-
* Reference date. The instant (JavaScript Date object) when the input is written or mention.
|
|
59
|
-
* This effect date/time implication (e.g. weekday or time mentioning).
|
|
60
|
-
* (default = now)
|
|
61
|
-
*/
|
|
62
|
-
instant?: Date;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Reference timezone. The timezone where the input is written or mention.
|
|
66
|
-
* Date/time implication will account the difference between input timezone and the current system timezone.
|
|
67
|
-
* (default = current timezone)
|
|
68
|
-
*/
|
|
69
|
-
timezone?: string | number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Parsed result or final output.
|
|
74
|
-
* Each result object represents a date/time (or date/time-range) mentioning in the input.
|
|
75
|
-
*/
|
|
76
|
-
export interface ParsedResult {
|
|
77
|
-
readonly refDate: Date;
|
|
78
|
-
readonly index: number;
|
|
79
|
-
readonly text: string;
|
|
80
|
-
|
|
81
|
-
readonly start: ParsedComponents;
|
|
82
|
-
readonly end?: ParsedComponents;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Create a javascript date object (from the result.start).
|
|
86
|
-
*/
|
|
87
|
-
date(): Date;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* A collection of parsed date/time components (e.g. day, hour, minute, ..., etc).
|
|
92
|
-
*
|
|
93
|
-
* Each parsed component has three different levels of certainty.
|
|
94
|
-
* - *Certain* (or *Known*): The component is directly mentioned and parsed.
|
|
95
|
-
* - *Implied*: The component is not directly mentioned, but implied by other parsed information.
|
|
96
|
-
* - *Unknown*: Completely no mention of the component.
|
|
97
|
-
*/
|
|
98
|
-
export interface ParsedComponents {
|
|
99
|
-
/**
|
|
100
|
-
* Check the component certainly if the component is *Certain* (or *Known*)
|
|
101
|
-
*/
|
|
102
|
-
isCertain(component: Component): boolean;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get the component value for either *Certain* or *Implied* value.
|
|
106
|
-
*/
|
|
107
|
-
get(component: Component): number | null;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @return a javascript date object.
|
|
111
|
-
*/
|
|
112
|
-
date(): Date;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type Component =
|
|
116
|
-
| "year"
|
|
117
|
-
| "month"
|
|
118
|
-
| "day"
|
|
119
|
-
| "weekday"
|
|
120
|
-
| "hour"
|
|
121
|
-
| "minute"
|
|
122
|
-
| "second"
|
|
123
|
-
| "millisecond"
|
|
124
|
-
| "meridiem"
|
|
125
|
-
| "timezoneOffset";
|
|
126
|
-
|
|
127
|
-
export enum Meridiem {
|
|
128
|
-
AM = 0,
|
|
129
|
-
PM = 1,
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export enum Weekday {
|
|
133
|
-
SUNDAY = 0,
|
|
134
|
-
MONDAY = 1,
|
|
135
|
-
TUESDAY = 2,
|
|
136
|
-
WEDNESDAY = 3,
|
|
137
|
-
THURSDAY = 4,
|
|
138
|
-
FRIDAY = 5,
|
|
139
|
-
SATURDAY = 6,
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export enum Month {
|
|
143
|
-
JANUARY = 1,
|
|
144
|
-
FEBRUARY = 2,
|
|
145
|
-
MARCH = 3,
|
|
146
|
-
APRIL = 4,
|
|
147
|
-
MAY = 5,
|
|
148
|
-
JUNE = 6,
|
|
149
|
-
JULY = 7,
|
|
150
|
-
AUGUST = 8,
|
|
151
|
-
SEPTEMBER = 9,
|
|
152
|
-
OCTOBER = 10,
|
|
153
|
-
NOVEMBER = 11,
|
|
154
|
-
DECEMBER = 12,
|
|
155
|
-
}
|
|
6
|
+
export { en, Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
7
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
156
8
|
|
|
157
9
|
// Export all locales
|
|
158
10
|
import * as de from "./locales/de";
|
|
@@ -163,7 +15,9 @@ import * as nl from "./locales/nl";
|
|
|
163
15
|
import * as zh from "./locales/zh";
|
|
164
16
|
import * as ru from "./locales/ru";
|
|
165
17
|
import * as es from "./locales/es";
|
|
166
|
-
|
|
18
|
+
import * as uk from "./locales/uk";
|
|
19
|
+
|
|
20
|
+
export { de, fr, ja, pt, nl, zh, ru, es, uk };
|
|
167
21
|
|
|
168
22
|
/**
|
|
169
23
|
* A shortcut for {@link en | chrono.en.strict}
|
package/src/locales/de/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { includeCommonConfiguration } from "../../configurations";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
3
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../results";
|
|
4
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
4
5
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
5
6
|
import ISOFormatParser from "../../common/parsers/ISOFormatParser";
|
|
6
7
|
import DETimeExpressionParser from "./parsers/DETimeExpressionParser";
|
|
@@ -14,6 +15,9 @@ import DEMonthNameLittleEndianParser from "./parsers/DEMonthNameLittleEndianPars
|
|
|
14
15
|
import DETimeUnitRelativeFormatParser from "./parsers/DETimeUnitRelativeFormatParser";
|
|
15
16
|
import DETimeUnitWithinFormatParser from "./parsers/DETimeUnitWithinFormatParser";
|
|
16
17
|
|
|
18
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
19
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
20
|
+
|
|
17
21
|
// Shortcuts
|
|
18
22
|
export const casual = new Chrono(createCasualConfiguration());
|
|
19
23
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
|
-
import { Meridiem } from "../../../
|
|
4
|
+
import { Meridiem } from "../../../types";
|
|
5
5
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
6
|
import { implySimilarTime } from "../../../utils/dayjs";
|
|
7
7
|
import { addImpliedTimeUnits } from "../../../utils/timeunits";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Configuration } from "../../chrono";
|
|
2
|
+
|
|
3
|
+
import ENTimeUnitWithinFormatParser from "./parsers/ENTimeUnitWithinFormatParser";
|
|
4
|
+
import ENMonthNameLittleEndianParser from "./parsers/ENMonthNameLittleEndianParser";
|
|
5
|
+
import ENMonthNameMiddleEndianParser from "./parsers/ENMonthNameMiddleEndianParser";
|
|
6
|
+
import ENMonthNameParser from "./parsers/ENMonthNameParser";
|
|
7
|
+
import ENCasualYearMonthDayParser from "./parsers/ENCasualYearMonthDayParser";
|
|
8
|
+
import ENSlashMonthFormatParser from "./parsers/ENSlashMonthFormatParser";
|
|
9
|
+
import ENTimeExpressionParser from "./parsers/ENTimeExpressionParser";
|
|
10
|
+
import ENTimeUnitAgoFormatParser from "./parsers/ENTimeUnitAgoFormatParser";
|
|
11
|
+
import ENTimeUnitLaterFormatParser from "./parsers/ENTimeUnitLaterFormatParser";
|
|
12
|
+
import ENMergeDateRangeRefiner from "./refiners/ENMergeDateRangeRefiner";
|
|
13
|
+
import ENMergeDateTimeRefiner from "./refiners/ENMergeDateTimeRefiner";
|
|
14
|
+
|
|
15
|
+
import { includeCommonConfiguration } from "../../configurations";
|
|
16
|
+
import ENCasualDateParser from "./parsers/ENCasualDateParser";
|
|
17
|
+
import ENCasualTimeParser from "./parsers/ENCasualTimeParser";
|
|
18
|
+
import ENWeekdayParser from "./parsers/ENWeekdayParser";
|
|
19
|
+
import ENRelativeDateFormatParser from "./parsers/ENRelativeDateFormatParser";
|
|
20
|
+
|
|
21
|
+
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
22
|
+
import ENTimeUnitCasualRelativeFormatParser from "./parsers/ENTimeUnitCasualRelativeFormatParser";
|
|
23
|
+
import ENMergeRelativeDateRefiner from "./refiners/ENMergeRelativeDateRefiner";
|
|
24
|
+
|
|
25
|
+
export default class ENDefaultConfiguration {
|
|
26
|
+
/**
|
|
27
|
+
* Create a default *casual* {@Link Configuration} for English chrono.
|
|
28
|
+
* It calls {@Link createConfiguration} and includes additional parsers.
|
|
29
|
+
*/
|
|
30
|
+
createCasualConfiguration(littleEndian = false): Configuration {
|
|
31
|
+
const option = this.createConfiguration(false, littleEndian);
|
|
32
|
+
option.parsers.unshift(new ENCasualDateParser());
|
|
33
|
+
option.parsers.unshift(new ENCasualTimeParser());
|
|
34
|
+
option.parsers.unshift(new ENMonthNameParser());
|
|
35
|
+
option.parsers.unshift(new ENRelativeDateFormatParser());
|
|
36
|
+
option.parsers.unshift(new ENTimeUnitCasualRelativeFormatParser());
|
|
37
|
+
return option;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a default {@Link Configuration} for English chrono
|
|
42
|
+
*
|
|
43
|
+
* @param strictMode If the timeunit mentioning should be strict, not casual
|
|
44
|
+
* @param littleEndian If format should be date-first/littleEndian (e.g. en_UK), not month-first/middleEndian (e.g. en_US)
|
|
45
|
+
*/
|
|
46
|
+
createConfiguration(strictMode = true, littleEndian = false): Configuration {
|
|
47
|
+
const options = includeCommonConfiguration(
|
|
48
|
+
{
|
|
49
|
+
parsers: [
|
|
50
|
+
new SlashDateFormatParser(littleEndian),
|
|
51
|
+
new ENTimeUnitWithinFormatParser(strictMode),
|
|
52
|
+
new ENMonthNameLittleEndianParser(),
|
|
53
|
+
new ENMonthNameMiddleEndianParser(),
|
|
54
|
+
new ENWeekdayParser(),
|
|
55
|
+
new ENCasualYearMonthDayParser(),
|
|
56
|
+
new ENSlashMonthFormatParser(),
|
|
57
|
+
new ENTimeExpressionParser(strictMode),
|
|
58
|
+
new ENTimeUnitAgoFormatParser(strictMode),
|
|
59
|
+
new ENTimeUnitLaterFormatParser(strictMode),
|
|
60
|
+
],
|
|
61
|
+
refiners: [new ENMergeRelativeDateRefiner(), new ENMergeDateTimeRefiner()],
|
|
62
|
+
},
|
|
63
|
+
strictMode
|
|
64
|
+
);
|
|
65
|
+
// Re-apply the date time refiner again after the timezone refinement and exclusion in common refiners.
|
|
66
|
+
options.refiners.push(new ENMergeDateTimeRefiner());
|
|
67
|
+
// Keep the date range refiner at the end (after all other refinements).
|
|
68
|
+
options.refiners.push(new ENMergeDateRangeRefiner());
|
|
69
|
+
return options;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -2,7 +2,7 @@ import { OpUnitType, QUnitType } from "dayjs";
|
|
|
2
2
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
3
3
|
import { findMostLikelyADYear } from "../../calculation/years";
|
|
4
4
|
import { TimeUnits } from "../../utils/timeunits";
|
|
5
|
-
import { Weekday } from "../../
|
|
5
|
+
import { Weekday } from "../../types";
|
|
6
6
|
|
|
7
7
|
export const WEEKDAY_DICTIONARY: { [word: string]: Weekday } = {
|
|
8
8
|
sunday: 0,
|
package/src/locales/en/index.ts
CHANGED
|
@@ -4,44 +4,31 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import ENMonthNameParser from "./parsers/ENMonthNameParser";
|
|
11
|
-
import ENCasualYearMonthDayParser from "./parsers/ENCasualYearMonthDayParser";
|
|
12
|
-
import ENSlashMonthFormatParser from "./parsers/ENSlashMonthFormatParser";
|
|
13
|
-
import ENTimeExpressionParser from "./parsers/ENTimeExpressionParser";
|
|
14
|
-
import ENTimeUnitAgoFormatParser from "./parsers/ENTimeUnitAgoFormatParser";
|
|
15
|
-
import ENTimeUnitLaterFormatParser from "./parsers/ENTimeUnitLaterFormatParser";
|
|
16
|
-
import ENMergeDateRangeRefiner from "./refiners/ENMergeDateRangeRefiner";
|
|
17
|
-
import ENMergeDateTimeRefiner from "./refiners/ENMergeDateTimeRefiner";
|
|
7
|
+
import { Chrono, Parser, Refiner } from "../../chrono";
|
|
8
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../results";
|
|
9
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
18
10
|
|
|
19
|
-
import
|
|
20
|
-
import ENCasualDateParser from "./parsers/ENCasualDateParser";
|
|
21
|
-
import ENCasualTimeParser from "./parsers/ENCasualTimeParser";
|
|
22
|
-
import ENWeekdayParser from "./parsers/ENWeekdayParser";
|
|
23
|
-
import ENRelativeDateFormatParser from "./parsers/ENRelativeDateFormatParser";
|
|
11
|
+
import ENDefaultConfiguration from "./configuration";
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import ENMergeRelativeDateRefiner from "./refiners/ENMergeRelativeDateRefiner";
|
|
13
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
14
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
15
|
+
|
|
16
|
+
const enConfig = new ENDefaultConfiguration();
|
|
30
17
|
|
|
31
18
|
/**
|
|
32
19
|
* Chrono object configured for parsing *casual* English
|
|
33
20
|
*/
|
|
34
|
-
export const casual = new Chrono(createCasualConfiguration(false));
|
|
21
|
+
export const casual = new Chrono(enConfig.createCasualConfiguration(false));
|
|
35
22
|
|
|
36
23
|
/**
|
|
37
24
|
* Chrono object configured for parsing *strict* English
|
|
38
25
|
*/
|
|
39
|
-
export const strict = new Chrono(createConfiguration(true, false));
|
|
26
|
+
export const strict = new Chrono(enConfig.createConfiguration(true, false));
|
|
40
27
|
|
|
41
28
|
/**
|
|
42
29
|
* Chrono object configured for parsing *UK-style* English
|
|
43
30
|
*/
|
|
44
|
-
export const GB = new Chrono(createConfiguration(false, true));
|
|
31
|
+
export const GB = new Chrono(enConfig.createConfiguration(false, true));
|
|
45
32
|
|
|
46
33
|
/**
|
|
47
34
|
* A shortcut for en.casual.parse()
|
|
@@ -56,44 +43,3 @@ export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedR
|
|
|
56
43
|
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
|
|
57
44
|
return casual.parseDate(text, ref, option);
|
|
58
45
|
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Create a default *casual* {@Link Configuration} for English chrono.
|
|
62
|
-
* It calls {@Link createConfiguration} and includes additional parsers.
|
|
63
|
-
*/
|
|
64
|
-
export function createCasualConfiguration(littleEndian = false): Configuration {
|
|
65
|
-
const option = createConfiguration(false, littleEndian);
|
|
66
|
-
option.parsers.unshift(new ENCasualDateParser());
|
|
67
|
-
option.parsers.unshift(new ENCasualTimeParser());
|
|
68
|
-
option.parsers.unshift(new ENMonthNameParser());
|
|
69
|
-
option.parsers.unshift(new ENRelativeDateFormatParser());
|
|
70
|
-
option.parsers.unshift(new ENTimeUnitCasualRelativeFormatParser());
|
|
71
|
-
return option;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create a default {@Link Configuration} for English chrono
|
|
76
|
-
*
|
|
77
|
-
* @param strictMode If the timeunit mentioning should be strict, not casual
|
|
78
|
-
* @param littleEndian If format should be date-first/littleEndian (e.g. en_UK), not month-first/middleEndian (e.g. en_US)
|
|
79
|
-
*/
|
|
80
|
-
export function createConfiguration(strictMode = true, littleEndian = false): Configuration {
|
|
81
|
-
return includeCommonConfiguration(
|
|
82
|
-
{
|
|
83
|
-
parsers: [
|
|
84
|
-
new SlashDateFormatParser(littleEndian),
|
|
85
|
-
new ENTimeUnitWithinFormatParser(strictMode),
|
|
86
|
-
new ENMonthNameLittleEndianParser(),
|
|
87
|
-
new ENMonthNameMiddleEndianParser(),
|
|
88
|
-
new ENWeekdayParser(),
|
|
89
|
-
new ENCasualYearMonthDayParser(),
|
|
90
|
-
new ENSlashMonthFormatParser(),
|
|
91
|
-
new ENTimeExpressionParser(strictMode),
|
|
92
|
-
new ENTimeUnitAgoFormatParser(strictMode),
|
|
93
|
-
new ENTimeUnitLaterFormatParser(strictMode),
|
|
94
|
-
],
|
|
95
|
-
refiners: [new ENMergeRelativeDateRefiner(), new ENMergeDateTimeRefiner(), new ENMergeDateRangeRefiner()],
|
|
96
|
-
},
|
|
97
|
-
strictMode
|
|
98
|
-
);
|
|
99
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents } from "../../../results";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
5
5
|
|
|
6
6
|
export default class ENTimeExpressionParser extends AbstractTimeExpressionParser {
|
package/src/locales/es/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { includeCommonConfiguration } from "../../configurations";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
9
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
11
12
|
import ESWeekdayParser from "./parsers/ESWeekdayParser";
|
|
12
13
|
import ESTimeExpressionParser from "./parsers/ESTimeExpressionParser";
|
|
@@ -17,6 +18,9 @@ import ESCasualDateParser from "./parsers/ESCasualDateParser";
|
|
|
17
18
|
import ESCasualTimeParser from "./parsers/ESCasualTimeParser";
|
|
18
19
|
import ESTimeUnitWithinFormatParser from "./parsers/ESTimeUnitWithinFormatParser";
|
|
19
20
|
|
|
21
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
22
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
23
|
+
|
|
20
24
|
// Shortcuts
|
|
21
25
|
export const casual = new Chrono(createCasualConfiguration());
|
|
22
26
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { Meridiem } from "../../../
|
|
2
|
+
import { Meridiem } from "../../../types";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
4
|
import { assignTheNextDay } from "../../../utils/dayjs";
|
|
5
5
|
import dayjs from "dayjs";
|