chrono-node 2.9.0 → 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/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.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/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.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/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 -3
- 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
|
@@ -26,12 +26,14 @@ export default class NLCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
26
26
|
case "'s namiddags":
|
|
27
27
|
component.imply("meridiem", Meridiem.PM);
|
|
28
28
|
component.imply("hour", 15);
|
|
29
|
+
component.addTag("casualReference/afternoon");
|
|
29
30
|
break;
|
|
30
31
|
|
|
31
32
|
case "avond":
|
|
32
33
|
case "'s avonds'":
|
|
33
34
|
component.imply("meridiem", Meridiem.PM);
|
|
34
35
|
component.imply("hour", 20);
|
|
36
|
+
component.addTag("casualReference/evening");
|
|
35
37
|
break;
|
|
36
38
|
|
|
37
39
|
case "middernacht":
|
|
@@ -42,18 +44,21 @@ export default class NLCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
42
44
|
component.imply("hour", 0);
|
|
43
45
|
component.imply("minute", 0);
|
|
44
46
|
component.imply("second", 0);
|
|
47
|
+
component.addTag("casualReference/midnight");
|
|
45
48
|
break;
|
|
46
49
|
|
|
47
50
|
case "ochtend":
|
|
48
51
|
case "'s ochtends":
|
|
49
52
|
component.imply("meridiem", Meridiem.AM);
|
|
50
53
|
component.imply("hour", 6);
|
|
54
|
+
component.addTag("casualReference/morning");
|
|
51
55
|
break;
|
|
52
56
|
|
|
53
57
|
case "middag":
|
|
54
58
|
case "'s middags":
|
|
55
59
|
component.imply("meridiem", Meridiem.AM);
|
|
56
60
|
component.imply("hour", 12);
|
|
61
|
+
component.addTag("casualReference/noon");
|
|
57
62
|
break;
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -15,17 +15,20 @@ export default class PTCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
15
15
|
case "tarde":
|
|
16
16
|
component.imply("meridiem", Meridiem.PM);
|
|
17
17
|
component.imply("hour", 15);
|
|
18
|
+
component.addTag("casualReference/afternoon");
|
|
18
19
|
break;
|
|
19
20
|
|
|
20
21
|
case "noite":
|
|
21
22
|
component.imply("meridiem", Meridiem.PM);
|
|
22
23
|
component.imply("hour", 22);
|
|
24
|
+
component.addTag("casualReference/evening");
|
|
23
25
|
break;
|
|
24
26
|
|
|
25
27
|
case "manha":
|
|
26
28
|
case "manhã":
|
|
27
29
|
component.imply("meridiem", Meridiem.AM);
|
|
28
30
|
component.imply("hour", 6);
|
|
31
|
+
component.addTag("casualReference/morning");
|
|
29
32
|
break;
|
|
30
33
|
|
|
31
34
|
case "meia-noite":
|
|
@@ -36,11 +39,13 @@ export default class PTCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
36
39
|
component.imply("hour", 0);
|
|
37
40
|
component.imply("minute", 0);
|
|
38
41
|
component.imply("second", 0);
|
|
42
|
+
component.addTag("casualReference/midnight");
|
|
39
43
|
break;
|
|
40
44
|
|
|
41
45
|
case "meio-dia":
|
|
42
46
|
component.imply("meridiem", Meridiem.AM);
|
|
43
47
|
component.imply("hour", 12);
|
|
48
|
+
component.addTag("casualReference/noon");
|
|
44
49
|
break;
|
|
45
50
|
}
|
|
46
51
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
2
|
+
import { findMostLikelyADYear } from "../../calculation/years";
|
|
3
|
+
import { Duration } from "../../calculation/duration";
|
|
4
|
+
import { Timeunit } from "../../types";
|
|
5
|
+
|
|
6
|
+
export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
|
|
7
|
+
"ch\u1ee7 nh\u1eadt": 0,
|
|
8
|
+
"cn": 0,
|
|
9
|
+
"th\u1ee9 hai": 1,
|
|
10
|
+
"t2": 1,
|
|
11
|
+
"th\u1ee9 ba": 2,
|
|
12
|
+
"t3": 2,
|
|
13
|
+
"th\u1ee9 t\u01b0": 3,
|
|
14
|
+
"t4": 3,
|
|
15
|
+
"th\u1ee9 n\u0103m": 4,
|
|
16
|
+
"t5": 4,
|
|
17
|
+
"th\u1ee9 s\u00e1u": 5,
|
|
18
|
+
"t6": 5,
|
|
19
|
+
"th\u1ee9 b\u1ea3y": 6,
|
|
20
|
+
"t7": 6,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const MONTH_DICTIONARY: { [word: string]: number } = {
|
|
24
|
+
"th\u00e1ng 1": 1,
|
|
25
|
+
"th\u00e1ng m\u1ed9t": 1,
|
|
26
|
+
"th\u00e1ng gi\u00eang": 1,
|
|
27
|
+
"th\u00e1ng 2": 2,
|
|
28
|
+
"th\u00e1ng hai": 2,
|
|
29
|
+
"th\u00e1ng 3": 3,
|
|
30
|
+
"th\u00e1ng ba": 3,
|
|
31
|
+
"th\u00e1ng 4": 4,
|
|
32
|
+
"th\u00e1ng t\u01b0": 4,
|
|
33
|
+
"th\u00e1ng 5": 5,
|
|
34
|
+
"th\u00e1ng n\u0103m": 5,
|
|
35
|
+
"th\u00e1ng 6": 6,
|
|
36
|
+
"th\u00e1ng s\u00e1u": 6,
|
|
37
|
+
"th\u00e1ng 7": 7,
|
|
38
|
+
"th\u00e1ng b\u1ea3y": 7,
|
|
39
|
+
"th\u00e1ng 8": 8,
|
|
40
|
+
"th\u00e1ng t\u00e1m": 8,
|
|
41
|
+
"th\u00e1ng 9": 9,
|
|
42
|
+
"th\u00e1ng ch\u00edn": 9,
|
|
43
|
+
"th\u00e1ng 10": 10,
|
|
44
|
+
"th\u00e1ng m\u01b0\u1eddi": 10,
|
|
45
|
+
"th\u00e1ng 11": 11,
|
|
46
|
+
"th\u00e1ng m\u01b0\u1eddi m\u1ed9t": 11,
|
|
47
|
+
"th\u00e1ng 12": 12,
|
|
48
|
+
"th\u00e1ng m\u01b0\u1eddi hai": 12,
|
|
49
|
+
"th\u00e1ng ch\u1ea1p": 12,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
53
|
+
"m\u1ed9t": 1,
|
|
54
|
+
"hai": 2,
|
|
55
|
+
"ba": 3,
|
|
56
|
+
"b\u1ed1n": 4,
|
|
57
|
+
"n\u0103m": 5,
|
|
58
|
+
"s\u00e1u": 6,
|
|
59
|
+
"b\u1ea3y": 7,
|
|
60
|
+
"t\u00e1m": 8,
|
|
61
|
+
"ch\u00edn": 9,
|
|
62
|
+
"m\u01b0\u1eddi": 10,
|
|
63
|
+
"m\u01b0\u1eddi m\u1ed9t": 11,
|
|
64
|
+
"m\u01b0\u1eddi hai": 12,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
68
|
+
"gi\u00e2y": "second",
|
|
69
|
+
"ph\u00fat": "minute",
|
|
70
|
+
"gi\u1edd": "hour",
|
|
71
|
+
"ng\u00e0y": "day",
|
|
72
|
+
"tu\u1ea7n": "week",
|
|
73
|
+
"th\u00e1ng": "month",
|
|
74
|
+
"n\u0103m": "year",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const NUMBER_PATTERN = "(?:" + matchAnyPattern(INTEGER_WORD_DICTIONARY) + "|[0-9]+|[0-9]+\\.[0-9]+)";
|
|
78
|
+
|
|
79
|
+
export function parseNumberPattern(match: string): number {
|
|
80
|
+
const num = match.toLowerCase();
|
|
81
|
+
if (INTEGER_WORD_DICTIONARY[num] !== undefined) return INTEGER_WORD_DICTIONARY[num];
|
|
82
|
+
return parseFloat(num);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// YYYY, YYYY TCN (Tr\u01b0\u1edbc C\u00f4ng nguy\u00ean = BC)
|
|
86
|
+
export const YEAR_PATTERN = "(?:[0-9]{1,4}(?:\\s*TCN)?)";
|
|
87
|
+
|
|
88
|
+
export function parseYear(match: string): number {
|
|
89
|
+
const upper = match.toUpperCase();
|
|
90
|
+
const num = parseInt(match.replace(/[^0-9]+/g, ""));
|
|
91
|
+
if (/TCN/.test(upper)) return -num;
|
|
92
|
+
return findMostLikelyADYear(num);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const SINGLE_TIME_UNIT_PATTERN =
|
|
96
|
+
"(" + NUMBER_PATTERN + ")\\s{0,5}(" + matchAnyPattern(TIME_UNIT_DICTIONARY) + ")\\s{0,5}";
|
|
97
|
+
const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
98
|
+
|
|
99
|
+
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
|
100
|
+
|
|
101
|
+
export function parseDuration(timeunitText: string): Duration {
|
|
102
|
+
const fragments: { [key: string]: number } = {};
|
|
103
|
+
let remainingText = timeunitText;
|
|
104
|
+
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
105
|
+
while (match) {
|
|
106
|
+
const num = parseNumberPattern(match[1]);
|
|
107
|
+
const unit = TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
|
108
|
+
fragments[unit] = num;
|
|
109
|
+
remainingText = remainingText.substring(match[0].length);
|
|
110
|
+
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
111
|
+
}
|
|
112
|
+
return fragments as Duration;
|
|
113
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chrono components for Vietnamese support (*parsers*, *refiners*, and *configuration*)
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { includeCommonConfiguration } from "../../configurations";
|
|
7
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
8
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../results";
|
|
9
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
|
+
import ISOFormatParser from "../../common/parsers/ISOFormatParser";
|
|
11
|
+
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
12
|
+
import VIStandardParser from "./parsers/VIStandardParser";
|
|
13
|
+
import VIMonthYearParser from "./parsers/VIMonthYearParser";
|
|
14
|
+
import VIYearParser from "./parsers/VIYearParser";
|
|
15
|
+
import VICasualDateParser from "./parsers/VICasualDateParser";
|
|
16
|
+
import VICasualTimeParser from "./parsers/VICasualTimeParser";
|
|
17
|
+
import VIWeekdayParser from "./parsers/VIWeekdayParser";
|
|
18
|
+
import VITimeExpressionParser from "./parsers/VITimeExpressionParser";
|
|
19
|
+
import VITimeUnitAgoFormatParser from "./parsers/VITimeUnitAgoFormatParser";
|
|
20
|
+
import VITimeUnitLaterFormatParser from "./parsers/VITimeUnitLaterFormatParser";
|
|
21
|
+
import VITimeUnitWithinFormatParser from "./parsers/VITimeUnitWithinFormatParser";
|
|
22
|
+
import VITimeUnitCasualRelativeFormatParser from "./parsers/VITimeUnitCasualRelativeFormatParser";
|
|
23
|
+
import VIMergeDateRangeRefiner from "./refiners/VIMergeDateRangeRefiner";
|
|
24
|
+
import VIMergeDateTimeRefiner from "./refiners/VIMergeDateTimeRefiner";
|
|
25
|
+
import VIMergeWeekdayComponentRefiner from "./refiners/VIMergeWeekdayComponentRefiner";
|
|
26
|
+
|
|
27
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
28
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
29
|
+
|
|
30
|
+
// Shortcuts
|
|
31
|
+
export const casual = new Chrono(createCasualConfiguration());
|
|
32
|
+
export const strict = new Chrono(createConfiguration(true));
|
|
33
|
+
|
|
34
|
+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
|
|
35
|
+
return casual.parse(text, ref, option);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
|
|
39
|
+
return casual.parseDate(text, ref, option);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function createCasualConfiguration(littleEndian = true): Configuration {
|
|
43
|
+
const option = createConfiguration(false, littleEndian);
|
|
44
|
+
option.parsers.unshift(new VICasualTimeParser());
|
|
45
|
+
option.parsers.unshift(new VICasualDateParser());
|
|
46
|
+
option.parsers.unshift(new VITimeUnitCasualRelativeFormatParser());
|
|
47
|
+
return option;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function createConfiguration(strictMode = true, littleEndian = true): Configuration {
|
|
51
|
+
return includeCommonConfiguration(
|
|
52
|
+
{
|
|
53
|
+
parsers: [
|
|
54
|
+
new ISOFormatParser(),
|
|
55
|
+
new SlashDateFormatParser(littleEndian),
|
|
56
|
+
new VIStandardParser(),
|
|
57
|
+
new VIMonthYearParser(),
|
|
58
|
+
new VIYearParser(),
|
|
59
|
+
new VIWeekdayParser(),
|
|
60
|
+
new VITimeExpressionParser(),
|
|
61
|
+
new VITimeUnitAgoFormatParser(strictMode),
|
|
62
|
+
new VITimeUnitLaterFormatParser(strictMode),
|
|
63
|
+
new VITimeUnitWithinFormatParser(strictMode),
|
|
64
|
+
],
|
|
65
|
+
refiners: [
|
|
66
|
+
new VIMergeWeekdayComponentRefiner(),
|
|
67
|
+
new VIMergeDateRangeRefiner(),
|
|
68
|
+
new VIMergeDateTimeRefiner(),
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
strictMode
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -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
|
+
}
|