chrono-node 2.9.0 → 2.9.2
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 +2 -2
- package/dist/cjs/calculation/mergingCalculation.js +4 -1
- package/dist/cjs/calculation/mergingCalculation.js.map +1 -1
- package/dist/cjs/common/refiners/ForwardDateRefiner.js +8 -13
- package/dist/cjs/common/refiners/ForwardDateRefiner.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DECasualTimeParser.js +7 -0
- package/dist/cjs/locales/de/parsers/DECasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.js +1 -1
- package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/configuration.js +2 -0
- package/dist/cjs/locales/en/configuration.js.map +1 -1
- package/dist/cjs/locales/en/constants.d.ts +1 -1
- package/dist/cjs/locales/en/constants.js +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameLittleEndianParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameLittleEndianParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENWeekdayParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENWeekdayParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENYearMonthNameParser.d.ts +6 -0
- package/dist/cjs/locales/en/parsers/ENYearMonthNameParser.js +31 -0
- package/dist/cjs/locales/en/parsers/ENYearMonthNameParser.js.map +1 -0
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js +5 -0
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/fi/constants.d.ts +24 -0
- package/dist/cjs/locales/fi/constants.js +197 -0
- package/dist/cjs/locales/fi/constants.js.map +1 -0
- package/dist/cjs/locales/fi/index.d.ts +11 -0
- package/dist/cjs/locales/fi/index.js +62 -0
- package/dist/cjs/locales/fi/index.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FICasualDateParser.d.ts +7 -0
- package/dist/cjs/locales/fi/parsers/FICasualDateParser.js +102 -0
- package/dist/cjs/locales/fi/parsers/FICasualDateParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FICasualTimeParser.d.ts +8 -0
- package/dist/cjs/locales/fi/parsers/FICasualTimeParser.js +77 -0
- package/dist/cjs/locales/fi/parsers/FICasualTimeParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FIMonthNameLittleEndianParser.d.ts +7 -0
- package/dist/cjs/locales/fi/parsers/FIMonthNameLittleEndianParser.js +48 -0
- package/dist/cjs/locales/fi/parsers/FIMonthNameLittleEndianParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FITimeExpressionParser.d.ts +8 -0
- package/dist/cjs/locales/fi/parsers/FITimeExpressionParser.js +19 -0
- package/dist/cjs/locales/fi/parsers/FITimeExpressionParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitAgoFormatParser.d.ts +7 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitAgoFormatParser.js +18 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitAgoFormatParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.d.ts +9 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.js +39 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitWithinFormatParser.d.ts +7 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitWithinFormatParser.js +16 -0
- package/dist/cjs/locales/fi/parsers/FITimeUnitWithinFormatParser.js.map +1 -0
- package/dist/cjs/locales/fi/parsers/FIWeekdayParser.d.ts +7 -0
- package/dist/cjs/locales/fi/parsers/FIWeekdayParser.js +39 -0
- package/dist/cjs/locales/fi/parsers/FIWeekdayParser.js.map +1 -0
- package/dist/cjs/locales/fi/refiners/FIMergeDateRangeRefiner.d.ts +4 -0
- package/dist/cjs/locales/fi/refiners/FIMergeDateRangeRefiner.js +13 -0
- package/dist/cjs/locales/fi/refiners/FIMergeDateRangeRefiner.js.map +1 -0
- package/dist/cjs/locales/fi/refiners/FIMergeDateTimeRefiner.d.ts +4 -0
- package/dist/cjs/locales/fi/refiners/FIMergeDateTimeRefiner.js +13 -0
- package/dist/cjs/locales/fi/refiners/FIMergeDateTimeRefiner.js.map +1 -0
- package/dist/cjs/locales/fr/parsers/FRCasualTimeParser.js +5 -0
- package/dist/cjs/locales/fr/parsers/FRCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +2 -1
- package/dist/cjs/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js +5 -0
- package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.js +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js +5 -0
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js +5 -0
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/vi/constants.d.ts +20 -0
- package/dist/cjs/locales/vi/constants.js +107 -0
- package/dist/cjs/locales/vi/constants.js.map +1 -0
- package/dist/cjs/locales/vi/index.d.ts +11 -0
- package/dist/cjs/locales/vi/index.js +73 -0
- package/dist/cjs/locales/vi/index.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VICasualDateParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VICasualDateParser.js +63 -0
- package/dist/cjs/locales/vi/parsers/VICasualDateParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VICasualTimeParser.d.ts +8 -0
- package/dist/cjs/locales/vi/parsers/VICasualTimeParser.js +59 -0
- package/dist/cjs/locales/vi/parsers/VICasualTimeParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VIMonthYearParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VIMonthYearParser.js +30 -0
- package/dist/cjs/locales/vi/parsers/VIMonthYearParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VIStandardParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VIStandardParser.js +39 -0
- package/dist/cjs/locales/vi/parsers/VIStandardParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VITimeExpressionParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VITimeExpressionParser.js +60 -0
- package/dist/cjs/locales/vi/parsers/VITimeExpressionParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitAgoFormatParser.d.ts +9 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitAgoFormatParser.js +24 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitAgoFormatParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.js +37 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitLaterFormatParser.d.ts +9 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitLaterFormatParser.js +23 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitLaterFormatParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitWithinFormatParser.d.ts +9 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitWithinFormatParser.js +23 -0
- package/dist/cjs/locales/vi/parsers/VITimeUnitWithinFormatParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VIWeekdayParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VIWeekdayParser.js +36 -0
- package/dist/cjs/locales/vi/parsers/VIWeekdayParser.js.map +1 -0
- package/dist/cjs/locales/vi/parsers/VIYearParser.d.ts +7 -0
- package/dist/cjs/locales/vi/parsers/VIYearParser.js +29 -0
- package/dist/cjs/locales/vi/parsers/VIYearParser.js.map +1 -0
- package/dist/cjs/locales/vi/refiners/VIMergeDateRangeRefiner.d.ts +4 -0
- package/dist/cjs/locales/vi/refiners/VIMergeDateRangeRefiner.js +13 -0
- package/dist/cjs/locales/vi/refiners/VIMergeDateRangeRefiner.js.map +1 -0
- package/dist/cjs/locales/vi/refiners/VIMergeDateTimeRefiner.d.ts +4 -0
- package/dist/cjs/locales/vi/refiners/VIMergeDateTimeRefiner.js +13 -0
- package/dist/cjs/locales/vi/refiners/VIMergeDateTimeRefiner.js.map +1 -0
- package/dist/cjs/locales/vi/refiners/VIMergeWeekdayComponentRefiner.d.ts +3 -0
- package/dist/cjs/locales/vi/refiners/VIMergeWeekdayComponentRefiner.js +10 -0
- package/dist/cjs/locales/vi/refiners/VIMergeWeekdayComponentRefiner.js.map +1 -0
- package/dist/cjs/locales/zh/hans/index.js +2 -0
- package/dist/cjs/locales/zh/hans/index.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansAgoFormatParser.d.ts +6 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansAgoFormatParser.js +80 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansAgoFormatParser.js.map +1 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +10 -4
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/index.js +2 -0
- package/dist/cjs/locales/zh/hant/index.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantAgoFormatParser.d.ts +6 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantAgoFormatParser.js +80 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantAgoFormatParser.js.map +1 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +8 -2
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -1
- package/dist/cjs/results.js +1 -1
- package/dist/cjs/results.js.map +1 -1
- package/dist/esm/calculation/mergingCalculation.js +4 -1
- package/dist/esm/calculation/mergingCalculation.js.map +1 -1
- package/dist/esm/common/refiners/ForwardDateRefiner.js +8 -13
- package/dist/esm/common/refiners/ForwardDateRefiner.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/locales/de/parsers/DECasualTimeParser.js +7 -0
- package/dist/esm/locales/de/parsers/DECasualTimeParser.js.map +1 -1
- package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.js +1 -1
- package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/en/configuration.js +2 -0
- package/dist/esm/locales/en/configuration.js.map +1 -1
- package/dist/esm/locales/en/constants.d.ts +1 -1
- package/dist/esm/locales/en/constants.js +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameLittleEndianParser.js +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameLittleEndianParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENWeekdayParser.js +1 -1
- package/dist/esm/locales/en/parsers/ENWeekdayParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENYearMonthNameParser.d.ts +6 -0
- package/dist/esm/locales/en/parsers/ENYearMonthNameParser.js +28 -0
- package/dist/esm/locales/en/parsers/ENYearMonthNameParser.js.map +1 -0
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.js +5 -0
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/fi/constants.d.ts +24 -0
- package/dist/esm/locales/fi/constants.js +191 -0
- package/dist/esm/locales/fi/constants.js.map +1 -0
- package/dist/esm/locales/fi/index.d.ts +11 -0
- package/dist/esm/locales/fi/index.js +48 -0
- package/dist/esm/locales/fi/index.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FICasualDateParser.d.ts +7 -0
- package/dist/esm/locales/fi/parsers/FICasualDateParser.js +63 -0
- package/dist/esm/locales/fi/parsers/FICasualDateParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FICasualTimeParser.d.ts +8 -0
- package/dist/esm/locales/fi/parsers/FICasualTimeParser.js +74 -0
- package/dist/esm/locales/fi/parsers/FICasualTimeParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FIMonthNameLittleEndianParser.d.ts +7 -0
- package/dist/esm/locales/fi/parsers/FIMonthNameLittleEndianParser.js +45 -0
- package/dist/esm/locales/fi/parsers/FIMonthNameLittleEndianParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FITimeExpressionParser.d.ts +8 -0
- package/dist/esm/locales/fi/parsers/FITimeExpressionParser.js +16 -0
- package/dist/esm/locales/fi/parsers/FITimeExpressionParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitAgoFormatParser.d.ts +7 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitAgoFormatParser.js +15 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitAgoFormatParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.d.ts +9 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.js +37 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitWithinFormatParser.d.ts +7 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitWithinFormatParser.js +13 -0
- package/dist/esm/locales/fi/parsers/FITimeUnitWithinFormatParser.js.map +1 -0
- package/dist/esm/locales/fi/parsers/FIWeekdayParser.d.ts +7 -0
- package/dist/esm/locales/fi/parsers/FIWeekdayParser.js +36 -0
- package/dist/esm/locales/fi/parsers/FIWeekdayParser.js.map +1 -0
- package/dist/esm/locales/fi/refiners/FIMergeDateRangeRefiner.d.ts +4 -0
- package/dist/esm/locales/fi/refiners/FIMergeDateRangeRefiner.js +7 -0
- package/dist/esm/locales/fi/refiners/FIMergeDateRangeRefiner.js.map +1 -0
- package/dist/esm/locales/fi/refiners/FIMergeDateTimeRefiner.d.ts +4 -0
- package/dist/esm/locales/fi/refiners/FIMergeDateTimeRefiner.js +7 -0
- package/dist/esm/locales/fi/refiners/FIMergeDateTimeRefiner.js.map +1 -0
- package/dist/esm/locales/fr/parsers/FRCasualTimeParser.js +5 -0
- package/dist/esm/locales/fr/parsers/FRCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +2 -1
- package/dist/esm/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITCasualTimeParser.js +5 -0
- package/dist/esm/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeExpressionParser.js +1 -1
- package/dist/esm/locales/it/parsers/ITTimeExpressionParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js +5 -0
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js +5 -0
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/vi/constants.d.ts +20 -0
- package/dist/esm/locales/vi/constants.js +101 -0
- package/dist/esm/locales/vi/constants.js.map +1 -0
- package/dist/esm/locales/vi/index.d.ts +11 -0
- package/dist/esm/locales/vi/index.js +59 -0
- package/dist/esm/locales/vi/index.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VICasualDateParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VICasualDateParser.js +27 -0
- package/dist/esm/locales/vi/parsers/VICasualDateParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VICasualTimeParser.d.ts +8 -0
- package/dist/esm/locales/vi/parsers/VICasualTimeParser.js +56 -0
- package/dist/esm/locales/vi/parsers/VICasualTimeParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VIMonthYearParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VIMonthYearParser.js +27 -0
- package/dist/esm/locales/vi/parsers/VIMonthYearParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VIStandardParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VIStandardParser.js +36 -0
- package/dist/esm/locales/vi/parsers/VIStandardParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VITimeExpressionParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VITimeExpressionParser.js +56 -0
- package/dist/esm/locales/vi/parsers/VITimeExpressionParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitAgoFormatParser.d.ts +9 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitAgoFormatParser.js +22 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitAgoFormatParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.js +34 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitLaterFormatParser.d.ts +9 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitLaterFormatParser.js +21 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitLaterFormatParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitWithinFormatParser.d.ts +9 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitWithinFormatParser.js +21 -0
- package/dist/esm/locales/vi/parsers/VITimeUnitWithinFormatParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VIWeekdayParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VIWeekdayParser.js +33 -0
- package/dist/esm/locales/vi/parsers/VIWeekdayParser.js.map +1 -0
- package/dist/esm/locales/vi/parsers/VIYearParser.d.ts +7 -0
- package/dist/esm/locales/vi/parsers/VIYearParser.js +26 -0
- package/dist/esm/locales/vi/parsers/VIYearParser.js.map +1 -0
- package/dist/esm/locales/vi/refiners/VIMergeDateRangeRefiner.d.ts +4 -0
- package/dist/esm/locales/vi/refiners/VIMergeDateRangeRefiner.js +7 -0
- package/dist/esm/locales/vi/refiners/VIMergeDateRangeRefiner.js.map +1 -0
- package/dist/esm/locales/vi/refiners/VIMergeDateTimeRefiner.d.ts +4 -0
- package/dist/esm/locales/vi/refiners/VIMergeDateTimeRefiner.js +7 -0
- package/dist/esm/locales/vi/refiners/VIMergeDateTimeRefiner.js.map +1 -0
- package/dist/esm/locales/vi/refiners/VIMergeWeekdayComponentRefiner.d.ts +3 -0
- package/dist/esm/locales/vi/refiners/VIMergeWeekdayComponentRefiner.js +4 -0
- package/dist/esm/locales/vi/refiners/VIMergeWeekdayComponentRefiner.js.map +1 -0
- package/dist/esm/locales/zh/hans/index.js +2 -0
- package/dist/esm/locales/zh/hans/index.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansAgoFormatParser.d.ts +6 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansAgoFormatParser.js +77 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansAgoFormatParser.js.map +1 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +1 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +10 -4
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/index.js +2 -0
- package/dist/esm/locales/zh/hant/index.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantAgoFormatParser.d.ts +6 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantAgoFormatParser.js +77 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantAgoFormatParser.js.map +1 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +1 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +8 -2
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -1
- package/dist/esm/results.js +1 -1
- package/dist/esm/results.js.map +1 -1
- package/package.json +2 -2
- package/src/calculation/mergingCalculation.ts +7 -1
- package/src/common/refiners/ForwardDateRefiner.ts +8 -14
- package/src/index.ts +3 -1
- package/src/locales/de/parsers/DECasualTimeParser.ts +7 -0
- package/src/locales/de/parsers/DETimeUnitRelativeFormatParser.ts +1 -1
- package/src/locales/en/configuration.ts +2 -0
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/parsers/ENMonthNameLittleEndianParser.ts +1 -1
- package/src/locales/en/parsers/ENWeekdayParser.ts +1 -1
- package/src/locales/en/parsers/ENYearMonthNameParser.ts +38 -0
- package/src/locales/es/parsers/ESCasualTimeParser.ts +5 -0
- package/src/locales/fi/constants.ts +209 -0
- package/src/locales/fi/index.ts +57 -0
- package/src/locales/fi/parsers/FICasualDateParser.ts +82 -0
- package/src/locales/fi/parsers/FICasualTimeParser.ts +85 -0
- package/src/locales/fi/parsers/FIMonthNameLittleEndianParser.ts +57 -0
- package/src/locales/fi/parsers/FITimeExpressionParser.ts +22 -0
- package/src/locales/fi/parsers/FITimeUnitAgoFormatParser.ts +18 -0
- package/src/locales/fi/parsers/FITimeUnitCasualRelativeFormatParser.ts +47 -0
- package/src/locales/fi/parsers/FITimeUnitWithinFormatParser.ts +15 -0
- package/src/locales/fi/parsers/FIWeekdayParser.ts +46 -0
- package/src/locales/fi/refiners/FIMergeDateRangeRefiner.ts +7 -0
- package/src/locales/fi/refiners/FIMergeDateTimeRefiner.ts +7 -0
- package/src/locales/fr/parsers/FRCasualTimeParser.ts +5 -0
- package/src/locales/fr/parsers/FRTimeUnitRelativeFormatParser.ts +2 -1
- package/src/locales/it/parsers/ITCasualTimeParser.ts +5 -0
- package/src/locales/it/parsers/ITTimeExpressionParser.ts +1 -1
- package/src/locales/nl/parsers/NLCasualTimeParser.ts +5 -0
- package/src/locales/pt/parsers/PTCasualTimeParser.ts +5 -0
- package/src/locales/uk/parsers/UKTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/vi/constants.ts +113 -0
- package/src/locales/vi/index.ts +73 -0
- package/src/locales/vi/parsers/VICasualDateParser.ts +31 -0
- package/src/locales/vi/parsers/VICasualTimeParser.ts +62 -0
- package/src/locales/vi/parsers/VIMonthYearParser.ts +35 -0
- package/src/locales/vi/parsers/VIStandardParser.ts +45 -0
- package/src/locales/vi/parsers/VITimeExpressionParser.ts +66 -0
- package/src/locales/vi/parsers/VITimeUnitAgoFormatParser.ts +23 -0
- package/src/locales/vi/parsers/VITimeUnitCasualRelativeFormatParser.ts +46 -0
- package/src/locales/vi/parsers/VITimeUnitLaterFormatParser.ts +25 -0
- package/src/locales/vi/parsers/VITimeUnitWithinFormatParser.ts +22 -0
- package/src/locales/vi/parsers/VIWeekdayParser.ts +41 -0
- package/src/locales/vi/parsers/VIYearParser.ts +31 -0
- package/src/locales/vi/refiners/VIMergeDateRangeRefiner.ts +7 -0
- package/src/locales/vi/refiners/VIMergeDateTimeRefiner.ts +7 -0
- package/src/locales/vi/refiners/VIMergeWeekdayComponentRefiner.ts +7 -0
- package/src/locales/zh/hans/index.ts +2 -0
- package/src/locales/zh/hans/parsers/ZHHansAgoFormatParser.ts +87 -0
- package/src/locales/zh/hans/parsers/ZHHansTimeExpressionParser.ts +15 -4
- package/src/locales/zh/hant/index.ts +2 -0
- package/src/locales/zh/hant/parsers/ZHHantAgoFormatParser.ts +87 -0
- package/src/locales/zh/hant/parsers/ZHHantTimeExpressionParser.ts +14 -2
- package/src/results.ts +1 -3
- package/test/de/de_casual.test.ts +14 -0
- package/test/de/de_time_units_casual_relative.test.ts +12 -0
- package/test/en/en_month.test.ts +44 -0
- package/test/en/en_month_name_little_endian.test.ts +30 -0
- package/test/en/en_time_units_casual_relative.test.ts +11 -0
- package/test/en/en_weekday.test.ts +123 -0
- package/test/fi/fi_casual.test.ts +99 -0
- package/test/fi/fi_casual_time.test.ts +56 -0
- package/test/fi/fi_month_name_little_endian.test.ts +50 -0
- package/test/fi/fi_time_exp.test.ts +39 -0
- package/test/fi/fi_time_units_ago.test.ts +93 -0
- package/test/fi/fi_time_units_casual_relative.test.ts +117 -0
- package/test/fi/fi_time_units_within.test.ts +74 -0
- package/test/fi/fi_weekday.test.ts +90 -0
- package/test/fr/fr_casual.test.ts +14 -0
- package/test/fr/fr_time_units_casual_relative.test.ts +6 -0
- package/test/it/it_casual.test.ts +37 -0
- package/test/it/it_month_name_middle_endian.test.ts +39 -0
- package/test/it/it_time_exp.test.ts +84 -0
- package/test/it/it_year_month_day.test.ts +41 -0
- package/test/result.test.ts +8 -0
- package/test/system.test.ts +4 -3
- package/test/system_timezone.test.ts +99 -0
- package/test/uk/uk_time_units_within.test.ts +8 -1
- package/test/vi/vi_casual.test.ts +84 -0
- package/test/vi/vi_casual_time.test.ts +77 -0
- package/test/vi/vi_date_range.test.ts +61 -0
- package/test/vi/vi_forward_date.test.ts +45 -0
- package/test/vi/vi_month_year.test.ts +40 -0
- package/test/vi/vi_negative_cases.test.ts +60 -0
- package/test/vi/vi_slash.test.ts +36 -0
- package/test/vi/vi_standard.test.ts +86 -0
- package/test/vi/vi_strict.test.ts +67 -0
- package/test/vi/vi_time_exp.test.ts +99 -0
- package/test/vi/vi_time_units_ago.test.ts +56 -0
- package/test/vi/vi_time_units_casual_relative.test.ts +56 -0
- package/test/vi/vi_time_units_later.test.ts +43 -0
- package/test/vi/vi_time_units_within.test.ts +24 -0
- package/test/vi/vi_weekday.test.ts +77 -0
- package/test/vi/vi_year.test.ts +42 -0
- package/test/zh/hans/zh_hans_ago.test.ts +58 -0
- package/test/zh/hans/zh_hans_time_exp.test.ts +252 -6
- package/test/zh/hant/zh_hant_ago.test.ts +58 -0
- package/test/zh/hant/zh_hant_time_exp.test.ts +30 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { findYearClosestToRef } from "../../../calculation/years";
|
|
4
|
+
import { YEAR_PATTERN, parseYear } from "../constants";
|
|
5
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
+
|
|
7
|
+
// ngày 15 tháng 3 năm 1975 | 15 tháng 3 năm 1975 | 15 tháng 3
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
"(?:ng\u00e0y\\s*)?" +
|
|
10
|
+
"([0-9]{1,2})" +
|
|
11
|
+
"\\s*th\u00e1ng\\s*" +
|
|
12
|
+
"([0-9]{1,2})" +
|
|
13
|
+
"(?:\\s*n\u0103m\\s*(" +
|
|
14
|
+
YEAR_PATTERN +
|
|
15
|
+
"))?" +
|
|
16
|
+
"(?=\\W|$)",
|
|
17
|
+
"i"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const DAY_GROUP = 1;
|
|
21
|
+
const MONTH_GROUP = 2;
|
|
22
|
+
const YEAR_GROUP = 3;
|
|
23
|
+
|
|
24
|
+
export default class VIStandardParser extends AbstractParserWithWordBoundaryChecking {
|
|
25
|
+
innerPattern(): RegExp {
|
|
26
|
+
return PATTERN;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
30
|
+
const day = parseInt(match[DAY_GROUP]);
|
|
31
|
+
const month = parseInt(match[MONTH_GROUP]);
|
|
32
|
+
if (day > 31 || month > 12) return null;
|
|
33
|
+
|
|
34
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
35
|
+
result.start.assign("day", day);
|
|
36
|
+
result.start.assign("month", month);
|
|
37
|
+
|
|
38
|
+
if (match[YEAR_GROUP]) {
|
|
39
|
+
result.start.assign("year", parseYear(match[YEAR_GROUP]));
|
|
40
|
+
} else {
|
|
41
|
+
result.start.imply("year", findYearClosestToRef(context.refDate, day, month));
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
import { Meridiem } from "../../../types";
|
|
5
|
+
|
|
6
|
+
// l\u00fac 7 gi\u1edd 30 ph\u00fat | 7 gi\u1edd s\u00e1ng | 7 gi\u1edd | 15:30
|
|
7
|
+
const PATTERN = new RegExp(
|
|
8
|
+
"(?:l\u00fac\\s*|v\u00e0o\\s*)?" +
|
|
9
|
+
"([0-9]{1,2})" +
|
|
10
|
+
"(?:\\s*gi\u1edd\\s*([0-9]{1,2})?\\s*(?:ph\u00fat\\s*)?" +
|
|
11
|
+
"(s\u00e1ng|tr\u01b0a|chi\u1ec1u|t\u1ed1i|\u0111\u00eam)?" +
|
|
12
|
+
"|:([0-9]{2}))" +
|
|
13
|
+
"(?=\\W|$)",
|
|
14
|
+
"i"
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const HOUR_GROUP = 1;
|
|
18
|
+
const MINUTE_GIO_GROUP = 2;
|
|
19
|
+
const MERIDIEM_GROUP = 3;
|
|
20
|
+
const MINUTE_COLON_GROUP = 4;
|
|
21
|
+
|
|
22
|
+
export default class VITimeExpressionParser extends AbstractParserWithWordBoundaryChecking {
|
|
23
|
+
innerPattern(): RegExp {
|
|
24
|
+
return PATTERN;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
28
|
+
const hour = parseInt(match[HOUR_GROUP]);
|
|
29
|
+
if (hour > 23) return null;
|
|
30
|
+
|
|
31
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
32
|
+
result.start.assign("hour", hour);
|
|
33
|
+
|
|
34
|
+
const minute = match[MINUTE_COLON_GROUP]
|
|
35
|
+
? parseInt(match[MINUTE_COLON_GROUP])
|
|
36
|
+
: match[MINUTE_GIO_GROUP]
|
|
37
|
+
? parseInt(match[MINUTE_GIO_GROUP])
|
|
38
|
+
: 0;
|
|
39
|
+
if (minute >= 60) return null;
|
|
40
|
+
result.start.assign("minute", minute);
|
|
41
|
+
|
|
42
|
+
const meridiem = match[MERIDIEM_GROUP]?.toLowerCase();
|
|
43
|
+
if (meridiem === "sáng") {
|
|
44
|
+
// "12 giờ sáng" = midnight (00:00), matching EN convention
|
|
45
|
+
result.start.assign("meridiem", Meridiem.AM);
|
|
46
|
+
if (hour === 12) result.start.assign("hour", 0);
|
|
47
|
+
} else if (meridiem === "trưa") {
|
|
48
|
+
// "trưa" = noon/midday (~11 AM - 1 PM)
|
|
49
|
+
// "1 giờ trưa" = 13:00, but "11 giờ trưa" = 11:00 (approaching noon)
|
|
50
|
+
if (hour < 10) {
|
|
51
|
+
result.start.assign("meridiem", Meridiem.PM);
|
|
52
|
+
result.start.assign("hour", hour + 12);
|
|
53
|
+
} else {
|
|
54
|
+
// 10-12: keep as-is (AM for 10-11, PM for 12)
|
|
55
|
+
result.start.assign("meridiem", hour >= 12 ? Meridiem.PM : Meridiem.AM);
|
|
56
|
+
}
|
|
57
|
+
} else if (meridiem === "chiều" || meridiem === "tối" || meridiem === "đêm") {
|
|
58
|
+
result.start.assign("meridiem", Meridiem.PM);
|
|
59
|
+
if (hour < 12) result.start.assign("hour", hour + 12);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
result.start.imply("second", 0);
|
|
63
|
+
result.start.imply("millisecond", 0);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
|
+
|
|
7
|
+
// 2 ng\u00e0y tr\u01b0\u1edbc | 3 th\u00e1ng qua | 1 n\u0103m tr\u01b0\u1edbc
|
|
8
|
+
const PATTERN = new RegExp("(" + TIME_UNITS_PATTERN + ")" + "\\s{0,5}(?:tr\u01b0\u1edbc|qua)(?=\\W|$)", "i");
|
|
9
|
+
export default class VITimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
10
|
+
constructor(private strictMode = false) {
|
|
11
|
+
super();
|
|
12
|
+
}
|
|
13
|
+
innerPattern(): RegExp {
|
|
14
|
+
// VI has no unit abbreviations, so strict and casual patterns are identical.
|
|
15
|
+
return PATTERN;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
19
|
+
const duration = parseDuration(match[1]);
|
|
20
|
+
if (!duration) return null;
|
|
21
|
+
return ParsingComponents.createRelativeFromReference(context.reference, reverseDuration(duration));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TIME_UNIT_DICTIONARY, NUMBER_PATTERN, parseDuration } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
|
+
|
|
8
|
+
// tuần này | tháng trước | năm sau | tuần tới | 2 tuần trước
|
|
9
|
+
// NUMBER is optional so bare unit words ("tuần này") are matched
|
|
10
|
+
const CASUAL_UNIT_PATTERN = "(?:" + NUMBER_PATTERN + "\\s{0,5})?(?:" + matchAnyPattern(TIME_UNIT_DICTIONARY) + ")";
|
|
11
|
+
|
|
12
|
+
const PATTERN = new RegExp(
|
|
13
|
+
"(này|trước|qua|sau|tới|tiếp)\\s*(" +
|
|
14
|
+
CASUAL_UNIT_PATTERN +
|
|
15
|
+
")" +
|
|
16
|
+
"|(" +
|
|
17
|
+
CASUAL_UNIT_PATTERN +
|
|
18
|
+
")\\s*(này|trước|qua|sau|tới|tiếp)" +
|
|
19
|
+
"(?=\\W|$)",
|
|
20
|
+
"i"
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export default class VITimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
24
|
+
innerPattern(): RegExp {
|
|
25
|
+
return PATTERN;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
29
|
+
// prefix form (trước tuần) or suffix form (tuần trước)
|
|
30
|
+
const modifier = (match[1] || match[4] || "").toLowerCase();
|
|
31
|
+
const unitText = (match[2] || match[3] || "").toLowerCase();
|
|
32
|
+
|
|
33
|
+
let duration = parseDuration(unitText);
|
|
34
|
+
if (Object.keys(duration).length === 0) {
|
|
35
|
+
// bare unit word with no number — implies 1
|
|
36
|
+
const unit = TIME_UNIT_DICTIONARY[unitText];
|
|
37
|
+
if (!unit) return null;
|
|
38
|
+
duration = { [unit]: 1 };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (modifier === "trước" || modifier === "qua") {
|
|
42
|
+
duration = reverseDuration(duration);
|
|
43
|
+
}
|
|
44
|
+
return ParsingComponents.createRelativeFromReference(context.reference, duration);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
|
|
6
|
+
// 2 ng\u00e0y sau | 3 tu\u1ea7n n\u1eefa | 1 th\u00e1ng t\u1edbi
|
|
7
|
+
const PATTERN = new RegExp(
|
|
8
|
+
"(" + TIME_UNITS_PATTERN + ")" + "\\s{0,5}(?:sau|n\u1eefa|t\u1edbi|ti\u1ebfp)(?=\\W|$)",
|
|
9
|
+
"i"
|
|
10
|
+
);
|
|
11
|
+
export default class VITimeUnitLaterFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
12
|
+
constructor(private strictMode = false) {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
innerPattern(): RegExp {
|
|
16
|
+
// VI has no unit abbreviations, so strict and casual patterns are identical.
|
|
17
|
+
return PATTERN;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
21
|
+
const duration = parseDuration(match[1]);
|
|
22
|
+
if (!duration) return null;
|
|
23
|
+
return ParsingComponents.createRelativeFromReference(context.reference, duration);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
|
|
6
|
+
// trong 2 ng\u00e0y | trong 3 tu\u1ea7n | trong v\u00f2ng 1 th\u00e1ng
|
|
7
|
+
const PATTERN = new RegExp("(?:trong\\s*(?:v\u00f2ng\\s*)?)" + "(" + TIME_UNITS_PATTERN + ")(?=\\W|$)", "i");
|
|
8
|
+
export default class VITimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
9
|
+
constructor(private strictMode = false) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
innerPattern(): RegExp {
|
|
13
|
+
// VI has no unit abbreviations, so strict and casual patterns are identical.
|
|
14
|
+
return PATTERN;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
18
|
+
const timeUnits = parseDuration(match[1]);
|
|
19
|
+
if (!timeUnits) return null;
|
|
20
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { WEEKDAY_DICTIONARY } from "../constants";
|
|
4
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
+
import { createParsingComponentsAtWeekday } from "../../../calculation/weekdays";
|
|
7
|
+
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
"(" +
|
|
10
|
+
matchAnyPattern(WEEKDAY_DICTIONARY) +
|
|
11
|
+
")" +
|
|
12
|
+
// 'sau khi' is a conjunction ("after when") — exclude via negative lookahead
|
|
13
|
+
"(?:\\s*(này|tới|sau(?!\\s*khi)|qua))?" +
|
|
14
|
+
"(?=\\W|$)",
|
|
15
|
+
"i"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const WEEKDAY_GROUP = 1;
|
|
19
|
+
const MODIFIER_GROUP = 2;
|
|
20
|
+
|
|
21
|
+
export default class VIWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
22
|
+
innerPattern(): RegExp {
|
|
23
|
+
return PATTERN;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
27
|
+
const dowText = match[WEEKDAY_GROUP].toLowerCase();
|
|
28
|
+
const dow = WEEKDAY_DICTIONARY[dowText];
|
|
29
|
+
if (dow === undefined) return null;
|
|
30
|
+
|
|
31
|
+
const modifier = match[MODIFIER_GROUP];
|
|
32
|
+
let modifierType: "this" | "next" | "last" | null = null;
|
|
33
|
+
if (modifier) {
|
|
34
|
+
const m = modifier.toLowerCase();
|
|
35
|
+
if (m.includes("tới") || m.includes("sau")) modifierType = "next";
|
|
36
|
+
else if (m.includes("qua")) modifierType = "last";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return createParsingComponentsAtWeekday(context.reference, dow, modifierType);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { YEAR_PATTERN, parseYear } from "../constants";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
|
|
6
|
+
// năm 1975 | năm 43 TCN | 179 TCN (bare BC year without năm prefix)
|
|
7
|
+
const PATTERN = new RegExp("(?:\\bnăm\\s*(" + YEAR_PATTERN + ")|\\b([0-9]{1,4})\\s*(TCN))(?=\\W|$)", "i");
|
|
8
|
+
|
|
9
|
+
const YEAR_WITH_NAM_GROUP = 1; // năm YYYY or năm YYYY TCN
|
|
10
|
+
const BARE_BC_YEAR_GROUP = 2; // bare YYYY in "YYYY TCN"
|
|
11
|
+
const BARE_BC_SUFFIX_GROUP = 3; // "TCN" in bare form
|
|
12
|
+
|
|
13
|
+
export default class VIYearParser extends AbstractParserWithWordBoundaryChecking {
|
|
14
|
+
innerPattern(): RegExp {
|
|
15
|
+
return PATTERN;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
19
|
+
let yearText: string;
|
|
20
|
+
if (match[YEAR_WITH_NAM_GROUP]) {
|
|
21
|
+
yearText = match[YEAR_WITH_NAM_GROUP];
|
|
22
|
+
} else {
|
|
23
|
+
yearText = match[BARE_BC_YEAR_GROUP] + " " + match[BARE_BC_SUFFIX_GROUP];
|
|
24
|
+
}
|
|
25
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
26
|
+
result.start.assign("year", parseYear(yearText));
|
|
27
|
+
result.start.imply("month", 1);
|
|
28
|
+
result.start.imply("day", 1);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MergeWeekdayComponentRefiner from "../../../common/refiners/MergeWeekdayComponentRefiner";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merge weekday with adjacent date/time component.
|
|
5
|
+
* e.g. [th\u1ee9 Hai] [l\u00fac 7 gi\u1edd] => [th\u1ee9 Hai l\u00fac 7 gi\u1edd]
|
|
6
|
+
*/
|
|
7
|
+
export default class VIMergeWeekdayComponentRefiner extends MergeWeekdayComponentRefiner {}
|
|
@@ -10,6 +10,7 @@ import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
|
|
|
10
10
|
import ZHHansCasualDateParser from "./parsers/ZHHansCasualDateParser";
|
|
11
11
|
import ZHHansDateParser from "./parsers/ZHHansDateParser";
|
|
12
12
|
import ZHHansDeadlineFormatParser from "./parsers/ZHHansDeadlineFormatParser";
|
|
13
|
+
import ZHHansAgoFormatParser from "./parsers/ZHHansAgoFormatParser";
|
|
13
14
|
import ZHHansRelationWeekdayParser from "./parsers/ZHHansRelationWeekdayParser";
|
|
14
15
|
import ZHHansTimeExpressionParser from "./parsers/ZHHansTimeExpressionParser";
|
|
15
16
|
import ZHHansWeekdayParser from "./parsers/ZHHansWeekdayParser";
|
|
@@ -53,6 +54,7 @@ export function createConfiguration(): Configuration {
|
|
|
53
54
|
new ZHHansWeekdayParser(),
|
|
54
55
|
new ZHHansTimeExpressionParser(),
|
|
55
56
|
new ZHHansDeadlineFormatParser(),
|
|
57
|
+
new ZHHansAgoFormatParser(),
|
|
56
58
|
],
|
|
57
59
|
refiners: [new ZHHansMergeDateRangeRefiner(), new ZHHansMergeDateTimeRefiner()],
|
|
58
60
|
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../../chrono";
|
|
2
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
+
import { addDuration, Duration, reverseDuration } from "../../../../calculation/duration";
|
|
4
|
+
import { NUMBER, zhStringToNumber } from "../constants";
|
|
5
|
+
|
|
6
|
+
const PATTERN = new RegExp(
|
|
7
|
+
"(\\d+|[" +
|
|
8
|
+
Object.keys(NUMBER).join("") +
|
|
9
|
+
"]+|半|几)(?:\\s*)" +
|
|
10
|
+
"(?:个)?" +
|
|
11
|
+
"(秒(?:钟)?|分钟|小时|钟|日|天|星期|礼拜|月|年)" +
|
|
12
|
+
"(?:之)?前",
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const NUMBER_GROUP = 1;
|
|
17
|
+
const UNIT_GROUP = 2;
|
|
18
|
+
|
|
19
|
+
export default class ZHHansAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
20
|
+
innerPattern(): RegExp {
|
|
21
|
+
return PATTERN;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
25
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
26
|
+
|
|
27
|
+
let number = parseInt(match[NUMBER_GROUP]);
|
|
28
|
+
if (isNaN(number)) {
|
|
29
|
+
number = zhStringToNumber(match[NUMBER_GROUP]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isNaN(number)) {
|
|
33
|
+
const string = match[NUMBER_GROUP];
|
|
34
|
+
if (string === "几") {
|
|
35
|
+
number = 3;
|
|
36
|
+
} else if (string === "半") {
|
|
37
|
+
number = 0.5;
|
|
38
|
+
} else {
|
|
39
|
+
//just in case
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let duration: Duration = {};
|
|
45
|
+
const unit = match[UNIT_GROUP];
|
|
46
|
+
const unitAbbr = unit[0];
|
|
47
|
+
|
|
48
|
+
if (unitAbbr.match(/[日天星礼月年]/)) {
|
|
49
|
+
if (unitAbbr == "日" || unitAbbr == "天") {
|
|
50
|
+
duration.day = number;
|
|
51
|
+
} else if (unitAbbr == "星" || unitAbbr == "礼") {
|
|
52
|
+
duration.week = number;
|
|
53
|
+
} else if (unitAbbr == "月") {
|
|
54
|
+
duration.month = number;
|
|
55
|
+
} else if (unitAbbr == "年") {
|
|
56
|
+
duration.year = number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
duration = reverseDuration(duration);
|
|
60
|
+
|
|
61
|
+
const date = addDuration(context.refDate, duration);
|
|
62
|
+
result.start.assign("year", date.getFullYear());
|
|
63
|
+
result.start.assign("month", date.getMonth() + 1);
|
|
64
|
+
result.start.assign("day", date.getDate());
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (unitAbbr == "秒") {
|
|
69
|
+
duration.second = number;
|
|
70
|
+
} else if (unitAbbr == "分") {
|
|
71
|
+
duration.minute = number;
|
|
72
|
+
} else if (unitAbbr == "小" || unitAbbr == "钟") {
|
|
73
|
+
duration.hour = number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
duration = reverseDuration(duration);
|
|
77
|
+
|
|
78
|
+
const date = addDuration(context.refDate, duration);
|
|
79
|
+
result.start.imply("year", date.getFullYear());
|
|
80
|
+
result.start.imply("month", date.getMonth() + 1);
|
|
81
|
+
result.start.imply("day", date.getDate());
|
|
82
|
+
result.start.assign("hour", date.getHours());
|
|
83
|
+
result.start.assign("minute", date.getMinutes());
|
|
84
|
+
result.start.assign("second", date.getSeconds());
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -63,6 +63,12 @@ const SECOND_GROUP = 8;
|
|
|
63
63
|
const AM_PM_HOUR_GROUP = 9;
|
|
64
64
|
|
|
65
65
|
export default class ZHHansTimeExpressionParser extends AbstractParserWithWordBoundaryChecking {
|
|
66
|
+
patternLeftBoundary(): string {
|
|
67
|
+
// Return a capturing group to ensure that the match index is correct in the base class
|
|
68
|
+
// while avoiding matching CJK characters as word boundaries.
|
|
69
|
+
return "()";
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
innerPattern(): RegExp {
|
|
67
73
|
return FIRST_REG_PATTERN;
|
|
68
74
|
}
|
|
@@ -74,14 +80,14 @@ export default class ZHHansTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
const result = context.createParsingResult(match.index, match[0]);
|
|
77
|
-
const startMoment = new Date(context.
|
|
83
|
+
const startMoment = new Date(context.reference.instant.getTime());
|
|
78
84
|
|
|
79
85
|
// ----- Day
|
|
80
86
|
if (match[DAY_GROUP_1]) {
|
|
81
87
|
const day1 = match[DAY_GROUP_1];
|
|
82
88
|
if (day1 == "明") {
|
|
83
89
|
// Check not "Tomorrow" on late night
|
|
84
|
-
if (context.
|
|
90
|
+
if (context.reference.instant.getHours() > 1) {
|
|
85
91
|
startMoment.setDate(startMoment.getDate() + 1);
|
|
86
92
|
}
|
|
87
93
|
} else if (day1 == "昨") {
|
|
@@ -240,7 +246,12 @@ export default class ZHHansTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
240
246
|
return result;
|
|
241
247
|
}
|
|
242
248
|
|
|
243
|
-
|
|
249
|
+
let endMoment = new Date(startMoment.getTime());
|
|
250
|
+
if (secondMatch[DAY_GROUP_1] || secondMatch[DAY_GROUP_3]) {
|
|
251
|
+
// If the end time expression has a relative day specified (e.g. "Tomorrow"),
|
|
252
|
+
// we should reset the end date to the reference date to calculate the relative date correctly.
|
|
253
|
+
endMoment = new Date(context.reference.instant.getTime());
|
|
254
|
+
}
|
|
244
255
|
result.end = context.createParsingComponents();
|
|
245
256
|
|
|
246
257
|
// ----- Day
|
|
@@ -248,7 +259,7 @@ export default class ZHHansTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
248
259
|
const day1 = secondMatch[DAY_GROUP_1];
|
|
249
260
|
if (day1 == "明") {
|
|
250
261
|
// Check not "Tomorrow" on late night
|
|
251
|
-
if (context.
|
|
262
|
+
if (context.reference.instant.getHours() > 1) {
|
|
252
263
|
endMoment.setDate(endMoment.getDate() + 1);
|
|
253
264
|
}
|
|
254
265
|
} else if (day1 == "昨") {
|
|
@@ -11,6 +11,7 @@ import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
|
|
|
11
11
|
import ZHHantCasualDateParser from "./parsers/ZHHantCasualDateParser";
|
|
12
12
|
import ZHHantDateParser from "./parsers/ZHHantDateParser";
|
|
13
13
|
import ZHHantDeadlineFormatParser from "./parsers/ZHHantDeadlineFormatParser";
|
|
14
|
+
import ZHHantAgoFormatParser from "./parsers/ZHHantAgoFormatParser";
|
|
14
15
|
import ZHHantRelationWeekdayParser from "./parsers/ZHHantRelationWeekdayParser";
|
|
15
16
|
import ZHHantTimeExpressionParser from "./parsers/ZHHantTimeExpressionParser";
|
|
16
17
|
import ZHHantWeekdayParser from "./parsers/ZHHantWeekdayParser";
|
|
@@ -54,6 +55,7 @@ export function createConfiguration(): Configuration {
|
|
|
54
55
|
new ZHHantWeekdayParser(),
|
|
55
56
|
new ZHHantTimeExpressionParser(),
|
|
56
57
|
new ZHHantDeadlineFormatParser(),
|
|
58
|
+
new ZHHantAgoFormatParser(),
|
|
57
59
|
],
|
|
58
60
|
refiners: [new ZHHantMergeDateRangeRefiner(), new ZHHantMergeDateTimeRefiner()],
|
|
59
61
|
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../../chrono";
|
|
2
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
+
import { addDuration, Duration, reverseDuration } from "../../../../calculation/duration";
|
|
4
|
+
import { NUMBER, zhStringToNumber } from "../constants";
|
|
5
|
+
|
|
6
|
+
const PATTERN = new RegExp(
|
|
7
|
+
"(\\d+|[" +
|
|
8
|
+
Object.keys(NUMBER).join("") +
|
|
9
|
+
"]+|半|幾)(?:\\s*)" +
|
|
10
|
+
"(?:個)?" +
|
|
11
|
+
"(秒(?:鐘)?|分鐘|小時|鐘|日|天|星期|禮拜|月|年)" +
|
|
12
|
+
"(?:之)?前",
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const NUMBER_GROUP = 1;
|
|
17
|
+
const UNIT_GROUP = 2;
|
|
18
|
+
|
|
19
|
+
export default class ZHHantAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
20
|
+
innerPattern(): RegExp {
|
|
21
|
+
return PATTERN;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
25
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
26
|
+
|
|
27
|
+
let number = parseInt(match[NUMBER_GROUP]);
|
|
28
|
+
if (isNaN(number)) {
|
|
29
|
+
number = zhStringToNumber(match[NUMBER_GROUP]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isNaN(number)) {
|
|
33
|
+
const string = match[NUMBER_GROUP];
|
|
34
|
+
if (string === "幾") {
|
|
35
|
+
number = 3;
|
|
36
|
+
} else if (string === "半") {
|
|
37
|
+
number = 0.5;
|
|
38
|
+
} else {
|
|
39
|
+
//just in case
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let duration: Duration = {};
|
|
45
|
+
const unit = match[UNIT_GROUP];
|
|
46
|
+
const unitAbbr = unit[0];
|
|
47
|
+
|
|
48
|
+
if (unitAbbr.match(/[日天星禮月年]/)) {
|
|
49
|
+
if (unitAbbr == "日" || unitAbbr == "天") {
|
|
50
|
+
duration.day = number;
|
|
51
|
+
} else if (unitAbbr == "星" || unitAbbr == "禮") {
|
|
52
|
+
duration.week = number;
|
|
53
|
+
} else if (unitAbbr == "月") {
|
|
54
|
+
duration.month = number;
|
|
55
|
+
} else if (unitAbbr == "年") {
|
|
56
|
+
duration.year = number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
duration = reverseDuration(duration);
|
|
60
|
+
|
|
61
|
+
const date = addDuration(context.refDate, duration);
|
|
62
|
+
result.start.assign("year", date.getFullYear());
|
|
63
|
+
result.start.assign("month", date.getMonth() + 1);
|
|
64
|
+
result.start.assign("day", date.getDate());
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (unitAbbr == "秒") {
|
|
69
|
+
duration.second = number;
|
|
70
|
+
} else if (unitAbbr == "分") {
|
|
71
|
+
duration.minute = number;
|
|
72
|
+
} else if (unitAbbr == "小" || unitAbbr == "鐘") {
|
|
73
|
+
duration.hour = number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
duration = reverseDuration(duration);
|
|
77
|
+
|
|
78
|
+
const date = addDuration(context.refDate, duration);
|
|
79
|
+
result.start.imply("year", date.getFullYear());
|
|
80
|
+
result.start.imply("month", date.getMonth() + 1);
|
|
81
|
+
result.start.imply("day", date.getDate());
|
|
82
|
+
result.start.assign("hour", date.getHours());
|
|
83
|
+
result.start.assign("minute", date.getMinutes());
|
|
84
|
+
result.start.assign("second", date.getSeconds());
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -63,6 +63,12 @@ const SECOND_GROUP = 8;
|
|
|
63
63
|
const AM_PM_HOUR_GROUP = 9;
|
|
64
64
|
|
|
65
65
|
export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBoundaryChecking {
|
|
66
|
+
patternLeftBoundary(): string {
|
|
67
|
+
// Return a capturing group to ensure that the match index is correct in the base class
|
|
68
|
+
// while avoiding matching CJK characters as word boundaries.
|
|
69
|
+
return "()";
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
innerPattern(): RegExp {
|
|
67
73
|
return FIRST_REG_PATTERN;
|
|
68
74
|
}
|
|
@@ -74,7 +80,7 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
const result = context.createParsingResult(match.index, match[0]);
|
|
77
|
-
const startMoment = new Date(context.
|
|
83
|
+
const startMoment = new Date(context.reference.instant.getTime());
|
|
78
84
|
|
|
79
85
|
// ----- Day
|
|
80
86
|
if (match[DAY_GROUP_1]) {
|
|
@@ -240,7 +246,13 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
240
246
|
return result;
|
|
241
247
|
}
|
|
242
248
|
|
|
243
|
-
|
|
249
|
+
let endMoment = new Date(startMoment.getTime());
|
|
250
|
+
if (secondMatch[DAY_GROUP_1] || secondMatch[DAY_GROUP_3]) {
|
|
251
|
+
// If the end time expression has a relative day specified (e.g. "Tomorrow"),
|
|
252
|
+
// we should reset the end date to the reference date to calculate the relative date correctly.
|
|
253
|
+
endMoment = new Date(context.reference.instant.getTime());
|
|
254
|
+
}
|
|
255
|
+
|
|
244
256
|
result.end = context.createParsingComponents();
|
|
245
257
|
|
|
246
258
|
// ----- Day
|
package/src/results.ts
CHANGED
|
@@ -44,9 +44,7 @@ export class ReferenceWithTimezone {
|
|
|
44
44
|
* @param overrideTimezoneOffset
|
|
45
45
|
*/
|
|
46
46
|
getSystemTimezoneAdjustmentMinute(date?: Date, overrideTimezoneOffset?: number): number {
|
|
47
|
-
if (!date
|
|
48
|
-
// Javascript date timezone calculation got effect when the time epoch < 0
|
|
49
|
-
// e.g. new Date('Tue Feb 02 1300 00:00:00 GMT+0900 (JST)') => Tue Feb 02 1300 00:18:59 GMT+0918 (JST)
|
|
47
|
+
if (!date) {
|
|
50
48
|
date = new Date();
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -320,3 +320,17 @@ test("Test - Random negative text", function () {
|
|
|
320
320
|
|
|
321
321
|
testUnexpectedResult(chrono.de, "ljetztlich");
|
|
322
322
|
});
|
|
323
|
+
|
|
324
|
+
test("Test - Casual time keeps its meridiem when merged with an explicit time", () => {
|
|
325
|
+
testSingleCase(chrono.de, "nachmittag um 5", new Date(2016, 7, 10, 12), (result, text) => {
|
|
326
|
+
expect(result.text).toBe(text);
|
|
327
|
+
expect(result.start.get("hour")).toBe(17);
|
|
328
|
+
expect(result.start.get("meridiem")).toBe(1);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
testSingleCase(chrono.de, "abend um 5", new Date(2016, 7, 10, 12), (result, text) => {
|
|
332
|
+
expect(result.text).toBe(text);
|
|
333
|
+
expect(result.start.get("hour")).toBe(17);
|
|
334
|
+
expect(result.start.get("meridiem")).toBe(1);
|
|
335
|
+
});
|
|
336
|
+
});
|