chrono-node 2.8.5 → 2.9.1
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/casualReferences.d.ts +1 -1
- package/dist/cjs/common/casualReferences.js +4 -4
- package/dist/cjs/common/casualReferences.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/DETimeUnitRelativeFormatParser.js +1 -1
- package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.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/ENWeekdayParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENWeekdayParser.js.map +1 -1
- 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 +70 -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/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/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/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/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.d.ts +0 -2
- package/dist/cjs/results.js +1 -10
- 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/casualReferences.d.ts +1 -1
- package/dist/esm/common/casualReferences.js +3 -3
- package/dist/esm/common/casualReferences.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/DETimeUnitRelativeFormatParser.js +1 -1
- package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.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/ENWeekdayParser.js +1 -1
- package/dist/esm/locales/en/parsers/ENWeekdayParser.js.map +1 -1
- 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 +67 -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/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/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/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/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.d.ts +0 -2
- package/dist/esm/results.js +1 -7
- package/dist/esm/results.js.map +1 -1
- package/package.json +3 -5
- package/src/calculation/mergingCalculation.ts +7 -1
- package/src/common/casualReferences.ts +4 -10
- package/src/common/refiners/ForwardDateRefiner.ts +8 -14
- package/src/index.ts +3 -1
- package/src/locales/de/parsers/DETimeUnitRelativeFormatParser.ts +1 -1
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/parsers/ENWeekdayParser.ts +1 -1
- 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 +78 -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/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/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/parsers/ZHHansTimeExpressionParser.ts +15 -4
- package/src/locales/zh/hant/parsers/ZHHantTimeExpressionParser.ts +14 -2
- package/src/results.ts +1 -10
- package/test/de/de_time_units_casual_relative.test.ts +12 -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 +85 -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/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/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_time_exp.test.ts +252 -6
- package/test/zh/hant/zh_hant_time_exp.test.ts +30 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
import * as references from "../../../common/casualReferences";
|
|
5
|
+
|
|
6
|
+
const PATTERN = /\b(hôm nay|hôm qua|hôm kia|ngày mai|ngày kia|bây giờ|lúc này)(?=\W|$)/i;
|
|
7
|
+
|
|
8
|
+
export default class VICasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
9
|
+
innerPattern(): RegExp {
|
|
10
|
+
return PATTERN;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
14
|
+
switch (match[1].toLowerCase()) {
|
|
15
|
+
case "bây giờ":
|
|
16
|
+
case "lúc này":
|
|
17
|
+
return references.now(context.reference);
|
|
18
|
+
case "hôm nay":
|
|
19
|
+
return references.today(context.reference);
|
|
20
|
+
case "hôm qua":
|
|
21
|
+
return references.yesterday(context.reference);
|
|
22
|
+
case "hôm kia":
|
|
23
|
+
return references.theDayBefore(context.reference, 2);
|
|
24
|
+
case "ngày mai":
|
|
25
|
+
return references.tomorrow(context.reference);
|
|
26
|
+
case "ngày kia":
|
|
27
|
+
return references.theDayAfter(context.reference, 2);
|
|
28
|
+
}
|
|
29
|
+
return context.createParsingComponents();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { implySimilarTime } from "../../../utils/dates";
|
|
6
|
+
|
|
7
|
+
// bu\u1ed5i s\u00e1ng | bu\u1ed5i tr\u01b0a | bu\u1ed5i chi\u1ec1u | bu\u1ed5i t\u1ed1i | n\u1eeda \u0111\u00eam
|
|
8
|
+
const PATTERN = /(buổi\s*)?(sáng sớm|sáng|trưa|chiều|tối|đêm|nửa đêm|bình minh)(?=\W|$)/i;
|
|
9
|
+
|
|
10
|
+
export default class VICasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
11
|
+
innerPattern(): RegExp {
|
|
12
|
+
return PATTERN;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
16
|
+
const component = context.createParsingComponents();
|
|
17
|
+
implySimilarTime(component, context.refDate);
|
|
18
|
+
return VICasualTimeParser.extractTimeComponents(component, match[2].toLowerCase());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static extractTimeComponents(component: ParsingComponents, keyword: string): ParsingComponents {
|
|
22
|
+
switch (keyword) {
|
|
23
|
+
case "b\u00ecnh minh":
|
|
24
|
+
case "s\u00e1ng s\u1edbm":
|
|
25
|
+
component.imply("hour", 6);
|
|
26
|
+
component.imply("minute", 0);
|
|
27
|
+
component.imply("meridiem", Meridiem.AM);
|
|
28
|
+
break;
|
|
29
|
+
case "s\u00e1ng":
|
|
30
|
+
component.imply("hour", 9);
|
|
31
|
+
component.imply("minute", 0);
|
|
32
|
+
component.imply("meridiem", Meridiem.AM);
|
|
33
|
+
break;
|
|
34
|
+
case "tr\u01b0a":
|
|
35
|
+
component.imply("hour", 12);
|
|
36
|
+
component.imply("minute", 0);
|
|
37
|
+
component.imply("meridiem", Meridiem.PM); // noon = 12:00 PM in chrono's 12-hour convention
|
|
38
|
+
break;
|
|
39
|
+
case "chi\u1ec1u":
|
|
40
|
+
component.imply("hour", 15);
|
|
41
|
+
component.imply("minute", 0);
|
|
42
|
+
component.imply("meridiem", Meridiem.PM);
|
|
43
|
+
break;
|
|
44
|
+
case "t\u1ed1i":
|
|
45
|
+
component.imply("hour", 19);
|
|
46
|
+
component.imply("minute", 0);
|
|
47
|
+
component.imply("meridiem", Meridiem.PM);
|
|
48
|
+
break;
|
|
49
|
+
case "\u0111\u00eam":
|
|
50
|
+
component.imply("hour", 22);
|
|
51
|
+
component.imply("minute", 0);
|
|
52
|
+
component.imply("meridiem", Meridiem.PM);
|
|
53
|
+
break;
|
|
54
|
+
case "n\u1eeda \u0111\u00eam":
|
|
55
|
+
component.imply("hour", 0);
|
|
56
|
+
component.imply("minute", 0);
|
|
57
|
+
component.imply("meridiem", Meridiem.AM);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
return component;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { MONTH_DICTIONARY, YEAR_PATTERN, parseYear } from "../constants";
|
|
4
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
+
|
|
7
|
+
// tháng 3 năm 1975 | tháng ba năm 1975 | tháng chạp | tháng giêng/1975
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
"(" + matchAnyPattern(MONTH_DICTIONARY) + ")" + "(?:\\s*(?:năm|/)\\s*(" + YEAR_PATTERN + "))?" + "(?=\\W|$)",
|
|
10
|
+
"i"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const MONTH_GROUP = 1;
|
|
14
|
+
const YEAR_GROUP = 2;
|
|
15
|
+
|
|
16
|
+
export default class VIMonthYearParser extends AbstractParserWithWordBoundaryChecking {
|
|
17
|
+
innerPattern(): RegExp {
|
|
18
|
+
return PATTERN;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
22
|
+
const month = MONTH_DICTIONARY[match[MONTH_GROUP].toLowerCase()];
|
|
23
|
+
if (!month) return null;
|
|
24
|
+
|
|
25
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
26
|
+
result.start.assign("month", month);
|
|
27
|
+
result.start.imply("day", 1);
|
|
28
|
+
if (match[YEAR_GROUP]) {
|
|
29
|
+
result.start.assign("year", parseYear(match[YEAR_GROUP]));
|
|
30
|
+
} else {
|
|
31
|
+
result.start.imply("year", context.reference.getDateWithAdjustedTimezone().getFullYear());
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -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 {}
|
|
@@ -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 == "昨") {
|
|
@@ -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
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Component, ParsedComponents, ParsedResult, ParsingReference, TimezoneAbbrMap } from "./types";
|
|
2
2
|
|
|
3
|
-
import quarterOfYear from "dayjs/plugin/quarterOfYear";
|
|
4
|
-
import dayjs, { QUnitType } from "dayjs";
|
|
5
3
|
import { assignSimilarDate, assignSimilarTime, implySimilarTime } from "./utils/dates";
|
|
6
4
|
import { toTimezoneOffset } from "./timezone";
|
|
7
5
|
import { addDuration, Duration, EmptyDuration } from "./calculation/duration";
|
|
8
|
-
dayjs.extend(quarterOfYear);
|
|
9
6
|
|
|
10
7
|
export class ReferenceWithTimezone {
|
|
11
8
|
readonly instant: Date;
|
|
@@ -47,9 +44,7 @@ export class ReferenceWithTimezone {
|
|
|
47
44
|
* @param overrideTimezoneOffset
|
|
48
45
|
*/
|
|
49
46
|
getSystemTimezoneAdjustmentMinute(date?: Date, overrideTimezoneOffset?: number): number {
|
|
50
|
-
if (!date
|
|
51
|
-
// Javascript date timezone calculation got effect when the time epoch < 0
|
|
52
|
-
// 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) {
|
|
53
48
|
date = new Date();
|
|
54
49
|
}
|
|
55
50
|
|
|
@@ -256,10 +251,6 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
256
251
|
reference: ${JSON.stringify(this.reference)}]`;
|
|
257
252
|
}
|
|
258
253
|
|
|
259
|
-
dayjs() {
|
|
260
|
-
return dayjs(this.dateWithoutTimezoneAdjustment());
|
|
261
|
-
}
|
|
262
|
-
|
|
263
254
|
date(): Date {
|
|
264
255
|
const date = this.dateWithoutTimezoneAdjustment();
|
|
265
256
|
const timezoneAdjustment = this.reference.getSystemTimezoneAdjustmentMinute(date, this.get("timezoneOffset"));
|
|
@@ -106,3 +106,15 @@ test("Test - de - relative date", function () {
|
|
|
106
106
|
expect(result.start.isCertain("second")).toBeFalsy();
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
+
|
|
110
|
+
test("Test - de - false positive prevention for single-letter time units", function () {
|
|
111
|
+
// Test that "Letzte A" in "Letzte Aktualisierun" doesn't match as "letzte a" (last year)
|
|
112
|
+
// The word boundary check should prevent "A" from matching the time unit "a"
|
|
113
|
+
testSingleCase(chrono.de, "Letzte Aktualisierun 03/12/2025", (result) => {
|
|
114
|
+
expect(result.text).toBe("03/12/2025");
|
|
115
|
+
expect(result.start.get("year")).toBe(2025);
|
|
116
|
+
expect(result.start.get("month")).toBe(12);
|
|
117
|
+
expect(result.start.get("day")).toBe(3);
|
|
118
|
+
expect(result).toBeDate(new Date(2025, 12 - 1, 3, 12));
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -416,3 +416,33 @@ test("Test - Impossible Dates (Strict Mode)", function () {
|
|
|
416
416
|
|
|
417
417
|
testUnexpectedResult(chrono.strict, "29 February", new Date(2013, 7, 10));
|
|
418
418
|
});
|
|
419
|
+
|
|
420
|
+
test("Test - Year 3000+ support (Issue #636)", () => {
|
|
421
|
+
testSingleCase(chrono, "Jan 1 3000, 9:30", (result) => {
|
|
422
|
+
expect(result.index).toBe(0);
|
|
423
|
+
expect(result.text).toBe("Jan 1 3000, 9:30");
|
|
424
|
+
|
|
425
|
+
expect(result.start).not.toBeNull();
|
|
426
|
+
expect(result.start.get("year")).toBe(3000);
|
|
427
|
+
expect(result.start.get("month")).toBe(1);
|
|
428
|
+
expect(result.start.get("day")).toBe(1);
|
|
429
|
+
expect(result.start.get("hour")).toBe(9);
|
|
430
|
+
expect(result.start.get("minute")).toBe(30);
|
|
431
|
+
|
|
432
|
+
expect(result.start).toBeDate(new Date(3000, 1 - 1, 1, 9, 30));
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
testSingleCase(chrono, "Jan 1 2025, 9:30", (result) => {
|
|
436
|
+
expect(result.index).toBe(0);
|
|
437
|
+
expect(result.text).toBe("Jan 1 2025, 9:30");
|
|
438
|
+
|
|
439
|
+
expect(result.start).not.toBeNull();
|
|
440
|
+
expect(result.start.get("year")).toBe(2025);
|
|
441
|
+
expect(result.start.get("month")).toBe(1);
|
|
442
|
+
expect(result.start.get("day")).toBe(1);
|
|
443
|
+
expect(result.start.get("hour")).toBe(9);
|
|
444
|
+
expect(result.start.get("minute")).toBe(30);
|
|
445
|
+
|
|
446
|
+
expect(result.start).toBeDate(new Date(2025, 1 - 1, 1, 9, 30));
|
|
447
|
+
});
|
|
448
|
+
});
|
|
@@ -145,6 +145,17 @@ test("Test - Minus '-' sign", () => {
|
|
|
145
145
|
expect(result.start.get("hour")).toBe(9);
|
|
146
146
|
expect(result.start.get("minute")).toBe(55);
|
|
147
147
|
});
|
|
148
|
+
|
|
149
|
+
testSingleCase(chrono, "-5d 00", new Date(2016, 10 - 1, 1, 12), (result, text) => {
|
|
150
|
+
expect(result.text).toBe(text);
|
|
151
|
+
expect(result.start.get("year")).toBe(2016);
|
|
152
|
+
expect(result.start.get("month")).toBe(9);
|
|
153
|
+
expect(result.start.get("day")).toBe(26);
|
|
154
|
+
expect(result.start.get("hour")).toBe(0);
|
|
155
|
+
expect(result.start.get("minute")).toBe(0);
|
|
156
|
+
|
|
157
|
+
expect(result.start).toBeDate(new Date(2016, 9 - 1, 26, 0, 0));
|
|
158
|
+
});
|
|
148
159
|
});
|
|
149
160
|
|
|
150
161
|
test("Test - Without custom parser without abbreviations", function () {
|