chrono-node 2.6.3 → 2.6.5
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 +25 -3
- package/dist/cjs/calculation/mergingCalculation.js +2 -2
- package/dist/cjs/chrono.d.ts +3 -1
- package/dist/cjs/chrono.js +10 -4
- package/dist/cjs/chrono.js.map +1 -1
- package/dist/cjs/common/calculation/weekdays.d.ts +1 -1
- package/dist/cjs/common/calculation/weekdays.js +7 -7
- package/dist/cjs/common/casualReferences.js +7 -7
- package/dist/cjs/common/parsers/AbstractParserWithWordBoundary.d.ts +1 -1
- package/dist/cjs/common/parsers/AbstractTimeExpressionParser.js +16 -16
- package/dist/cjs/common/refiners/ExtractTimezoneAbbrRefiner.d.ts +1 -1
- package/dist/cjs/index.d.ts +8 -63
- package/dist/cjs/index.js +10 -31
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/locales/de/index.d.ts +5 -2
- package/dist/cjs/locales/de/index.js +9 -1
- package/dist/cjs/locales/de/index.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DECasualTimeParser.js +8 -8
- package/dist/cjs/locales/de/parsers/DESpecificTimeExpressionParser.js +9 -9
- package/dist/cjs/locales/en/configuration.d.ts +5 -0
- package/dist/cjs/locales/en/configuration.js +57 -0
- package/dist/cjs/locales/en/configuration.js.map +1 -0
- package/dist/cjs/locales/en/constants.d.ts +1 -1
- package/dist/cjs/locales/en/index.d.ts +5 -4
- package/dist/cjs/locales/en/index.js +14 -51
- package/dist/cjs/locales/en/index.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeExpressionParser.js +5 -5
- package/dist/cjs/locales/es/index.d.ts +5 -2
- package/dist/cjs/locales/es/index.js +9 -1
- package/dist/cjs/locales/es/index.js.map +1 -1
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js +5 -5
- package/dist/cjs/locales/fr/index.d.ts +5 -2
- package/dist/cjs/locales/fr/index.js +9 -1
- package/dist/cjs/locales/fr/index.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRCasualDateParser.js +2 -2
- package/dist/cjs/locales/fr/parsers/FRCasualTimeParser.js +6 -6
- package/dist/cjs/locales/fr/parsers/FRSpecificTimeExpressionParser.js +6 -6
- package/dist/cjs/locales/ja/index.d.ts +5 -2
- package/dist/cjs/locales/ja/index.js +9 -1
- package/dist/cjs/locales/ja/index.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.d.ts +1 -1
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js +27 -5
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPStandardParser.d.ts +1 -1
- package/dist/cjs/locales/nl/index.d.ts +5 -2
- package/dist/cjs/locales/nl/index.js +9 -1
- package/dist/cjs/locales/nl/index.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualDateTimeParser.js +5 -5
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js +5 -5
- package/dist/cjs/locales/nl/parsers/NLMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/nl/parsers/NLMonthNameParser.d.ts +1 -1
- package/dist/cjs/locales/pt/index.d.ts +5 -2
- package/dist/cjs/locales/pt/index.js +9 -1
- package/dist/cjs/locales/pt/index.js.map +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js +5 -5
- package/dist/cjs/locales/ru/index.d.ts +5 -2
- package/dist/cjs/locales/ru/index.js +9 -1
- package/dist/cjs/locales/ru/index.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RUCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/ru/parsers/RUMonthNameParser.d.ts +1 -1
- package/dist/cjs/locales/ru/parsers/RUTimeExpressionParser.js +5 -5
- package/dist/cjs/locales/uk/constants.d.ts +33 -0
- package/dist/cjs/locales/uk/constants.js +301 -0
- package/dist/cjs/locales/uk/constants.js.map +1 -0
- package/dist/cjs/locales/uk/index.d.ts +11 -0
- package/dist/cjs/locales/uk/index.js +66 -0
- package/dist/cjs/locales/uk/index.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.js +56 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.d.ts +7 -0
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js +77 -0
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.js +59 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.d.ts +7 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.js +45 -0
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js +66 -0
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeExpressionParser.d.ts +12 -0
- package/dist/cjs/locales/uk/parsers/UKTimeExpressionParser.js +57 -0
- package/dist/cjs/locales/uk/parsers/UKTimeExpressionParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +22 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +29 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +22 -0
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.d.ts +8 -0
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.js +50 -0
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.js.map +1 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateRangeRefiner.d.ts +4 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateRangeRefiner.js +13 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateRangeRefiner.js.map +1 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateTimeRefiner.d.ts +4 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateTimeRefiner.js +13 -0
- package/dist/cjs/locales/uk/refiners/UKMergeDateTimeRefiner.js.map +1 -0
- package/dist/cjs/locales/zh/hans/index.d.ts +5 -2
- package/dist/cjs/locales/zh/hans/index.js +10 -2
- package/dist/cjs/locales/zh/hans/index.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hant/index.d.ts +5 -2
- package/dist/cjs/locales/zh/hant/index.js +10 -2
- package/dist/cjs/locales/zh/hant/index.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +1 -1
- package/dist/cjs/results.d.ts +1 -1
- package/dist/cjs/timezone.d.ts +1 -1
- package/dist/cjs/timezone.js +11 -11
- package/dist/cjs/types.d.ts +58 -0
- package/dist/cjs/types.js +34 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/dayjs.js +3 -3
- package/dist/esm/calculation/mergingCalculation.js +1 -1
- package/dist/esm/chrono.d.ts +3 -1
- package/dist/esm/chrono.js +7 -4
- package/dist/esm/chrono.js.map +1 -1
- package/dist/esm/common/calculation/weekdays.d.ts +1 -1
- package/dist/esm/common/calculation/weekdays.js +1 -1
- package/dist/esm/common/casualReferences.js +1 -1
- package/dist/esm/common/parsers/AbstractParserWithWordBoundary.d.ts +1 -1
- package/dist/esm/common/parsers/AbstractTimeExpressionParser.js +1 -1
- package/dist/esm/common/refiners/ExtractTimezoneAbbrRefiner.d.ts +1 -1
- package/dist/esm/index.d.ts +8 -63
- package/dist/esm/index.js +6 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/locales/de/index.d.ts +5 -2
- package/dist/esm/locales/de/index.js +4 -0
- package/dist/esm/locales/de/index.js.map +1 -1
- package/dist/esm/locales/de/parsers/DECasualTimeParser.js +1 -1
- package/dist/esm/locales/de/parsers/DESpecificTimeExpressionParser.js +1 -1
- package/dist/esm/locales/en/configuration.d.ts +5 -0
- package/dist/esm/locales/en/configuration.js +51 -0
- package/dist/esm/locales/en/configuration.js.map +1 -0
- package/dist/esm/locales/en/constants.d.ts +1 -1
- package/dist/esm/locales/en/index.d.ts +5 -4
- package/dist/esm/locales/en/index.js +9 -48
- package/dist/esm/locales/en/index.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENTimeExpressionParser.js +1 -1
- package/dist/esm/locales/es/index.d.ts +5 -2
- package/dist/esm/locales/es/index.js +4 -0
- package/dist/esm/locales/es/index.js.map +1 -1
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.js +1 -1
- package/dist/esm/locales/fr/index.d.ts +5 -2
- package/dist/esm/locales/fr/index.js +4 -0
- package/dist/esm/locales/fr/index.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRCasualDateParser.js +1 -1
- package/dist/esm/locales/fr/parsers/FRCasualTimeParser.js +1 -1
- package/dist/esm/locales/fr/parsers/FRSpecificTimeExpressionParser.js +1 -1
- package/dist/esm/locales/ja/index.d.ts +5 -2
- package/dist/esm/locales/ja/index.js +4 -0
- package/dist/esm/locales/ja/index.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.d.ts +1 -1
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js +25 -3
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPStandardParser.d.ts +1 -1
- package/dist/esm/locales/nl/index.d.ts +5 -2
- package/dist/esm/locales/nl/index.js +4 -0
- package/dist/esm/locales/nl/index.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualDateTimeParser.js +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js +1 -1
- package/dist/esm/locales/nl/parsers/NLMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/esm/locales/nl/parsers/NLMonthNameParser.d.ts +1 -1
- package/dist/esm/locales/pt/index.d.ts +5 -2
- package/dist/esm/locales/pt/index.js +4 -0
- package/dist/esm/locales/pt/index.js.map +1 -1
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js +1 -1
- package/dist/esm/locales/ru/index.d.ts +5 -2
- package/dist/esm/locales/ru/index.js +4 -0
- package/dist/esm/locales/ru/index.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RUCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/ru/parsers/RUMonthNameParser.d.ts +1 -1
- package/dist/esm/locales/ru/parsers/RUTimeExpressionParser.js +1 -1
- package/dist/esm/locales/uk/constants.d.ts +33 -0
- package/dist/esm/locales/uk/constants.js +324 -0
- package/dist/esm/locales/uk/constants.js.map +1 -0
- package/dist/esm/locales/uk/index.d.ts +11 -0
- package/dist/esm/locales/uk/index.js +52 -0
- package/dist/esm/locales/uk/index.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.js +34 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.d.ts +7 -0
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js +52 -0
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.js +56 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.d.ts +7 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.js +42 -0
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js +60 -0
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeExpressionParser.d.ts +12 -0
- package/dist/esm/locales/uk/parsers/UKTimeExpressionParser.js +54 -0
- package/dist/esm/locales/uk/parsers/UKTimeExpressionParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +19 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +26 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +19 -0
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.d.ts +8 -0
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.js +47 -0
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.js.map +1 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateRangeRefiner.d.ts +4 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateRangeRefiner.js +7 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateRangeRefiner.js.map +1 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateTimeRefiner.d.ts +4 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateTimeRefiner.js +7 -0
- package/dist/esm/locales/uk/refiners/UKMergeDateTimeRefiner.js.map +1 -0
- package/dist/esm/locales/zh/hans/index.d.ts +5 -2
- package/dist/esm/locales/zh/hans/index.js +5 -1
- package/dist/esm/locales/zh/hans/index.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.d.ts +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +1 -1
- package/dist/esm/locales/zh/hant/index.d.ts +5 -2
- package/dist/esm/locales/zh/hant/index.js +5 -1
- package/dist/esm/locales/zh/hant/index.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.d.ts +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +1 -1
- package/dist/esm/results.d.ts +1 -1
- package/dist/esm/timezone.d.ts +1 -1
- package/dist/esm/timezone.js +1 -1
- package/dist/esm/types.d.ts +58 -0
- package/dist/esm/types.js +31 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/dayjs.js +1 -1
- package/package.json +9 -1
- package/src/calculation/mergingCalculation.ts +1 -1
- package/src/chrono.ts +14 -8
- package/src/common/calculation/weekdays.ts +1 -1
- package/src/common/casualReferences.ts +1 -1
- package/src/common/parsers/AbstractParserWithWordBoundary.ts +1 -1
- package/src/common/parsers/AbstractTimeExpressionParser.ts +1 -1
- package/src/common/parsers/ISOFormatParser.ts +1 -1
- package/src/common/refiners/ExtractTimezoneAbbrRefiner.ts +3 -3
- package/src/configurations.ts +1 -1
- package/src/index.ts +7 -153
- package/src/locales/de/index.ts +6 -2
- package/src/locales/de/parsers/DECasualTimeParser.ts +1 -1
- package/src/locales/de/parsers/DESpecificTimeExpressionParser.ts +1 -1
- package/src/locales/en/configuration.ts +71 -0
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/index.ts +11 -65
- package/src/locales/en/parsers/ENTimeExpressionParser.ts +1 -1
- package/src/locales/es/index.ts +6 -2
- package/src/locales/es/parsers/ESCasualTimeParser.ts +1 -1
- package/src/locales/fr/index.ts +6 -2
- package/src/locales/fr/parsers/FRCasualDateParser.ts +1 -1
- package/src/locales/fr/parsers/FRCasualTimeParser.ts +1 -1
- package/src/locales/fr/parsers/FRSpecificTimeExpressionParser.ts +1 -1
- package/src/locales/ja/index.ts +6 -2
- package/src/locales/ja/parsers/JPCasualDateParser.ts +26 -3
- package/src/locales/nl/index.ts +6 -2
- package/src/locales/nl/parsers/NLCasualDateTimeParser.ts +1 -1
- package/src/locales/nl/parsers/NLCasualTimeParser.ts +1 -1
- package/src/locales/pt/index.ts +6 -2
- package/src/locales/pt/parsers/PTCasualTimeParser.ts +1 -1
- package/src/locales/ru/index.ts +6 -2
- package/src/locales/ru/parsers/RUTimeExpressionParser.ts +1 -1
- package/src/locales/uk/constants.ts +349 -0
- package/src/locales/uk/index.ts +90 -0
- package/src/locales/uk/parsers/UKCasualDateParser.ts +50 -0
- package/src/locales/uk/parsers/UKCasualTimeParser.ts +59 -0
- package/src/locales/uk/parsers/UKMonthNameLittleEndianParser.ts +72 -0
- package/src/locales/uk/parsers/UKMonthNameParser.ts +61 -0
- package/src/locales/uk/parsers/UKRelativeDateFormatParser.ts +85 -0
- package/src/locales/uk/parsers/UKTimeExpressionParser.ts +64 -0
- package/src/locales/uk/parsers/UKTimeUnitAgoFormatParser.ts +24 -0
- package/src/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.ts +34 -0
- package/src/locales/uk/parsers/UKTimeUnitWithinFormatParser.ts +27 -0
- package/src/locales/uk/parsers/UKWeekdayParser.ts +59 -0
- package/src/locales/uk/refiners/UKMergeDateRangeRefiner.ts +13 -0
- package/src/locales/uk/refiners/UKMergeDateTimeRefiner.ts +13 -0
- package/src/locales/zh/hans/index.ts +6 -2
- package/src/locales/zh/hant/index.ts +6 -2
- package/src/results.ts +1 -1
- package/src/timezone.ts +1 -1
- package/src/types.ts +150 -0
- package/src/utils/dayjs.ts +1 -1
- package/test/debugging.test.ts +17 -0
- package/test/en/en_month_name_little_endian.test.ts +12 -0
- package/test/en/en_time_units_within.test.ts +7 -0
- package/test/en/en_timezone_exp.test.ts +48 -4
- package/test/ja/ja_casual.test.ts +50 -13
- package/test/uk/uk_casual.test.ts +153 -0
- package/test/uk/uk_month.test.ts +70 -0
- package/test/uk/uk_month_name_little_endian.test.ts +148 -0
- package/test/uk/uk_relative.test.ts +74 -0
- package/test/uk/uk_time_exp.test.ts +111 -0
- package/test/uk/uk_time_units_ago.test.ts +48 -0
- package/test/uk/uk_time_units_casual_relative.test.ts +112 -0
- package/test/uk/uk_time_units_within.test.ts +16 -0
- package/test/uk/uk_weekday.test.ts +52 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
import * as references from "../../../common/casualReferences";
|
|
5
|
+
import { REGEX_PARTS } from "../constants";
|
|
6
|
+
|
|
7
|
+
const PATTERN = new RegExp(
|
|
8
|
+
`(?:з|із|від)?\\s*(сьогодні|вчора|завтра|післязавтра|післяпіслязавтра|позапозавчора|позавчора)${REGEX_PARTS.rightBoundary}`,
|
|
9
|
+
REGEX_PARTS.flags
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default class UKCasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
13
|
+
patternLeftBoundary(): string {
|
|
14
|
+
return REGEX_PARTS.leftBoundary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
innerPattern(context: ParsingContext): RegExp {
|
|
18
|
+
return PATTERN;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
22
|
+
const lowerText = match[1].toLowerCase();
|
|
23
|
+
const component = context.createParsingComponents();
|
|
24
|
+
|
|
25
|
+
switch (lowerText) {
|
|
26
|
+
case "сьогодні":
|
|
27
|
+
return references.today(context.reference);
|
|
28
|
+
|
|
29
|
+
case "вчора":
|
|
30
|
+
return references.yesterday(context.reference);
|
|
31
|
+
|
|
32
|
+
case "завтра":
|
|
33
|
+
return references.tomorrow(context.reference);
|
|
34
|
+
|
|
35
|
+
case "післязавтра":
|
|
36
|
+
return references.theDayAfter(context.reference, 2);
|
|
37
|
+
|
|
38
|
+
case "післяпіслязавтра":
|
|
39
|
+
return references.theDayAfter(context.reference, 3);
|
|
40
|
+
|
|
41
|
+
case "позавчора":
|
|
42
|
+
return references.theDayBefore(context.reference, 2);
|
|
43
|
+
|
|
44
|
+
case "позапозавчора":
|
|
45
|
+
return references.theDayBefore(context.reference, 3);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return component;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
+
import * as references from "../../../common/casualReferences";
|
|
4
|
+
import { assignSimilarDate } from "../../../utils/dayjs";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import { REGEX_PARTS } from "../constants";
|
|
7
|
+
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
`(зараз|минулого\\s*вечора|минулої\\s*ночі|наступної\\s*ночі|сьогодні\\s*вночі|цієї\\s*ночі|цього ранку|вранці|ранку|зранку|опівдні|ввечері|вечора|опівночі|вночі)` +
|
|
10
|
+
`${REGEX_PARTS.rightBoundary}`,
|
|
11
|
+
REGEX_PARTS.flags
|
|
12
|
+
);
|
|
13
|
+
export default class UKCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
14
|
+
patternLeftBoundary(): string {
|
|
15
|
+
return REGEX_PARTS.leftBoundary;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
innerPattern() {
|
|
19
|
+
return PATTERN;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
23
|
+
let targetDate = dayjs(context.reference.instant);
|
|
24
|
+
const lowerText = match[0].toLowerCase();
|
|
25
|
+
const component = context.createParsingComponents();
|
|
26
|
+
|
|
27
|
+
if (lowerText === "зараз") {
|
|
28
|
+
return references.now(context.reference);
|
|
29
|
+
}
|
|
30
|
+
if (lowerText === "ввечері" || lowerText === "вечора") {
|
|
31
|
+
return references.evening(context.reference);
|
|
32
|
+
}
|
|
33
|
+
if (lowerText.endsWith("вранці") || lowerText.endsWith("ранку") || lowerText.endsWith("зранку")) {
|
|
34
|
+
return references.morning(context.reference);
|
|
35
|
+
}
|
|
36
|
+
if (lowerText.endsWith("опівдні")) {
|
|
37
|
+
return references.noon(context.reference);
|
|
38
|
+
}
|
|
39
|
+
if (lowerText.match(/минулої\s*ночі/)) {
|
|
40
|
+
return references.lastNight(context.reference);
|
|
41
|
+
}
|
|
42
|
+
if (lowerText.match(/минулого\s*вечора/)) {
|
|
43
|
+
return references.yesterdayEvening(context.reference);
|
|
44
|
+
}
|
|
45
|
+
if (lowerText.match(/наступної\s*ночі/)) {
|
|
46
|
+
const daysToAdd = targetDate.hour() < 22 ? 1 : 2;
|
|
47
|
+
targetDate = targetDate.add(daysToAdd, "day");
|
|
48
|
+
assignSimilarDate(component, targetDate);
|
|
49
|
+
component.imply("hour", 1);
|
|
50
|
+
}
|
|
51
|
+
if (lowerText.match(/цієї\s*ночі/)) {
|
|
52
|
+
return references.midnight(context.reference);
|
|
53
|
+
}
|
|
54
|
+
if (lowerText.endsWith("опівночі") || lowerText.endsWith("вночі")) {
|
|
55
|
+
return references.midnight(context.reference);
|
|
56
|
+
}
|
|
57
|
+
return component;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { findYearClosestToRef } from "../../../calculation/years";
|
|
4
|
+
import { MONTH_DICTIONARY, REGEX_PARTS } from "../constants";
|
|
5
|
+
import { YEAR_PATTERN, parseYearPattern } from "../constants";
|
|
6
|
+
import { ORDINAL_NUMBER_PATTERN, parseOrdinalNumberPattern } from "../constants";
|
|
7
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
8
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
9
|
+
|
|
10
|
+
// prettier-ignore
|
|
11
|
+
const PATTERN = new RegExp(
|
|
12
|
+
`(?:з|із)?\\s*(${ORDINAL_NUMBER_PATTERN})` +
|
|
13
|
+
`(?:` +
|
|
14
|
+
`\\s{0,3}(?:по|-|–|до)?\\s{0,3}` +
|
|
15
|
+
`(${ORDINAL_NUMBER_PATTERN})` +
|
|
16
|
+
`)?` +
|
|
17
|
+
`(?:-|\\/|\\s{0,3}(?:of)?\\s{0,3})` +
|
|
18
|
+
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
19
|
+
`(?:` +
|
|
20
|
+
`(?:-|\\/|,?\\s{0,3})` +
|
|
21
|
+
`(${YEAR_PATTERN}(?![^\\s]\\d))` +
|
|
22
|
+
`)?` +
|
|
23
|
+
`${REGEX_PARTS.rightBoundary}`,
|
|
24
|
+
REGEX_PARTS.flags
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const DATE_GROUP = 1;
|
|
28
|
+
const DATE_TO_GROUP = 2;
|
|
29
|
+
const MONTH_NAME_GROUP = 3;
|
|
30
|
+
const YEAR_GROUP = 4;
|
|
31
|
+
|
|
32
|
+
export default class UKMonthNameLittleEndianParser extends AbstractParserWithWordBoundaryChecking {
|
|
33
|
+
patternLeftBoundary(): string {
|
|
34
|
+
return REGEX_PARTS.leftBoundary;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
innerPattern(): RegExp {
|
|
38
|
+
return PATTERN;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
42
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
43
|
+
|
|
44
|
+
const month = MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
|
45
|
+
const day = parseOrdinalNumberPattern(match[DATE_GROUP]);
|
|
46
|
+
if (day > 31) {
|
|
47
|
+
// e.g. "[96 Aug]" => "9[6 Aug]", we need to shift away from the next number
|
|
48
|
+
match.index = match.index + match[DATE_GROUP].length;
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
result.start.assign("month", month);
|
|
53
|
+
result.start.assign("day", day);
|
|
54
|
+
|
|
55
|
+
if (match[YEAR_GROUP]) {
|
|
56
|
+
const yearNumber = parseYearPattern(match[YEAR_GROUP]);
|
|
57
|
+
result.start.assign("year", yearNumber);
|
|
58
|
+
} else {
|
|
59
|
+
const year = findYearClosestToRef(context.reference.instant, day, month);
|
|
60
|
+
result.start.imply("year", year);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (match[DATE_TO_GROUP]) {
|
|
64
|
+
const endDate = parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
|
65
|
+
|
|
66
|
+
result.end = result.start.clone();
|
|
67
|
+
result.end.assign("day", endDate);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FULL_MONTH_NAME_DICTIONARY, MONTH_DICTIONARY, REGEX_PARTS } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { findYearClosestToRef } from "../../../calculation/years";
|
|
4
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
|
+
import { YEAR_PATTERN, parseYearPattern } from "../constants";
|
|
6
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
7
|
+
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
`((?:в|у)\\s*)?` +
|
|
10
|
+
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
11
|
+
`\\s*` +
|
|
12
|
+
`(?:` +
|
|
13
|
+
`[,-]?\\s*(${YEAR_PATTERN})?` +
|
|
14
|
+
`)?` +
|
|
15
|
+
`(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,
|
|
16
|
+
REGEX_PARTS.flags
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const MONTH_NAME_GROUP = 2;
|
|
20
|
+
const YEAR_GROUP = 3;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The parser for parsing month name and year.
|
|
24
|
+
* - Cічень, 2012
|
|
25
|
+
* - Січень 2012
|
|
26
|
+
* - Січень
|
|
27
|
+
*/
|
|
28
|
+
export default class UkMonthNameParser extends AbstractParserWithWordBoundaryChecking {
|
|
29
|
+
patternLeftBoundary(): string {
|
|
30
|
+
return REGEX_PARTS.leftBoundary;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
innerPattern(): RegExp {
|
|
34
|
+
return PATTERN;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
38
|
+
const monthName = match[MONTH_NAME_GROUP].toLowerCase();
|
|
39
|
+
|
|
40
|
+
// skip some unlikely words "січ", "лют", ..
|
|
41
|
+
if (match[0].length <= 3 && !FULL_MONTH_NAME_DICTIONARY[monthName]) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const result = context.createParsingResult(match.index, match.index + match[0].length);
|
|
46
|
+
result.start.imply("day", 1);
|
|
47
|
+
|
|
48
|
+
const month = MONTH_DICTIONARY[monthName];
|
|
49
|
+
result.start.assign("month", month);
|
|
50
|
+
|
|
51
|
+
if (match[YEAR_GROUP]) {
|
|
52
|
+
const year = parseYearPattern(match[YEAR_GROUP]);
|
|
53
|
+
result.start.assign("year", year);
|
|
54
|
+
} else {
|
|
55
|
+
const year = findYearClosestToRef(context.reference.instant, 1, month);
|
|
56
|
+
result.start.imply("year", year);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { REGEX_PARTS, TIME_UNIT_DICTIONARY } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import dayjs from "dayjs";
|
|
5
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
|
+
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
`(в минулому|у минулому|на минулому|минулого|на наступному|в наступному|у наступному|наступного|на цьому|в цьому|у цьому|цього)\\s*(${matchAnyPattern(
|
|
10
|
+
TIME_UNIT_DICTIONARY
|
|
11
|
+
)})(?=\\s*)${REGEX_PARTS.rightBoundary}`,
|
|
12
|
+
REGEX_PARTS.flags
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const MODIFIER_WORD_GROUP = 1;
|
|
16
|
+
const RELATIVE_WORD_GROUP = 2;
|
|
17
|
+
|
|
18
|
+
export default class UKRelativeDateFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
19
|
+
patternLeftBoundary(): string {
|
|
20
|
+
return REGEX_PARTS.leftBoundary;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
innerPattern(): RegExp {
|
|
24
|
+
return PATTERN;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
28
|
+
const modifier = match[MODIFIER_WORD_GROUP].toLowerCase();
|
|
29
|
+
const unitWord = match[RELATIVE_WORD_GROUP].toLowerCase();
|
|
30
|
+
const timeunit = TIME_UNIT_DICTIONARY[unitWord];
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
modifier == "на наступному" ||
|
|
34
|
+
modifier == "в наступному" ||
|
|
35
|
+
modifier == "у наступному" ||
|
|
36
|
+
modifier == "наступного"
|
|
37
|
+
) {
|
|
38
|
+
const timeUnits = {};
|
|
39
|
+
timeUnits[timeunit] = 1;
|
|
40
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
modifier == "на минулому" ||
|
|
45
|
+
modifier == "в минулому" ||
|
|
46
|
+
modifier == "у минулому" ||
|
|
47
|
+
modifier == "минулого"
|
|
48
|
+
) {
|
|
49
|
+
const timeUnits = {};
|
|
50
|
+
timeUnits[timeunit] = -1;
|
|
51
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const components = context.createParsingComponents();
|
|
55
|
+
let date = dayjs(context.reference.instant);
|
|
56
|
+
|
|
57
|
+
// This week
|
|
58
|
+
if (timeunit.match(/week/i)) {
|
|
59
|
+
date = date.add(-date.get("d"), "d");
|
|
60
|
+
components.imply("day", date.date());
|
|
61
|
+
components.imply("month", date.month() + 1);
|
|
62
|
+
components.imply("year", date.year());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// This month
|
|
66
|
+
else if (timeunit.match(/month/i)) {
|
|
67
|
+
date = date.add(-date.date() + 1, "d");
|
|
68
|
+
components.imply("day", date.date());
|
|
69
|
+
components.assign("year", date.year());
|
|
70
|
+
components.assign("month", date.month() + 1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// This year
|
|
74
|
+
else if (timeunit.match(/year/i)) {
|
|
75
|
+
date = date.add(-date.date() + 1, "d");
|
|
76
|
+
date = date.add(-date.month(), "month");
|
|
77
|
+
|
|
78
|
+
components.imply("day", date.date());
|
|
79
|
+
components.imply("month", date.month() + 1);
|
|
80
|
+
components.assign("year", date.year());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return components;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
|
+
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
5
|
+
import { REGEX_PARTS } from "../constants";
|
|
6
|
+
|
|
7
|
+
export default class UKTimeExpressionParser extends AbstractTimeExpressionParser {
|
|
8
|
+
constructor(strictMode) {
|
|
9
|
+
super(strictMode);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
patternFlags(): string {
|
|
13
|
+
return REGEX_PARTS.flags;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
primaryPatternLeftBoundary(): string {
|
|
17
|
+
return `(^|\\s|T|(?:[^\\p{L}\\p{N}_]))`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
followingPhase(): string {
|
|
21
|
+
return `\\s*(?:\\-|\\–|\\~|\\〜|до|і|по|\\?)\\s*`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
primaryPrefix(): string {
|
|
25
|
+
return `(?:(?:в|у|о|об|з|із|від)\\s*)??`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
primarySuffix(): string {
|
|
29
|
+
return `(?:\\s*(?:ранку|вечора|по обіді|після обіду))?(?!\\/)${REGEX_PARTS.rightBoundary}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
extractPrimaryTimeComponents(context: ParsingContext, match: RegExpMatchArray): null | ParsingComponents {
|
|
33
|
+
const components = super.extractPrimaryTimeComponents(context, match);
|
|
34
|
+
if (components) {
|
|
35
|
+
if (match[0].endsWith("вечора")) {
|
|
36
|
+
const hour = components.get("hour");
|
|
37
|
+
if (hour >= 6 && hour < 12) {
|
|
38
|
+
components.assign("hour", components.get("hour") + 12);
|
|
39
|
+
components.assign("meridiem", Meridiem.PM);
|
|
40
|
+
} else if (hour < 6) {
|
|
41
|
+
components.assign("meridiem", Meridiem.AM);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (match[0].endsWith("по обіді") || match[0].endsWith("після обіду")) {
|
|
46
|
+
components.assign("meridiem", Meridiem.PM);
|
|
47
|
+
const hour = components.get("hour");
|
|
48
|
+
if (hour >= 0 && hour <= 6) {
|
|
49
|
+
components.assign("hour", components.get("hour") + 12);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (match[0].endsWith("ранку")) {
|
|
54
|
+
components.assign("meridiem", Meridiem.AM);
|
|
55
|
+
const hour = components.get("hour");
|
|
56
|
+
if (hour < 12) {
|
|
57
|
+
components.assign("hour", components.get("hour"));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return components;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { parseTimeUnits, REGEX_PARTS, TIME_UNITS_PATTERN } from "../constants";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
6
|
+
|
|
7
|
+
const PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}тому(?=(?:\\W|$))`, REGEX_PARTS.flags);
|
|
8
|
+
|
|
9
|
+
export default class UKTimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
10
|
+
patternLeftBoundary(): string {
|
|
11
|
+
return REGEX_PARTS.leftBoundary;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
innerPattern(): RegExp {
|
|
15
|
+
return PATTERN;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
19
|
+
const timeUnits = parseTimeUnits(match[1]);
|
|
20
|
+
const outputTimeUnits = reverseTimeUnits(timeUnits);
|
|
21
|
+
|
|
22
|
+
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseTimeUnits, REGEX_PARTS } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
6
|
+
|
|
7
|
+
const PATTERN = new RegExp(
|
|
8
|
+
`(ці|останні|минулі|майбутні|наступні|після|через|\\+|-)\\s*(${TIME_UNITS_PATTERN})${REGEX_PARTS.rightBoundary}`,
|
|
9
|
+
REGEX_PARTS.flags
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default class UKTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
13
|
+
patternLeftBoundary(): string {
|
|
14
|
+
return REGEX_PARTS.leftBoundary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
innerPattern(): RegExp {
|
|
18
|
+
return PATTERN;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
22
|
+
const prefix = match[1].toLowerCase();
|
|
23
|
+
let timeUnits = parseTimeUnits(match[3]);
|
|
24
|
+
switch (prefix) {
|
|
25
|
+
case "останні":
|
|
26
|
+
case "минулі":
|
|
27
|
+
case "-":
|
|
28
|
+
timeUnits = reverseTimeUnits(timeUnits);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseTimeUnits, REGEX_PARTS } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
|
|
6
|
+
const PATTERN = `(?:(?:приблизно|орієнтовно)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})${REGEX_PARTS.rightBoundary}`;
|
|
7
|
+
const PATTERN_WITH_PREFIX = new RegExp(
|
|
8
|
+
`(?:протягом|на протязі|протягом|упродовж|впродовж)\\s*${PATTERN}`,
|
|
9
|
+
REGEX_PARTS.flags
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const PATTERN_WITHOUT_PREFIX = new RegExp(PATTERN, "i");
|
|
13
|
+
|
|
14
|
+
export default class UKTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
15
|
+
patternLeftBoundary(): string {
|
|
16
|
+
return REGEX_PARTS.leftBoundary;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
innerPattern(context: ParsingContext): RegExp {
|
|
20
|
+
return context.option.forwardDate ? PATTERN_WITHOUT_PREFIX : PATTERN_WITH_PREFIX;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
24
|
+
const timeUnits = parseTimeUnits(match[1]);
|
|
25
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
// TODO: ADD REGEX_PARTS below
|
|
4
|
+
import { REGEX_PARTS, WEEKDAY_DICTIONARY } from "../constants";
|
|
5
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
6
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
7
|
+
import { createParsingComponentsAtWeekday } from "../../../common/calculation/weekdays";
|
|
8
|
+
|
|
9
|
+
const PATTERN = new RegExp(
|
|
10
|
+
`(?:(?:,|\\(|()\\s*)?` +
|
|
11
|
+
`(?:в\\s*?)?` +
|
|
12
|
+
`(?:у\\s*?)?` +
|
|
13
|
+
`(?:(цей|минулого|минулий|попередній|попереднього|наступного|наступний|наступному)\\s*)?` +
|
|
14
|
+
`(${matchAnyPattern(WEEKDAY_DICTIONARY)})` +
|
|
15
|
+
`(?:\\s*(?:,|\\)|)))?` +
|
|
16
|
+
`(?:\\s*(на|у|в)\\s*(цьому|минулому|наступному)\\s*тижні)?` +
|
|
17
|
+
`${REGEX_PARTS.rightBoundary}`,
|
|
18
|
+
REGEX_PARTS.flags
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const PREFIX_GROUP = 1;
|
|
22
|
+
const WEEKDAY_GROUP = 2;
|
|
23
|
+
const POSTFIX_GROUP = 3;
|
|
24
|
+
|
|
25
|
+
export default class UKWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
26
|
+
innerPattern(): RegExp {
|
|
27
|
+
return PATTERN;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
patternLeftBoundary(): string {
|
|
31
|
+
return REGEX_PARTS.leftBoundary;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
35
|
+
const dayOfWeek = match[WEEKDAY_GROUP].toLocaleLowerCase();
|
|
36
|
+
const weekday = WEEKDAY_DICTIONARY[dayOfWeek];
|
|
37
|
+
const prefix = match[PREFIX_GROUP];
|
|
38
|
+
const postfix = match[POSTFIX_GROUP];
|
|
39
|
+
let modifierWord = prefix || postfix;
|
|
40
|
+
modifierWord = modifierWord || "";
|
|
41
|
+
modifierWord = modifierWord.toLocaleLowerCase();
|
|
42
|
+
|
|
43
|
+
let modifier = null;
|
|
44
|
+
if (
|
|
45
|
+
modifierWord == "минулого" ||
|
|
46
|
+
modifierWord == "минулий" ||
|
|
47
|
+
modifierWord == "попередній" ||
|
|
48
|
+
modifierWord == "попереднього"
|
|
49
|
+
) {
|
|
50
|
+
modifier = "last";
|
|
51
|
+
} else if (modifierWord == "наступного" || modifierWord == "наступний") {
|
|
52
|
+
modifier = "next";
|
|
53
|
+
} else if (modifierWord == "цей" || modifierWord == "цього" || modifierWord == "цьому") {
|
|
54
|
+
modifier = "this";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return createParsingComponentsAtWeekday(context.reference, weekday, modifier);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import AbstractMergeDateRangeRefiner from "../../../common/refiners/AbstractMergeDateRangeRefiner";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merging before and after results (see. AbstractMergeDateRangeRefiner)
|
|
5
|
+
* This implementation should provide Russian connecting phases
|
|
6
|
+
* - [з|із] 06.09.1989 [до|по] 11.12.1996
|
|
7
|
+
* - [з|із] п'ятниці і до середи
|
|
8
|
+
*/
|
|
9
|
+
export default class UKMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner {
|
|
10
|
+
patternBetween(): RegExp {
|
|
11
|
+
return /^\s*(і до|і по|до|по|-)\s*$/i;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import AbstractMergeDateTimeRefiner from "../../../common/refiners/AbstractMergeDateTimeRefiner";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merging date-only result and time-only result (see. AbstractMergeDateTimeRefiner).
|
|
5
|
+
* This implementation should provide Ukrainian connecting phases
|
|
6
|
+
* - 2020-02-13 [в/у/о] 6:00
|
|
7
|
+
* - Завтра [,] 7:00
|
|
8
|
+
*/
|
|
9
|
+
export default class UKMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner {
|
|
10
|
+
patternBetween(): RegExp {
|
|
11
|
+
return new RegExp(`^\\s*(T|в|у|о|,|-)?\\s*$`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Chrono components for zh support
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { Chrono, Configuration } from "../../../chrono";
|
|
6
5
|
import ExtractTimezoneOffsetRefiner from "../../../common/refiners/ExtractTimezoneOffsetRefiner";
|
|
7
6
|
import { includeCommonConfiguration } from "../../../configurations";
|
|
8
|
-
import {
|
|
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";
|
|
9
10
|
import ZHHansCasualDateParser from "./parsers/ZHHansCasualDateParser";
|
|
10
11
|
import ZHHansDateParser from "./parsers/ZHHansDateParser";
|
|
11
12
|
import ZHHansDeadlineFormatParser from "./parsers/ZHHansDeadlineFormatParser";
|
|
@@ -15,6 +16,9 @@ import ZHHansWeekdayParser from "./parsers/ZHHansWeekdayParser";
|
|
|
15
16
|
import ZHHansMergeDateRangeRefiner from "./refiners/ZHHansMergeDateRangeRefiner";
|
|
16
17
|
import ZHHansMergeDateTimeRefiner from "./refiners/ZHHansMergeDateTimeRefiner";
|
|
17
18
|
|
|
19
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
20
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
21
|
+
|
|
18
22
|
// Shortcuts
|
|
19
23
|
export const hans = new Chrono(createCasualConfiguration());
|
|
20
24
|
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* TODO: Complete general zh support (current support only zh-Hant)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Chrono, Configuration } from "../../../chrono";
|
|
7
6
|
import ExtractTimezoneOffsetRefiner from "../../../common/refiners/ExtractTimezoneOffsetRefiner";
|
|
8
7
|
import { includeCommonConfiguration } from "../../../configurations";
|
|
9
|
-
import {
|
|
8
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../../chrono";
|
|
9
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../../types";
|
|
10
11
|
import ZHHantCasualDateParser from "./parsers/ZHHantCasualDateParser";
|
|
11
12
|
import ZHHantDateParser from "./parsers/ZHHantDateParser";
|
|
12
13
|
import ZHHantDeadlineFormatParser from "./parsers/ZHHantDeadlineFormatParser";
|
|
@@ -16,6 +17,9 @@ import ZHHantWeekdayParser from "./parsers/ZHHantWeekdayParser";
|
|
|
16
17
|
import ZHHantMergeDateRangeRefiner from "./refiners/ZHHantMergeDateRangeRefiner";
|
|
17
18
|
import ZHHantMergeDateTimeRefiner from "./refiners/ZHHantMergeDateTimeRefiner";
|
|
18
19
|
|
|
20
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
21
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
22
|
+
|
|
19
23
|
// Shortcuts
|
|
20
24
|
export const hant = new Chrono(createCasualConfiguration());
|
|
21
25
|
|
package/src/results.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, ParsedComponents, ParsedResult, ParsingReference } from "./
|
|
1
|
+
import { Component, ParsedComponents, ParsedResult, ParsingReference } from "./types";
|
|
2
2
|
|
|
3
3
|
import quarterOfYear from "dayjs/plugin/quarterOfYear";
|
|
4
4
|
import dayjs, { QUnitType } from "dayjs";
|
package/src/timezone.ts
CHANGED