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
|
@@ -0,0 +1,209 @@
|
|
|
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
|
+
"sunnuntai": 0,
|
|
8
|
+
"sunnuntaina": 0,
|
|
9
|
+
"su": 0,
|
|
10
|
+
"maanantai": 1,
|
|
11
|
+
"maanantaina": 1,
|
|
12
|
+
"ma": 1,
|
|
13
|
+
"tiistai": 2,
|
|
14
|
+
"tiistaina": 2,
|
|
15
|
+
"ti": 2,
|
|
16
|
+
"keskiviikko": 3,
|
|
17
|
+
"keskiviikkona": 3,
|
|
18
|
+
"ke": 3,
|
|
19
|
+
"torstai": 4,
|
|
20
|
+
"torstaina": 4,
|
|
21
|
+
"to": 4,
|
|
22
|
+
"perjantai": 5,
|
|
23
|
+
"perjantaina": 5,
|
|
24
|
+
"pe": 5,
|
|
25
|
+
"lauantai": 6,
|
|
26
|
+
"lauantaina": 6,
|
|
27
|
+
"la": 6,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const MONTH_DICTIONARY: { [word: string]: number } = {
|
|
31
|
+
"tammikuu": 1,
|
|
32
|
+
"tammikuuta": 1,
|
|
33
|
+
"tammikuun": 1,
|
|
34
|
+
"tammi": 1,
|
|
35
|
+
"helmikuu": 2,
|
|
36
|
+
"helmikuuta": 2,
|
|
37
|
+
"helmikuun": 2,
|
|
38
|
+
"helmi": 2,
|
|
39
|
+
"maaliskuu": 3,
|
|
40
|
+
"maaliskuuta": 3,
|
|
41
|
+
"maaliskuun": 3,
|
|
42
|
+
"maalis": 3,
|
|
43
|
+
"huhtikuu": 4,
|
|
44
|
+
"huhtikuuta": 4,
|
|
45
|
+
"huhtikuun": 4,
|
|
46
|
+
"huhti": 4,
|
|
47
|
+
"toukokuu": 5,
|
|
48
|
+
"toukokuuta": 5,
|
|
49
|
+
"toukokuun": 5,
|
|
50
|
+
"touko": 5,
|
|
51
|
+
"kesäkuu": 6,
|
|
52
|
+
"kesäkuuta": 6,
|
|
53
|
+
"kesäkuun": 6,
|
|
54
|
+
"kesä": 6,
|
|
55
|
+
"heinäkuu": 7,
|
|
56
|
+
"heinäkuuta": 7,
|
|
57
|
+
"heinäkuun": 7,
|
|
58
|
+
"heinä": 7,
|
|
59
|
+
"elokuu": 8,
|
|
60
|
+
"elokuuta": 8,
|
|
61
|
+
"elokuun": 8,
|
|
62
|
+
"elo": 8,
|
|
63
|
+
"syyskuu": 9,
|
|
64
|
+
"syyskuuta": 9,
|
|
65
|
+
"syyskuun": 9,
|
|
66
|
+
"syys": 9,
|
|
67
|
+
"lokakuu": 10,
|
|
68
|
+
"lokakuuta": 10,
|
|
69
|
+
"lokakuun": 10,
|
|
70
|
+
"loka": 10,
|
|
71
|
+
"marraskuu": 11,
|
|
72
|
+
"marraskuuta": 11,
|
|
73
|
+
"marraskuun": 11,
|
|
74
|
+
"marras": 11,
|
|
75
|
+
"joulukuu": 12,
|
|
76
|
+
"joulukuuta": 12,
|
|
77
|
+
"joulukuun": 12,
|
|
78
|
+
"joulu": 12,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
82
|
+
"yksi": 1,
|
|
83
|
+
"yhden": 1,
|
|
84
|
+
"kaksi": 2,
|
|
85
|
+
"kahden": 2,
|
|
86
|
+
"kolme": 3,
|
|
87
|
+
"kolmen": 3,
|
|
88
|
+
"neljä": 4,
|
|
89
|
+
"neljän": 4,
|
|
90
|
+
"viisi": 5,
|
|
91
|
+
"viiden": 5,
|
|
92
|
+
"kuusi": 6,
|
|
93
|
+
"kuuden": 6,
|
|
94
|
+
"seitsemän": 7,
|
|
95
|
+
"kahdeksan": 8,
|
|
96
|
+
"yhdeksän": 9,
|
|
97
|
+
"kymmenen": 10,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
101
|
+
"s": "second",
|
|
102
|
+
"sek": "second",
|
|
103
|
+
"sekunti": "second",
|
|
104
|
+
"sekuntia": "second",
|
|
105
|
+
"sekunnin": "second",
|
|
106
|
+
"min": "minute",
|
|
107
|
+
"minuutti": "minute",
|
|
108
|
+
"minuuttia": "minute",
|
|
109
|
+
"minuutin": "minute",
|
|
110
|
+
"t": "hour",
|
|
111
|
+
"tunti": "hour",
|
|
112
|
+
"tuntia": "hour",
|
|
113
|
+
"tunnin": "hour",
|
|
114
|
+
"pv": "day",
|
|
115
|
+
"päivä": "day",
|
|
116
|
+
"päivää": "day",
|
|
117
|
+
"päivän": "day",
|
|
118
|
+
"vk": "week",
|
|
119
|
+
"viikko": "week",
|
|
120
|
+
"viikkoa": "week",
|
|
121
|
+
"viikon": "week",
|
|
122
|
+
"kk": "month",
|
|
123
|
+
"kuukausi": "month",
|
|
124
|
+
"kuukautta": "month",
|
|
125
|
+
"kuukauden": "month",
|
|
126
|
+
"vuosi": "year",
|
|
127
|
+
"vuotta": "year",
|
|
128
|
+
"vuoden": "year",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const TIME_UNIT_NO_ABBR_DICTIONARY: { [word: string]: Timeunit } = {
|
|
132
|
+
"sekunti": "second",
|
|
133
|
+
"sekuntia": "second",
|
|
134
|
+
"sekunnin": "second",
|
|
135
|
+
"minuutti": "minute",
|
|
136
|
+
"minuuttia": "minute",
|
|
137
|
+
"minuutin": "minute",
|
|
138
|
+
"tunti": "hour",
|
|
139
|
+
"tuntia": "hour",
|
|
140
|
+
"tunnin": "hour",
|
|
141
|
+
"päivä": "day",
|
|
142
|
+
"päivää": "day",
|
|
143
|
+
"päivän": "day",
|
|
144
|
+
"viikko": "week",
|
|
145
|
+
"viikkoa": "week",
|
|
146
|
+
"viikon": "week",
|
|
147
|
+
"kuukausi": "month",
|
|
148
|
+
"kuukautta": "month",
|
|
149
|
+
"kuukauden": "month",
|
|
150
|
+
"vuosi": "year",
|
|
151
|
+
"vuotta": "year",
|
|
152
|
+
"vuoden": "year",
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export function parseDuration(timeunitText: string): Duration {
|
|
156
|
+
const fragments: { [key: string]: number } = {};
|
|
157
|
+
let remainingText = timeunitText;
|
|
158
|
+
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
159
|
+
while (match) {
|
|
160
|
+
collectDateTimeFragment(fragments, match);
|
|
161
|
+
remainingText = remainingText.substring(match[0].length);
|
|
162
|
+
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
163
|
+
}
|
|
164
|
+
return fragments as Duration;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function collectDateTimeFragment(fragments: { [key: string]: number }, match: RegExpMatchArray) {
|
|
168
|
+
const num = parseNumberPattern(match[1]);
|
|
169
|
+
const unit = TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
|
170
|
+
fragments[unit] = num;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const NUMBER_PATTERN = `(?:${matchAnyPattern(INTEGER_WORD_DICTIONARY)}|\\d+)`;
|
|
174
|
+
export const TIME_UNIT_PATTERN = `(?:${matchAnyPattern(TIME_UNIT_DICTIONARY)})`;
|
|
175
|
+
|
|
176
|
+
const SINGLE_TIME_UNIT_PATTERN = `(${NUMBER_PATTERN})\\s{0,5}(${matchAnyPattern(TIME_UNIT_DICTIONARY)})\\s{0,5}`;
|
|
177
|
+
const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
178
|
+
|
|
179
|
+
const SINGLE_TIME_UNIT_NO_ABBR_PATTERN = `(${NUMBER_PATTERN})\\s{0,5}(${matchAnyPattern(
|
|
180
|
+
TIME_UNIT_NO_ABBR_DICTIONARY
|
|
181
|
+
)})\\s{0,5}`;
|
|
182
|
+
|
|
183
|
+
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
|
184
|
+
export const TIME_UNITS_NO_ABBR_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_NO_ABBR_PATTERN);
|
|
185
|
+
|
|
186
|
+
export function parseNumberPattern(match: string): number {
|
|
187
|
+
const num = match.toLowerCase();
|
|
188
|
+
if (INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
|
189
|
+
return INTEGER_WORD_DICTIONARY[num];
|
|
190
|
+
}
|
|
191
|
+
return parseInt(num);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function parseYear(match: string): number {
|
|
195
|
+
if (/\d+/.test(match)) {
|
|
196
|
+
let yearNumber = parseInt(match);
|
|
197
|
+
if (yearNumber < 100) {
|
|
198
|
+
yearNumber = findMostLikelyADYear(yearNumber);
|
|
199
|
+
}
|
|
200
|
+
return yearNumber;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const num = match.toLowerCase();
|
|
204
|
+
if (INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
|
205
|
+
return INTEGER_WORD_DICTIONARY[num];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return parseInt(match);
|
|
209
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { includeCommonConfiguration } from "../../configurations";
|
|
2
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
3
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../results";
|
|
4
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
5
|
+
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
6
|
+
import ISOFormatParser from "../../common/parsers/ISOFormatParser";
|
|
7
|
+
import FITimeExpressionParser from "./parsers/FITimeExpressionParser";
|
|
8
|
+
import FIWeekdayParser from "./parsers/FIWeekdayParser";
|
|
9
|
+
import FIMonthNameLittleEndianParser from "./parsers/FIMonthNameLittleEndianParser";
|
|
10
|
+
import FITimeUnitCasualRelativeFormatParser from "./parsers/FITimeUnitCasualRelativeFormatParser";
|
|
11
|
+
import FITimeUnitAgoFormatParser from "./parsers/FITimeUnitAgoFormatParser";
|
|
12
|
+
import FITimeUnitWithinFormatParser from "./parsers/FITimeUnitWithinFormatParser";
|
|
13
|
+
import FICasualDateParser from "./parsers/FICasualDateParser";
|
|
14
|
+
import FICasualTimeParser from "./parsers/FICasualTimeParser";
|
|
15
|
+
import FIMergeDateRangeRefiner from "./refiners/FIMergeDateRangeRefiner";
|
|
16
|
+
import FIMergeDateTimeRefiner from "./refiners/FIMergeDateTimeRefiner";
|
|
17
|
+
|
|
18
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
19
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
20
|
+
|
|
21
|
+
// Shortcuts
|
|
22
|
+
export const casual = new Chrono(createCasualConfiguration());
|
|
23
|
+
export const strict = new Chrono(createConfiguration(true));
|
|
24
|
+
|
|
25
|
+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
|
|
26
|
+
return casual.parse(text, ref, option);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
|
|
30
|
+
return casual.parseDate(text, ref, option);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function createCasualConfiguration(littleEndian = true): Configuration {
|
|
34
|
+
const option = createConfiguration(false, littleEndian);
|
|
35
|
+
option.parsers.unshift(new FICasualTimeParser());
|
|
36
|
+
option.parsers.unshift(new FICasualDateParser());
|
|
37
|
+
option.parsers.unshift(new FITimeUnitCasualRelativeFormatParser());
|
|
38
|
+
return option;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createConfiguration(strictMode = true, littleEndian = true): Configuration {
|
|
42
|
+
return includeCommonConfiguration(
|
|
43
|
+
{
|
|
44
|
+
parsers: [
|
|
45
|
+
new ISOFormatParser(),
|
|
46
|
+
new SlashDateFormatParser(littleEndian),
|
|
47
|
+
new FITimeExpressionParser(),
|
|
48
|
+
new FIMonthNameLittleEndianParser(),
|
|
49
|
+
new FIWeekdayParser(),
|
|
50
|
+
new FITimeUnitWithinFormatParser(),
|
|
51
|
+
new FITimeUnitAgoFormatParser(),
|
|
52
|
+
],
|
|
53
|
+
refiners: [new FIMergeDateRangeRefiner(), new FIMergeDateTimeRefiner()],
|
|
54
|
+
},
|
|
55
|
+
strictMode
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
|
|
5
|
+
import FICasualTimeParser from "./FICasualTimeParser";
|
|
6
|
+
import * as references from "../../../common/casualReferences";
|
|
7
|
+
import { addDuration } from "../../../calculation/duration";
|
|
8
|
+
|
|
9
|
+
const PATTERN = new RegExp(
|
|
10
|
+
`(nyt|tänään|huomenna|ylihuomenna|eilen|toissapäivänä|viime\\s*yönä)` +
|
|
11
|
+
`(?:\\s*(aamulla|aamuna|aamupäivällä|päivällä|iltapäivällä|illalla|yöllä|keskiyöllä))?` +
|
|
12
|
+
`(?=\\W|$)`,
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const DATE_GROUP = 1;
|
|
17
|
+
const TIME_GROUP = 2;
|
|
18
|
+
|
|
19
|
+
export default class FICasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
20
|
+
innerPattern(context: ParsingContext): RegExp {
|
|
21
|
+
return PATTERN;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
25
|
+
let targetDate = context.reference.getDateWithAdjustedTimezone();
|
|
26
|
+
const dateKeyword = (match[DATE_GROUP] || "").toLowerCase();
|
|
27
|
+
const timeKeyword = (match[TIME_GROUP] || "").toLowerCase();
|
|
28
|
+
|
|
29
|
+
let component = context.createParsingComponents();
|
|
30
|
+
switch (dateKeyword) {
|
|
31
|
+
case "nyt":
|
|
32
|
+
component = references.now(context.reference);
|
|
33
|
+
break;
|
|
34
|
+
|
|
35
|
+
case "tänään":
|
|
36
|
+
component = references.today(context.reference);
|
|
37
|
+
break;
|
|
38
|
+
|
|
39
|
+
case "huomenna":
|
|
40
|
+
targetDate = addDuration(targetDate, { day: 1 });
|
|
41
|
+
assignSimilarDate(component, targetDate);
|
|
42
|
+
implySimilarTime(component, targetDate);
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case "ylihuomenna":
|
|
46
|
+
targetDate = addDuration(targetDate, { day: 2 });
|
|
47
|
+
assignSimilarDate(component, targetDate);
|
|
48
|
+
implySimilarTime(component, targetDate);
|
|
49
|
+
break;
|
|
50
|
+
|
|
51
|
+
case "eilen":
|
|
52
|
+
targetDate = addDuration(targetDate, { day: -1 });
|
|
53
|
+
assignSimilarDate(component, targetDate);
|
|
54
|
+
implySimilarTime(component, targetDate);
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
case "toissapäivänä":
|
|
58
|
+
targetDate = addDuration(targetDate, { day: -2 });
|
|
59
|
+
assignSimilarDate(component, targetDate);
|
|
60
|
+
implySimilarTime(component, targetDate);
|
|
61
|
+
break;
|
|
62
|
+
|
|
63
|
+
default:
|
|
64
|
+
if (dateKeyword.match(/viime\s*yönä/)) {
|
|
65
|
+
if (targetDate.getHours() > 6) {
|
|
66
|
+
targetDate = addDuration(targetDate, { day: -1 });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
assignSimilarDate(component, targetDate);
|
|
70
|
+
component.imply("hour", 0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (timeKeyword) {
|
|
77
|
+
component = FICasualTimeParser.extractTimeComponents(component, timeKeyword);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return component;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
export default class FICasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
8
|
+
innerPattern(context: ParsingContext): RegExp {
|
|
9
|
+
return /(tänä\s*)?(aamulla|aamuna|aamupäivällä|päivällä|iltapäivällä|illalla|yöllä|keskiyöllä)(?=\W|$)/i;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
13
|
+
const targetDate = context.refDate;
|
|
14
|
+
const timeKeywordPattern = match[2].toLowerCase();
|
|
15
|
+
const component = context.createParsingComponents();
|
|
16
|
+
implySimilarTime(component, targetDate);
|
|
17
|
+
return FICasualTimeParser.extractTimeComponents(component, timeKeywordPattern);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static extractTimeComponents(component: ParsingComponents, timeKeywordPattern: string): ParsingComponents {
|
|
21
|
+
switch (timeKeywordPattern) {
|
|
22
|
+
case "aamulla":
|
|
23
|
+
case "aamuna":
|
|
24
|
+
component.imply("hour", 6);
|
|
25
|
+
component.imply("minute", 0);
|
|
26
|
+
component.imply("second", 0);
|
|
27
|
+
component.imply("meridiem", Meridiem.AM);
|
|
28
|
+
break;
|
|
29
|
+
|
|
30
|
+
case "aamupäivällä":
|
|
31
|
+
component.imply("hour", 9);
|
|
32
|
+
component.imply("minute", 0);
|
|
33
|
+
component.imply("second", 0);
|
|
34
|
+
component.imply("meridiem", Meridiem.AM);
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case "päivällä":
|
|
38
|
+
component.imply("hour", 12);
|
|
39
|
+
component.imply("minute", 0);
|
|
40
|
+
component.imply("second", 0);
|
|
41
|
+
component.imply("meridiem", Meridiem.AM);
|
|
42
|
+
break;
|
|
43
|
+
|
|
44
|
+
case "iltapäivällä":
|
|
45
|
+
component.imply("hour", 15);
|
|
46
|
+
component.imply("minute", 0);
|
|
47
|
+
component.imply("second", 0);
|
|
48
|
+
component.imply("meridiem", Meridiem.PM);
|
|
49
|
+
break;
|
|
50
|
+
|
|
51
|
+
case "illalla":
|
|
52
|
+
component.imply("hour", 18);
|
|
53
|
+
component.imply("minute", 0);
|
|
54
|
+
component.imply("second", 0);
|
|
55
|
+
component.imply("meridiem", Meridiem.PM);
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case "yöllä":
|
|
59
|
+
component.imply("hour", 22);
|
|
60
|
+
component.imply("minute", 0);
|
|
61
|
+
component.imply("second", 0);
|
|
62
|
+
component.imply("meridiem", Meridiem.PM);
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case "keskiyöllä":
|
|
66
|
+
if (component.get("hour") > 1) {
|
|
67
|
+
component.addDurationAsImplied({ "day": 1 });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
component.imply("hour", 0);
|
|
71
|
+
component.imply("minute", 0);
|
|
72
|
+
component.imply("second", 0);
|
|
73
|
+
component.imply("meridiem", Meridiem.AM);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return component;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { findYearClosestToRef } from "../../../calculation/years";
|
|
4
|
+
import { MONTH_DICTIONARY } from "../constants";
|
|
5
|
+
import { parseYear } from "../constants";
|
|
6
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
8
|
+
|
|
9
|
+
const PATTERN = new RegExp(
|
|
10
|
+
`([0-9]{1,2})\\.?` +
|
|
11
|
+
`(?:\\s*(?:\\-|\\–|\\s)\\s*([0-9]{1,2})\\.?)?\\s*` +
|
|
12
|
+
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
13
|
+
`(?:(?:-|/|,?\\s*)([0-9]{4}(?![^\\s]\\d)))?` +
|
|
14
|
+
`(?=\\W|$)`,
|
|
15
|
+
"i"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const DATE_GROUP = 1;
|
|
19
|
+
const DATE_TO_GROUP = 2;
|
|
20
|
+
const MONTH_NAME_GROUP = 3;
|
|
21
|
+
const YEAR_GROUP = 4;
|
|
22
|
+
|
|
23
|
+
export default class FIMonthNameLittleEndianParser extends AbstractParserWithWordBoundaryChecking {
|
|
24
|
+
innerPattern(): RegExp {
|
|
25
|
+
return PATTERN;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
29
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
30
|
+
|
|
31
|
+
const month = MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
|
32
|
+
const day = parseInt(match[DATE_GROUP]);
|
|
33
|
+
if (day > 31) {
|
|
34
|
+
match.index = match.index + match[DATE_GROUP].length;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
result.start.assign("month", month);
|
|
39
|
+
result.start.assign("day", day);
|
|
40
|
+
|
|
41
|
+
if (match[YEAR_GROUP]) {
|
|
42
|
+
const yearNumber = parseYear(match[YEAR_GROUP]);
|
|
43
|
+
result.start.assign("year", yearNumber);
|
|
44
|
+
} else {
|
|
45
|
+
const year = findYearClosestToRef(context.refDate, day, month);
|
|
46
|
+
result.start.imply("year", year);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (match[DATE_TO_GROUP]) {
|
|
50
|
+
const endDate = parseInt(match[DATE_TO_GROUP]);
|
|
51
|
+
result.end = result.start.clone();
|
|
52
|
+
result.end.assign("day", endDate);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { ParsingContext } from "../../../chrono";
|
|
4
|
+
|
|
5
|
+
export default class FITimeExpressionParser extends AbstractTimeExpressionParser {
|
|
6
|
+
primaryPrefix(): string {
|
|
7
|
+
return "(?:(?:klo|kello)\\s*)?";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
followingPhase(): string {
|
|
11
|
+
return "\\s*(?:\\-|\\–|\\~|\\〜)\\s*";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
extractPrimaryTimeComponents(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | null {
|
|
15
|
+
// This looks more like a year e.g. 2020
|
|
16
|
+
if (match[0].match(/^\s*\d{4}\s*$/)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return super.extractPrimaryTimeComponents(context, match);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export default class FITimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
8
|
+
innerPattern(): RegExp {
|
|
9
|
+
return new RegExp(`(${TIME_UNITS_PATTERN})\\s*sitten(?=\\W|$)`, "i");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
+
const timeUnits = parseDuration(match[1]);
|
|
14
|
+
const outputTimeUnits = reverseDuration(timeUnits);
|
|
15
|
+
|
|
16
|
+
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, TIME_UNITS_NO_ABBR_PATTERN } 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
|
+
|
|
7
|
+
const PATTERN = new RegExp(
|
|
8
|
+
`(seuraava|seuraavat|seuraavien|edellinen|edelliset|edellisten|viimeiset|viimeisten|kuluneet|kuluneiden|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
9
|
+
"i"
|
|
10
|
+
);
|
|
11
|
+
const PATTERN_NO_ABBR = new RegExp(
|
|
12
|
+
`(seuraava|seuraavat|seuraavien|edellinen|edelliset|edellisten|viimeiset|viimeisten|kuluneet|kuluneiden|\\+|-)\\s*(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`,
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default class FITimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
17
|
+
constructor(private allowAbbreviations: boolean = true) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
innerPattern(): RegExp {
|
|
22
|
+
return this.allowAbbreviations ? PATTERN : PATTERN_NO_ABBR;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
26
|
+
const prefix = match[1].toLowerCase();
|
|
27
|
+
let duration = parseDuration(match[2]);
|
|
28
|
+
if (!duration) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
switch (prefix) {
|
|
33
|
+
case "edellinen":
|
|
34
|
+
case "edelliset":
|
|
35
|
+
case "edellisten":
|
|
36
|
+
case "viimeiset":
|
|
37
|
+
case "viimeisten":
|
|
38
|
+
case "kuluneet":
|
|
39
|
+
case "kuluneiden":
|
|
40
|
+
case "-":
|
|
41
|
+
duration = reverseDuration(duration);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return ParsingComponents.createRelativeFromReference(context.reference, duration);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
|
|
6
|
+
export default class FITimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
7
|
+
innerPattern(): RegExp {
|
|
8
|
+
return new RegExp(`(${TIME_UNITS_PATTERN})\\s*(?:sisällä|kuluessa|päästä)(?=\\W|$)`, "i");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
12
|
+
const timeUnits = parseDuration(match[1]);
|
|
13
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
"(?:(?:\\,|\\(|\\()\\s*)?" +
|
|
10
|
+
"(?:(viime|edellinen|edellisenä|ensi|seuraava|seuraavana|tämä|tänä)\\s*)?" +
|
|
11
|
+
`(${matchAnyPattern(WEEKDAY_DICTIONARY)})` +
|
|
12
|
+
"(?:\\s*(?:\\,|\\)|\\)))?" +
|
|
13
|
+
"(?:\\s*(viime|ensi|seuraava)\\s*viikolla)?" +
|
|
14
|
+
"(?=\\W|$)",
|
|
15
|
+
"i"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const PREFIX_GROUP = 1;
|
|
19
|
+
const WEEKDAY_GROUP = 2;
|
|
20
|
+
const SUFFIX_GROUP = 3;
|
|
21
|
+
|
|
22
|
+
export default class FIWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
23
|
+
innerPattern(): RegExp {
|
|
24
|
+
return PATTERN;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
28
|
+
const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
|
29
|
+
const offset = WEEKDAY_DICTIONARY[dayOfWeek];
|
|
30
|
+
const prefix = match[PREFIX_GROUP];
|
|
31
|
+
const postfix = match[SUFFIX_GROUP];
|
|
32
|
+
|
|
33
|
+
let modifierWord = prefix || postfix;
|
|
34
|
+
modifierWord = modifierWord || "";
|
|
35
|
+
modifierWord = modifierWord.toLowerCase();
|
|
36
|
+
|
|
37
|
+
let modifier = null;
|
|
38
|
+
if (modifierWord.match(/viime|edellinen|edellisenä/)) {
|
|
39
|
+
modifier = "last";
|
|
40
|
+
} else if (modifierWord.match(/ensi|seuraava|seuraavana/)) {
|
|
41
|
+
modifier = "next";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return createParsingComponentsAtWeekday(context.reference, offset, modifier);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AbstractMergeDateTimeRefiner from "../../../common/refiners/AbstractMergeDateTimeRefiner";
|
|
2
|
+
|
|
3
|
+
export default class FIMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner {
|
|
4
|
+
patternBetween(): RegExp {
|
|
5
|
+
return new RegExp("^\\s*(T|klo|kello|,|-)?\\s*$");
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -17,7 +17,7 @@ export default class ENTimeExpressionParser extends AbstractTimeExpressionParser
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
primarySuffix(): string {
|
|
20
|
-
return "(?:\\s*(?:o\\W*in punto|
|
|
20
|
+
return "(?:\\s*(?:in punto|o\\W*in punto|(?:di|del|della|in|al|alla|alle)\\s*(?:mattina|pomeriggio|sera)))?(?!/)(?=\\W|$)";
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
extractPrimaryTimeComponents(context: ParsingContext, match: RegExpMatchArray): null | ParsingComponents {
|