chrono-node 2.6.2 → 2.6.4
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 +56 -4
- 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/AbstractMergeDateRangeRefiner.js +15 -7
- package/dist/cjs/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -1
- package/dist/cjs/common/refiners/ExtractTimezoneAbbrRefiner.d.ts +3 -4
- package/dist/cjs/common/refiners/ExtractTimezoneAbbrRefiner.js +6 -196
- package/dist/cjs/common/refiners/ExtractTimezoneAbbrRefiner.js.map +1 -1
- package/dist/cjs/common/refiners/ForwardDateRefiner.js +14 -14
- package/dist/cjs/common/refiners/ForwardDateRefiner.js.map +1 -1
- package/dist/cjs/configurations.js +1 -1
- package/dist/cjs/configurations.js.map +1 -1
- package/dist/cjs/index.d.ts +7 -41
- package/dist/cjs/index.js +8 -16
- 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 +7 -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 +58 -0
- package/dist/cjs/locales/en/configuration.js.map +1 -0
- package/dist/cjs/locales/en/constants.d.ts +5 -1
- package/dist/cjs/locales/en/constants.js +5 -18
- package/dist/cjs/locales/en/constants.js.map +1 -1
- package/dist/cjs/locales/en/index.d.ts +5 -4
- package/dist/cjs/locales/en/index.js +12 -51
- package/dist/cjs/locales/en/index.js.map +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/en/parsers/ENTimeUnitAgoFormatParser.js +2 -2
- package/dist/cjs/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.d.ts +2 -0
- package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +6 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitLaterFormatParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.d.ts +2 -0
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js +10 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/es/index.d.ts +5 -2
- package/dist/cjs/locales/es/index.js +7 -1
- package/dist/cjs/locales/es/index.js.map +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 +7 -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 +7 -1
- package/dist/cjs/locales/ja/index.js.map +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/nl/index.d.ts +5 -2
- package/dist/cjs/locales/nl/index.js +7 -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.js +5 -5
- package/dist/cjs/locales/nl/parsers/NLMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/pt/index.d.ts +5 -2
- package/dist/cjs/locales/pt/index.js +7 -1
- package/dist/cjs/locales/pt/index.js.map +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js +5 -5
- package/dist/cjs/locales/ru/constants.js +4 -1
- package/dist/cjs/locales/ru/constants.js.map +1 -1
- package/dist/cjs/locales/ru/index.d.ts +5 -2
- package/dist/cjs/locales/ru/index.js +7 -1
- package/dist/cjs/locales/ru/index.js.map +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 +64 -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 +8 -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 +8 -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 +2 -2
- package/dist/cjs/results.js +3 -3
- package/dist/cjs/results.js.map +1 -1
- package/dist/cjs/timezone.d.ts +5 -194
- package/dist/cjs/timezone.js +80 -7
- package/dist/cjs/timezone.js.map +1 -1
- 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/AbstractMergeDateRangeRefiner.js +15 -7
- package/dist/esm/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -1
- package/dist/esm/common/refiners/ExtractTimezoneAbbrRefiner.d.ts +3 -4
- package/dist/esm/common/refiners/ExtractTimezoneAbbrRefiner.js +6 -196
- package/dist/esm/common/refiners/ExtractTimezoneAbbrRefiner.js.map +1 -1
- package/dist/esm/common/refiners/ForwardDateRefiner.js +14 -14
- package/dist/esm/common/refiners/ForwardDateRefiner.js.map +1 -1
- package/dist/esm/configurations.js +1 -1
- package/dist/esm/configurations.js.map +1 -1
- package/dist/esm/index.d.ts +7 -41
- package/dist/esm/index.js +6 -17
- 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 +52 -0
- package/dist/esm/locales/en/configuration.js.map +1 -0
- package/dist/esm/locales/en/constants.d.ts +5 -1
- package/dist/esm/locales/en/constants.js +21 -0
- package/dist/esm/locales/en/constants.js.map +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/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/en/parsers/ENTimeUnitAgoFormatParser.js +3 -3
- package/dist/esm/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.d.ts +2 -0
- package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +7 -2
- package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js +2 -2
- package/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.d.ts +2 -0
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js +11 -2
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +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.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.js +25 -3
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js.map +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.js +1 -1
- package/dist/esm/locales/nl/parsers/NLMonthNameMiddleEndianParser.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.js +1 -1
- package/dist/esm/locales/ru/constants.js +4 -1
- package/dist/esm/locales/ru/constants.js.map +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/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 +2 -2
- package/dist/esm/results.js +3 -3
- package/dist/esm/results.js.map +1 -1
- package/dist/esm/timezone.d.ts +5 -194
- package/dist/esm/timezone.js +74 -6
- package/dist/esm/timezone.js.map +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 +12 -5
- 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/AbstractMergeDateRangeRefiner.ts +13 -8
- package/src/common/refiners/ExtractTimezoneAbbrRefiner.ts +7 -201
- package/src/common/refiners/ForwardDateRefiner.ts +18 -16
- package/src/configurations.ts +3 -1
- package/src/index.ts +6 -107
- 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 +70 -0
- package/src/locales/en/constants.ts +31 -1
- package/src/locales/en/index.ts +11 -65
- package/src/locales/en/parsers/ENTimeExpressionParser.ts +1 -1
- package/src/locales/en/parsers/ENTimeUnitAgoFormatParser.ts +3 -3
- package/src/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.ts +10 -2
- package/src/locales/en/parsers/ENTimeUnitLaterFormatParser.ts +5 -2
- package/src/locales/en/parsers/ENTimeUnitWithinFormatParser.ts +16 -3
- 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/constants.ts +4 -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 +4 -4
- package/src/timezone.ts +124 -7
- package/src/types.ts +150 -0
- package/src/utils/dayjs.ts +1 -1
- package/test/de/de_time_exp.test.ts +7 -7
- package/test/debugging.test.ts +17 -0
- package/test/en/en_month.test.ts +70 -0
- package/test/en/en_month_name_little_endian.test.ts +12 -0
- package/test/en/en_time_units_ago.test.ts +12 -0
- package/test/en/en_time_units_casual_relative.test.ts +18 -0
- package/test/en/en_time_units_later.test.ts +13 -10
- package/test/en/en_time_units_within.test.ts +12 -1
- package/test/en/en_timezone_exp.test.ts +142 -0
- package/test/en/en_weekday.test.ts +26 -0
- package/test/en/negative_cases.test.ts +2 -0
- package/test/fr/fr_time_exp.test.ts +2 -2
- package/test/ja/ja_casual.test.ts +50 -13
- package/test/system.test.ts +23 -1
- 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,70 @@
|
|
|
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
|
+
return 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: [
|
|
62
|
+
new ENMergeRelativeDateRefiner(),
|
|
63
|
+
new ENMergeDateTimeRefiner(),
|
|
64
|
+
new ENMergeDateRangeRefiner(),
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
strictMode
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -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,
|
|
@@ -134,6 +134,25 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
134
134
|
"thirty-first": 31,
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
+
export const TIME_UNIT_DICTIONARY_NO_ABBR: { [word: string]: OpUnitType | QUnitType } = {
|
|
138
|
+
second: "second",
|
|
139
|
+
seconds: "second",
|
|
140
|
+
minute: "minute",
|
|
141
|
+
minutes: "minute",
|
|
142
|
+
hour: "hour",
|
|
143
|
+
hours: "hour",
|
|
144
|
+
day: "d",
|
|
145
|
+
days: "d",
|
|
146
|
+
week: "week",
|
|
147
|
+
weeks: "week",
|
|
148
|
+
month: "month",
|
|
149
|
+
months: "month",
|
|
150
|
+
quarter: "quarter",
|
|
151
|
+
quarters: "quarter",
|
|
152
|
+
year: "year",
|
|
153
|
+
years: "year",
|
|
154
|
+
};
|
|
155
|
+
|
|
137
156
|
export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } = {
|
|
138
157
|
s: "second",
|
|
139
158
|
sec: "second",
|
|
@@ -167,6 +186,9 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
167
186
|
yr: "year",
|
|
168
187
|
year: "year",
|
|
169
188
|
years: "year",
|
|
189
|
+
// Also, merge the entries from the full-name dictionary.
|
|
190
|
+
// We leave the duplicated entries for readability.
|
|
191
|
+
...TIME_UNIT_DICTIONARY_NO_ABBR,
|
|
170
192
|
};
|
|
171
193
|
|
|
172
194
|
//-----------------------------
|
|
@@ -238,7 +260,15 @@ export function parseYear(match: string): number {
|
|
|
238
260
|
const SINGLE_TIME_UNIT_PATTERN = `(${NUMBER_PATTERN})\\s{0,3}(${matchAnyPattern(TIME_UNIT_DICTIONARY)})`;
|
|
239
261
|
const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
240
262
|
|
|
263
|
+
const SINGLE_TIME_UNIT_NO_ABBR_PATTERN = `(${NUMBER_PATTERN})\\s{0,3}(${matchAnyPattern(
|
|
264
|
+
TIME_UNIT_DICTIONARY_NO_ABBR
|
|
265
|
+
)})`;
|
|
266
|
+
|
|
241
267
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern(`(?:(?:about|around)\\s{0,3})?`, SINGLE_TIME_UNIT_PATTERN);
|
|
268
|
+
export const TIME_UNITS_NO_ABBR_PATTERN = repeatedTimeunitPattern(
|
|
269
|
+
`(?:(?:about|around)\\s{0,3})?`,
|
|
270
|
+
SINGLE_TIME_UNIT_NO_ABBR_PATTERN
|
|
271
|
+
);
|
|
242
272
|
|
|
243
273
|
export function parseTimeUnits(timeunitText): TimeUnits {
|
|
244
274
|
const fragments = {};
|
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 } 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 };
|
|
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(),
|
|
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 {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { parseTimeUnits, TIME_UNITS_PATTERN } from "../constants";
|
|
2
|
+
import { parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
6
6
|
|
|
7
|
-
const PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:ago|before|earlier)(
|
|
8
|
-
const STRICT_PATTERN = new RegExp(`(${
|
|
7
|
+
const PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`, "i");
|
|
8
|
+
const STRICT_PATTERN = new RegExp(`(${TIME_UNITS_NO_ABBR_PATTERN})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`, "i");
|
|
9
9
|
|
|
10
10
|
export default class ENTimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
11
11
|
constructor(private strictMode: boolean) {
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN, parseTimeUnits } from "../constants";
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
6
6
|
|
|
7
7
|
const PATTERN = new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
|
8
|
+
const PATTERN_NO_ABBR = new RegExp(
|
|
9
|
+
`(this|last|past|next|after|\\+|-)\\s*(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`,
|
|
10
|
+
"i"
|
|
11
|
+
);
|
|
8
12
|
|
|
9
13
|
export default class ENTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
14
|
+
constructor(private allowAbbreviations: boolean = true) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
innerPattern(): RegExp {
|
|
11
|
-
return PATTERN;
|
|
19
|
+
return this.allowAbbreviations ? PATTERN : PATTERN_NO_ABBR;
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { parseTimeUnits, TIME_UNITS_PATTERN } from "../constants";
|
|
2
|
+
import { parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
@@ -8,7 +8,10 @@ const PATTERN = new RegExp(
|
|
|
8
8
|
"i"
|
|
9
9
|
);
|
|
10
10
|
|
|
11
|
-
const STRICT_PATTERN = new RegExp(
|
|
11
|
+
const STRICT_PATTERN = new RegExp(
|
|
12
|
+
"" + "(" + TIME_UNITS_NO_ABBR_PATTERN + ")" + "(later|from now)" + "(?=(?:\\W|$))",
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
12
15
|
const GROUP_NUM_TIMEUNITS = 1;
|
|
13
16
|
|
|
14
17
|
export default class ENTimeUnitLaterFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN, parseTimeUnits } from "../constants";
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
6
|
+
const PATTERN_WITHOUT_PREFIX = new RegExp(
|
|
7
|
+
`(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
8
|
+
"i"
|
|
9
|
+
);
|
|
10
|
+
|
|
6
11
|
const PATTERN_WITH_PREFIX = new RegExp(
|
|
7
12
|
`(?:within|in|for)\\s*` +
|
|
8
13
|
`(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
9
14
|
"i"
|
|
10
15
|
);
|
|
11
16
|
|
|
12
|
-
const
|
|
13
|
-
`(?:
|
|
17
|
+
const PATTERN_WITH_PREFIX_STRICT = new RegExp(
|
|
18
|
+
`(?:within|in|for)\\s*` +
|
|
19
|
+
`(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`,
|
|
14
20
|
"i"
|
|
15
21
|
);
|
|
16
22
|
|
|
17
23
|
export default class ENTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
24
|
+
constructor(private strictMode: boolean) {
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
innerPattern(context: ParsingContext): RegExp {
|
|
29
|
+
if (this.strictMode) {
|
|
30
|
+
return PATTERN_WITH_PREFIX_STRICT;
|
|
31
|
+
}
|
|
19
32
|
return context.option.forwardDate ? PATTERN_WITHOUT_PREFIX : PATTERN_WITH_PREFIX;
|
|
20
33
|
}
|
|
21
34
|
|
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 } 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 };
|
|
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";
|
package/src/locales/fr/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 } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import FRCasualDateParser from "./parsers/FRCasualDateParser";
|
|
11
12
|
import FRCasualTimeParser from "./parsers/FRCasualTimeParser";
|
|
12
13
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
@@ -20,6 +21,9 @@ import FRTimeUnitAgoFormatParser from "./parsers/FRTimeUnitAgoFormatParser";
|
|
|
20
21
|
import FRTimeUnitWithinFormatParser from "./parsers/FRTimeUnitWithinFormatParser";
|
|
21
22
|
import FRTimeUnitRelativeFormatParser from "./parsers/FRTimeUnitRelativeFormatParser";
|
|
22
23
|
|
|
24
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
25
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
26
|
+
|
|
23
27
|
// Shortcuts
|
|
24
28
|
export const casual = new Chrono(createCasualConfiguration());
|
|
25
29
|
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 { assignSimilarDate } from "../../../utils/dayjs";
|
|
7
7
|
import * as references from "../../../common/casualReferences";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
6
6
|
export default class FRCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
package/src/locales/ja/index.ts
CHANGED
|
@@ -8,8 +8,12 @@ import JPStandardParser from "./parsers/JPStandardParser";
|
|
|
8
8
|
import JPMergeDateRangeRefiner from "./refiners/JPMergeDateRangeRefiner";
|
|
9
9
|
import JPCasualDateParser from "./parsers/JPCasualDateParser";
|
|
10
10
|
|
|
11
|
-
import { Chrono, Configuration } from "../../chrono";
|
|
12
|
-
import {
|
|
11
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
12
|
+
import { ParsingResult } from "../../results";
|
|
13
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
14
|
+
|
|
15
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
16
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
13
17
|
|
|
14
18
|
// Shortcuts
|
|
15
19
|
export const casual = new Chrono(createCasualConfiguration());
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { Parser, ParsingContext } from "../../../chrono";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import * as references from "../../../common/casualReferences";
|
|
5
5
|
|
|
6
|
-
const PATTERN =
|
|
6
|
+
const PATTERN = /今日|きょう|当日|とうじつ|昨日|きのう|明日|あした|今夜|こんや|今夕|こんゆう|今晩|こんばん|今朝|けさ/i;
|
|
7
|
+
|
|
8
|
+
function normalizeTextToKanji(text: string) {
|
|
9
|
+
switch (text) {
|
|
10
|
+
case "きょう":
|
|
11
|
+
return "今日";
|
|
12
|
+
case "とうじつ":
|
|
13
|
+
return "当日";
|
|
14
|
+
case "きのう":
|
|
15
|
+
return "昨日";
|
|
16
|
+
case "あした":
|
|
17
|
+
return "明日";
|
|
18
|
+
case "こんや":
|
|
19
|
+
return "今夜";
|
|
20
|
+
case "こんゆう":
|
|
21
|
+
return "今夕";
|
|
22
|
+
case "こんばん":
|
|
23
|
+
return "今晩";
|
|
24
|
+
case "けさ":
|
|
25
|
+
return "今朝";
|
|
26
|
+
default:
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
7
30
|
|
|
8
31
|
export default class JPCasualDateParser implements Parser {
|
|
9
32
|
pattern() {
|
|
@@ -11,7 +34,7 @@ export default class JPCasualDateParser implements Parser {
|
|
|
11
34
|
}
|
|
12
35
|
|
|
13
36
|
extract(context: ParsingContext, match: RegExpMatchArray) {
|
|
14
|
-
const text = match[0];
|
|
37
|
+
const text = normalizeTextToKanji(match[0]);
|
|
15
38
|
|
|
16
39
|
const date = dayjs(context.refDate);
|
|
17
40
|
const components = context.createParsingComponents();
|
package/src/locales/nl/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 } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import NLMergeDateRangeRefiner from "./refiners/NLMergeDateRangeRefiner";
|
|
11
12
|
import NLMergeDateTimeRefiner from "./refiners/NLMergeDateTimeRefiner";
|
|
12
13
|
import NLCasualDateParser from "./parsers/NLCasualDateParser";
|
|
@@ -25,6 +26,9 @@ import NLRelativeDateFormatParser from "./parsers/NLRelativeDateFormatParser";
|
|
|
25
26
|
import NLTimeUnitAgoFormatParser from "./parsers/NLTimeUnitAgoFormatParser";
|
|
26
27
|
import NLTimeUnitLaterFormatParser from "./parsers/NLTimeUnitLaterFormatParser";
|
|
27
28
|
|
|
29
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
30
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
31
|
+
|
|
28
32
|
// Shortcuts
|
|
29
33
|
export const casual = new Chrono(createCasualConfiguration());
|
|
30
34
|
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 { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
-
import { Meridiem } from "../../../
|
|
4
|
+
import { Meridiem } from "../../../types";
|
|
5
5
|
import { assignSimilarDate, assignTheNextDay } from "../../../utils/dayjs";
|
|
6
6
|
import dayjs from "dayjs";
|
|
7
7
|
|
|
@@ -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 dayjs from "dayjs";
|
|
5
5
|
import { assignTheNextDay } from "../../../utils/dayjs";
|
package/src/locales/pt/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 } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
11
12
|
import PTWeekdayParser from "./parsers/PTWeekdayParser";
|
|
12
13
|
import PTTimeExpressionParser from "./parsers/PTTimeExpressionParser";
|
|
@@ -16,6 +17,9 @@ import PTMonthNameLittleEndianParser from "./parsers/PTMonthNameLittleEndianPars
|
|
|
16
17
|
import PTCasualDateParser from "./parsers/PTCasualDateParser";
|
|
17
18
|
import PTCasualTimeParser from "./parsers/PTCasualTimeParser";
|
|
18
19
|
|
|
20
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
21
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
22
|
+
|
|
19
23
|
// Shortcuts
|
|
20
24
|
export const casual = new Chrono(createCasualConfiguration());
|
|
21
25
|
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";
|
|
@@ -219,6 +219,9 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
219
219
|
минуток: "minute",
|
|
220
220
|
минутки: "minute",
|
|
221
221
|
минутку: "minute",
|
|
222
|
+
минуточек: "minute",
|
|
223
|
+
минуточки: "minute",
|
|
224
|
+
минуточку: "minute",
|
|
222
225
|
час: "hour",
|
|
223
226
|
часов: "hour",
|
|
224
227
|
часа: "hour",
|
|
@@ -284,7 +287,7 @@ export function parseNumberPattern(match: string): number {
|
|
|
284
287
|
|
|
285
288
|
export const ORDINAL_NUMBER_PATTERN = `(?:${matchAnyPattern(ORDINAL_WORD_DICTIONARY)}|[0-9]{1,2}(?:го|ого|е|ое)?)`;
|
|
286
289
|
export function parseOrdinalNumberPattern(match: string): number {
|
|
287
|
-
|
|
290
|
+
const num = match.toLowerCase();
|
|
288
291
|
if (ORDINAL_WORD_DICTIONARY[num] !== undefined) {
|
|
289
292
|
return ORDINAL_WORD_DICTIONARY[num];
|
|
290
293
|
}
|
package/src/locales/ru/index.ts
CHANGED
|
@@ -18,11 +18,15 @@ import RUCasualTimeParser from "./parsers/RUCasualTimeParser";
|
|
|
18
18
|
import RUWeekdayParser from "./parsers/RUWeekdayParser";
|
|
19
19
|
import RURelativeDateFormatParser from "./parsers/RURelativeDateFormatParser";
|
|
20
20
|
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
22
|
+
import { ParsingResult } from "../../results";
|
|
23
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
23
24
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
24
25
|
import RUTimeUnitCasualRelativeFormatParser from "./parsers/RUTimeUnitCasualRelativeFormatParser";
|
|
25
26
|
|
|
27
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
28
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* Chrono object configured for parsing *casual* Russian
|
|
28
32
|
*/
|
|
@@ -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
|
import { REGEX_PARTS } from "../constants";
|
|
6
6
|
|