chrono-node 2.6.3 → 2.6.4
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 +7 -62
- package/dist/cjs/index.js +8 -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 +7 -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 +58 -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 +12 -51
- package/dist/cjs/locales/en/index.js.map +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 +7 -1
- package/dist/cjs/locales/es/index.js.map +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 +7 -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 +7 -1
- package/dist/cjs/locales/ja/index.js.map +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/nl/index.d.ts +5 -2
- package/dist/cjs/locales/nl/index.js +7 -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.js +5 -5
- package/dist/cjs/locales/nl/parsers/NLMonthNameMiddleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/pt/index.d.ts +5 -2
- package/dist/cjs/locales/pt/index.js +7 -1
- package/dist/cjs/locales/pt/index.js.map +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 +7 -1
- package/dist/cjs/locales/ru/index.js.map +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 +64 -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 +8 -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 +8 -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 +7 -62
- 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 +52 -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/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.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.js +25 -3
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js.map +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.js +1 -1
- package/dist/esm/locales/nl/parsers/NLMonthNameMiddleEndianParser.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.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/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 +1 -1
- package/src/index.ts +6 -151
- 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 +70 -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_timezone_exp.test.ts +1 -1
- 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
package/src/index.ts
CHANGED
|
@@ -1,158 +1,11 @@
|
|
|
1
1
|
import { DebugHandler, DebugConsume } from "./debugging";
|
|
2
2
|
import * as en from "./locales/en";
|
|
3
3
|
import { Chrono, Parser, Refiner } from "./chrono";
|
|
4
|
-
import
|
|
4
|
+
import { ParsingResult } from "./results";
|
|
5
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "./types";
|
|
5
6
|
|
|
6
7
|
export { en, Chrono, Parser, Refiner, ParsingResult };
|
|
7
|
-
|
|
8
|
-
export interface ParsingOption {
|
|
9
|
-
/**
|
|
10
|
-
* To parse only forward dates (the results should be after the reference date).
|
|
11
|
-
* This effects date/time implication (e.g. weekday or time mentioning)
|
|
12
|
-
*/
|
|
13
|
-
forwardDate?: boolean;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Additional timezone keywords for the parsers to recognize.
|
|
17
|
-
* Any value provided will override the default handling of that value.
|
|
18
|
-
*/
|
|
19
|
-
timezones?: TimezoneAbbrMap;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Internal debug event handler.
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
debug?: DebugHandler | DebugConsume;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Some timezone abbreviations are ambiguous in that they refer to different offsets
|
|
30
|
-
* depending on the time of year — daylight savings time (DST), or non-DST. This interface
|
|
31
|
-
* allows defining such timezones
|
|
32
|
-
*/
|
|
33
|
-
export interface AmbiguousTimezoneMap {
|
|
34
|
-
timezoneOffsetDuringDst: number;
|
|
35
|
-
timezoneOffsetNonDst: number;
|
|
36
|
-
/**
|
|
37
|
-
* Return the start date of DST for the given year.
|
|
38
|
-
* timezone.ts contains helper methods for common such rules.
|
|
39
|
-
*/
|
|
40
|
-
dstStart: (year: number) => Date;
|
|
41
|
-
/**
|
|
42
|
-
* Return the end date of DST for the given year.
|
|
43
|
-
* timezone.ts contains helper methods for common such rules.
|
|
44
|
-
*/
|
|
45
|
-
dstEnd: (year: number) => Date;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A map describing how timezone abbreviations should map to time offsets.
|
|
50
|
-
* Supports both unambigous mappings abbreviation => offset,
|
|
51
|
-
* and ambiguous mappings, where the offset will depend on whether the
|
|
52
|
-
* time in question is during daylight savings time or not.
|
|
53
|
-
*/
|
|
54
|
-
export type TimezoneAbbrMap = { [key: string]: number | AmbiguousTimezoneMap };
|
|
55
|
-
|
|
56
|
-
export interface ParsingReference {
|
|
57
|
-
/**
|
|
58
|
-
* Reference date. The instant (JavaScript Date object) when the input is written or mention.
|
|
59
|
-
* This effect date/time implication (e.g. weekday or time mentioning).
|
|
60
|
-
* (default = now)
|
|
61
|
-
*/
|
|
62
|
-
instant?: Date;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Reference timezone. The timezone where the input is written or mention.
|
|
66
|
-
* Date/time implication will account the difference between input timezone and the current system timezone.
|
|
67
|
-
* (default = current timezone)
|
|
68
|
-
*/
|
|
69
|
-
timezone?: string | number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Parsed result or final output.
|
|
74
|
-
* Each result object represents a date/time (or date/time-range) mentioning in the input.
|
|
75
|
-
*/
|
|
76
|
-
export interface ParsedResult {
|
|
77
|
-
readonly refDate: Date;
|
|
78
|
-
readonly index: number;
|
|
79
|
-
readonly text: string;
|
|
80
|
-
|
|
81
|
-
readonly start: ParsedComponents;
|
|
82
|
-
readonly end?: ParsedComponents;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Create a javascript date object (from the result.start).
|
|
86
|
-
*/
|
|
87
|
-
date(): Date;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* A collection of parsed date/time components (e.g. day, hour, minute, ..., etc).
|
|
92
|
-
*
|
|
93
|
-
* Each parsed component has three different levels of certainty.
|
|
94
|
-
* - *Certain* (or *Known*): The component is directly mentioned and parsed.
|
|
95
|
-
* - *Implied*: The component is not directly mentioned, but implied by other parsed information.
|
|
96
|
-
* - *Unknown*: Completely no mention of the component.
|
|
97
|
-
*/
|
|
98
|
-
export interface ParsedComponents {
|
|
99
|
-
/**
|
|
100
|
-
* Check the component certainly if the component is *Certain* (or *Known*)
|
|
101
|
-
*/
|
|
102
|
-
isCertain(component: Component): boolean;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get the component value for either *Certain* or *Implied* value.
|
|
106
|
-
*/
|
|
107
|
-
get(component: Component): number | null;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @return a javascript date object.
|
|
111
|
-
*/
|
|
112
|
-
date(): Date;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type Component =
|
|
116
|
-
| "year"
|
|
117
|
-
| "month"
|
|
118
|
-
| "day"
|
|
119
|
-
| "weekday"
|
|
120
|
-
| "hour"
|
|
121
|
-
| "minute"
|
|
122
|
-
| "second"
|
|
123
|
-
| "millisecond"
|
|
124
|
-
| "meridiem"
|
|
125
|
-
| "timezoneOffset";
|
|
126
|
-
|
|
127
|
-
export enum Meridiem {
|
|
128
|
-
AM = 0,
|
|
129
|
-
PM = 1,
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export enum Weekday {
|
|
133
|
-
SUNDAY = 0,
|
|
134
|
-
MONDAY = 1,
|
|
135
|
-
TUESDAY = 2,
|
|
136
|
-
WEDNESDAY = 3,
|
|
137
|
-
THURSDAY = 4,
|
|
138
|
-
FRIDAY = 5,
|
|
139
|
-
SATURDAY = 6,
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export enum Month {
|
|
143
|
-
JANUARY = 1,
|
|
144
|
-
FEBRUARY = 2,
|
|
145
|
-
MARCH = 3,
|
|
146
|
-
APRIL = 4,
|
|
147
|
-
MAY = 5,
|
|
148
|
-
JUNE = 6,
|
|
149
|
-
JULY = 7,
|
|
150
|
-
AUGUST = 8,
|
|
151
|
-
SEPTEMBER = 9,
|
|
152
|
-
OCTOBER = 10,
|
|
153
|
-
NOVEMBER = 11,
|
|
154
|
-
DECEMBER = 12,
|
|
155
|
-
}
|
|
8
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
156
9
|
|
|
157
10
|
// Export all locales
|
|
158
11
|
import * as de from "./locales/de";
|
|
@@ -163,7 +16,9 @@ import * as nl from "./locales/nl";
|
|
|
163
16
|
import * as zh from "./locales/zh";
|
|
164
17
|
import * as ru from "./locales/ru";
|
|
165
18
|
import * as es from "./locales/es";
|
|
166
|
-
|
|
19
|
+
import * as uk from "./locales/uk";
|
|
20
|
+
|
|
21
|
+
export { de, fr, ja, pt, nl, zh, ru, es, uk };
|
|
167
22
|
|
|
168
23
|
/**
|
|
169
24
|
* A shortcut for {@link en | chrono.en.strict}
|
package/src/locales/de/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { includeCommonConfiguration } from "../../configurations";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
3
|
+
import { ParsingResult } from "../../results";
|
|
4
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
4
5
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
5
6
|
import ISOFormatParser from "../../common/parsers/ISOFormatParser";
|
|
6
7
|
import DETimeExpressionParser from "./parsers/DETimeExpressionParser";
|
|
@@ -14,6 +15,9 @@ import DEMonthNameLittleEndianParser from "./parsers/DEMonthNameLittleEndianPars
|
|
|
14
15
|
import DETimeUnitRelativeFormatParser from "./parsers/DETimeUnitRelativeFormatParser";
|
|
15
16
|
import DETimeUnitWithinFormatParser from "./parsers/DETimeUnitWithinFormatParser";
|
|
16
17
|
|
|
18
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
19
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
20
|
+
|
|
17
21
|
// Shortcuts
|
|
18
22
|
export const casual = new Chrono(createCasualConfiguration());
|
|
19
23
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
|
-
import { Meridiem } from "../../../
|
|
4
|
+
import { Meridiem } from "../../../types";
|
|
5
5
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
6
|
import { implySimilarTime } from "../../../utils/dayjs";
|
|
7
7
|
import { addImpliedTimeUnits } from "../../../utils/timeunits";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Configuration } from "../../chrono";
|
|
2
|
+
|
|
3
|
+
import ENTimeUnitWithinFormatParser from "./parsers/ENTimeUnitWithinFormatParser";
|
|
4
|
+
import ENMonthNameLittleEndianParser from "./parsers/ENMonthNameLittleEndianParser";
|
|
5
|
+
import ENMonthNameMiddleEndianParser from "./parsers/ENMonthNameMiddleEndianParser";
|
|
6
|
+
import ENMonthNameParser from "./parsers/ENMonthNameParser";
|
|
7
|
+
import ENCasualYearMonthDayParser from "./parsers/ENCasualYearMonthDayParser";
|
|
8
|
+
import ENSlashMonthFormatParser from "./parsers/ENSlashMonthFormatParser";
|
|
9
|
+
import ENTimeExpressionParser from "./parsers/ENTimeExpressionParser";
|
|
10
|
+
import ENTimeUnitAgoFormatParser from "./parsers/ENTimeUnitAgoFormatParser";
|
|
11
|
+
import ENTimeUnitLaterFormatParser from "./parsers/ENTimeUnitLaterFormatParser";
|
|
12
|
+
import ENMergeDateRangeRefiner from "./refiners/ENMergeDateRangeRefiner";
|
|
13
|
+
import ENMergeDateTimeRefiner from "./refiners/ENMergeDateTimeRefiner";
|
|
14
|
+
|
|
15
|
+
import { includeCommonConfiguration } from "../../configurations";
|
|
16
|
+
import ENCasualDateParser from "./parsers/ENCasualDateParser";
|
|
17
|
+
import ENCasualTimeParser from "./parsers/ENCasualTimeParser";
|
|
18
|
+
import ENWeekdayParser from "./parsers/ENWeekdayParser";
|
|
19
|
+
import ENRelativeDateFormatParser from "./parsers/ENRelativeDateFormatParser";
|
|
20
|
+
|
|
21
|
+
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
22
|
+
import ENTimeUnitCasualRelativeFormatParser from "./parsers/ENTimeUnitCasualRelativeFormatParser";
|
|
23
|
+
import ENMergeRelativeDateRefiner from "./refiners/ENMergeRelativeDateRefiner";
|
|
24
|
+
|
|
25
|
+
export default class ENDefaultConfiguration {
|
|
26
|
+
/**
|
|
27
|
+
* Create a default *casual* {@Link Configuration} for English chrono.
|
|
28
|
+
* It calls {@Link createConfiguration} and includes additional parsers.
|
|
29
|
+
*/
|
|
30
|
+
createCasualConfiguration(littleEndian = false): Configuration {
|
|
31
|
+
const option = this.createConfiguration(false, littleEndian);
|
|
32
|
+
option.parsers.unshift(new ENCasualDateParser());
|
|
33
|
+
option.parsers.unshift(new ENCasualTimeParser());
|
|
34
|
+
option.parsers.unshift(new ENMonthNameParser());
|
|
35
|
+
option.parsers.unshift(new ENRelativeDateFormatParser());
|
|
36
|
+
option.parsers.unshift(new ENTimeUnitCasualRelativeFormatParser());
|
|
37
|
+
return option;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a default {@Link Configuration} for English chrono
|
|
42
|
+
*
|
|
43
|
+
* @param strictMode If the timeunit mentioning should be strict, not casual
|
|
44
|
+
* @param littleEndian If format should be date-first/littleEndian (e.g. en_UK), not month-first/middleEndian (e.g. en_US)
|
|
45
|
+
*/
|
|
46
|
+
createConfiguration(strictMode = true, littleEndian = false): Configuration {
|
|
47
|
+
return includeCommonConfiguration(
|
|
48
|
+
{
|
|
49
|
+
parsers: [
|
|
50
|
+
new SlashDateFormatParser(littleEndian),
|
|
51
|
+
new ENTimeUnitWithinFormatParser(strictMode),
|
|
52
|
+
new ENMonthNameLittleEndianParser(),
|
|
53
|
+
new ENMonthNameMiddleEndianParser(),
|
|
54
|
+
new ENWeekdayParser(),
|
|
55
|
+
new ENCasualYearMonthDayParser(),
|
|
56
|
+
new ENSlashMonthFormatParser(),
|
|
57
|
+
new ENTimeExpressionParser(strictMode),
|
|
58
|
+
new ENTimeUnitAgoFormatParser(strictMode),
|
|
59
|
+
new ENTimeUnitLaterFormatParser(strictMode),
|
|
60
|
+
],
|
|
61
|
+
refiners: [
|
|
62
|
+
new ENMergeRelativeDateRefiner(),
|
|
63
|
+
new ENMergeDateTimeRefiner(),
|
|
64
|
+
new ENMergeDateRangeRefiner(),
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
strictMode
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -2,7 +2,7 @@ import { OpUnitType, QUnitType } from "dayjs";
|
|
|
2
2
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
3
3
|
import { findMostLikelyADYear } from "../../calculation/years";
|
|
4
4
|
import { TimeUnits } from "../../utils/timeunits";
|
|
5
|
-
import { Weekday } from "../../
|
|
5
|
+
import { Weekday } from "../../types";
|
|
6
6
|
|
|
7
7
|
export const WEEKDAY_DICTIONARY: { [word: string]: Weekday } = {
|
|
8
8
|
sunday: 0,
|
package/src/locales/en/index.ts
CHANGED
|
@@ -4,44 +4,31 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import ENMonthNameParser from "./parsers/ENMonthNameParser";
|
|
11
|
-
import ENCasualYearMonthDayParser from "./parsers/ENCasualYearMonthDayParser";
|
|
12
|
-
import ENSlashMonthFormatParser from "./parsers/ENSlashMonthFormatParser";
|
|
13
|
-
import ENTimeExpressionParser from "./parsers/ENTimeExpressionParser";
|
|
14
|
-
import ENTimeUnitAgoFormatParser from "./parsers/ENTimeUnitAgoFormatParser";
|
|
15
|
-
import ENTimeUnitLaterFormatParser from "./parsers/ENTimeUnitLaterFormatParser";
|
|
16
|
-
import ENMergeDateRangeRefiner from "./refiners/ENMergeDateRangeRefiner";
|
|
17
|
-
import ENMergeDateTimeRefiner from "./refiners/ENMergeDateTimeRefiner";
|
|
7
|
+
import { Chrono, Parser, Refiner } from "../../chrono";
|
|
8
|
+
import { ParsingResult } from "../../results";
|
|
9
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
18
10
|
|
|
19
|
-
import
|
|
20
|
-
import ENCasualDateParser from "./parsers/ENCasualDateParser";
|
|
21
|
-
import ENCasualTimeParser from "./parsers/ENCasualTimeParser";
|
|
22
|
-
import ENWeekdayParser from "./parsers/ENWeekdayParser";
|
|
23
|
-
import ENRelativeDateFormatParser from "./parsers/ENRelativeDateFormatParser";
|
|
11
|
+
import ENDefaultConfiguration from "./configuration";
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import ENMergeRelativeDateRefiner from "./refiners/ENMergeRelativeDateRefiner";
|
|
13
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
14
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
15
|
+
|
|
16
|
+
const enConfig = new ENDefaultConfiguration();
|
|
30
17
|
|
|
31
18
|
/**
|
|
32
19
|
* Chrono object configured for parsing *casual* English
|
|
33
20
|
*/
|
|
34
|
-
export const casual = new Chrono(createCasualConfiguration(false));
|
|
21
|
+
export const casual = new Chrono(enConfig.createCasualConfiguration(false));
|
|
35
22
|
|
|
36
23
|
/**
|
|
37
24
|
* Chrono object configured for parsing *strict* English
|
|
38
25
|
*/
|
|
39
|
-
export const strict = new Chrono(createConfiguration(true, false));
|
|
26
|
+
export const strict = new Chrono(enConfig.createConfiguration(true, false));
|
|
40
27
|
|
|
41
28
|
/**
|
|
42
29
|
* Chrono object configured for parsing *UK-style* English
|
|
43
30
|
*/
|
|
44
|
-
export const GB = new Chrono(createConfiguration(false, true));
|
|
31
|
+
export const GB = new Chrono(enConfig.createConfiguration(false, true));
|
|
45
32
|
|
|
46
33
|
/**
|
|
47
34
|
* A shortcut for en.casual.parse()
|
|
@@ -56,44 +43,3 @@ export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedR
|
|
|
56
43
|
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
|
|
57
44
|
return casual.parseDate(text, ref, option);
|
|
58
45
|
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Create a default *casual* {@Link Configuration} for English chrono.
|
|
62
|
-
* It calls {@Link createConfiguration} and includes additional parsers.
|
|
63
|
-
*/
|
|
64
|
-
export function createCasualConfiguration(littleEndian = false): Configuration {
|
|
65
|
-
const option = createConfiguration(false, littleEndian);
|
|
66
|
-
option.parsers.unshift(new ENCasualDateParser());
|
|
67
|
-
option.parsers.unshift(new ENCasualTimeParser());
|
|
68
|
-
option.parsers.unshift(new ENMonthNameParser());
|
|
69
|
-
option.parsers.unshift(new ENRelativeDateFormatParser());
|
|
70
|
-
option.parsers.unshift(new ENTimeUnitCasualRelativeFormatParser());
|
|
71
|
-
return option;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create a default {@Link Configuration} for English chrono
|
|
76
|
-
*
|
|
77
|
-
* @param strictMode If the timeunit mentioning should be strict, not casual
|
|
78
|
-
* @param littleEndian If format should be date-first/littleEndian (e.g. en_UK), not month-first/middleEndian (e.g. en_US)
|
|
79
|
-
*/
|
|
80
|
-
export function createConfiguration(strictMode = true, littleEndian = false): Configuration {
|
|
81
|
-
return includeCommonConfiguration(
|
|
82
|
-
{
|
|
83
|
-
parsers: [
|
|
84
|
-
new SlashDateFormatParser(littleEndian),
|
|
85
|
-
new ENTimeUnitWithinFormatParser(strictMode),
|
|
86
|
-
new ENMonthNameLittleEndianParser(),
|
|
87
|
-
new ENMonthNameMiddleEndianParser(),
|
|
88
|
-
new ENWeekdayParser(),
|
|
89
|
-
new ENCasualYearMonthDayParser(),
|
|
90
|
-
new ENSlashMonthFormatParser(),
|
|
91
|
-
new ENTimeExpressionParser(strictMode),
|
|
92
|
-
new ENTimeUnitAgoFormatParser(strictMode),
|
|
93
|
-
new ENTimeUnitLaterFormatParser(strictMode),
|
|
94
|
-
],
|
|
95
|
-
refiners: [new ENMergeRelativeDateRefiner(), new ENMergeDateTimeRefiner(), new ENMergeDateRangeRefiner()],
|
|
96
|
-
},
|
|
97
|
-
strictMode
|
|
98
|
-
);
|
|
99
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents } from "../../../results";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
5
5
|
|
|
6
6
|
export default class ENTimeExpressionParser extends AbstractTimeExpressionParser {
|
package/src/locales/es/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { includeCommonConfiguration } from "../../configurations";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
9
|
+
import { ParsingResult } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
11
12
|
import ESWeekdayParser from "./parsers/ESWeekdayParser";
|
|
12
13
|
import ESTimeExpressionParser from "./parsers/ESTimeExpressionParser";
|
|
@@ -17,6 +18,9 @@ import ESCasualDateParser from "./parsers/ESCasualDateParser";
|
|
|
17
18
|
import ESCasualTimeParser from "./parsers/ESCasualTimeParser";
|
|
18
19
|
import ESTimeUnitWithinFormatParser from "./parsers/ESTimeUnitWithinFormatParser";
|
|
19
20
|
|
|
21
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
22
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
23
|
+
|
|
20
24
|
// Shortcuts
|
|
21
25
|
export const casual = new Chrono(createCasualConfiguration());
|
|
22
26
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { Meridiem } from "../../../
|
|
2
|
+
import { Meridiem } from "../../../types";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
4
|
import { assignTheNextDay } from "../../../utils/dayjs";
|
|
5
5
|
import dayjs from "dayjs";
|
package/src/locales/fr/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { includeCommonConfiguration } from "../../configurations";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
9
|
+
import { ParsingResult } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import FRCasualDateParser from "./parsers/FRCasualDateParser";
|
|
11
12
|
import FRCasualTimeParser from "./parsers/FRCasualTimeParser";
|
|
12
13
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
@@ -20,6 +21,9 @@ import FRTimeUnitAgoFormatParser from "./parsers/FRTimeUnitAgoFormatParser";
|
|
|
20
21
|
import FRTimeUnitWithinFormatParser from "./parsers/FRTimeUnitWithinFormatParser";
|
|
21
22
|
import FRTimeUnitRelativeFormatParser from "./parsers/FRTimeUnitRelativeFormatParser";
|
|
22
23
|
|
|
24
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
25
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
26
|
+
|
|
23
27
|
// Shortcuts
|
|
24
28
|
export const casual = new Chrono(createCasualConfiguration());
|
|
25
29
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
|
-
import { Meridiem } from "../../../
|
|
4
|
+
import { Meridiem } from "../../../types";
|
|
5
5
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
6
|
import { assignSimilarDate } from "../../../utils/dayjs";
|
|
7
7
|
import * as references from "../../../common/casualReferences";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
6
6
|
export default class FRCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
package/src/locales/ja/index.ts
CHANGED
|
@@ -8,8 +8,12 @@ import JPStandardParser from "./parsers/JPStandardParser";
|
|
|
8
8
|
import JPMergeDateRangeRefiner from "./refiners/JPMergeDateRangeRefiner";
|
|
9
9
|
import JPCasualDateParser from "./parsers/JPCasualDateParser";
|
|
10
10
|
|
|
11
|
-
import { Chrono, Configuration } from "../../chrono";
|
|
12
|
-
import {
|
|
11
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
12
|
+
import { ParsingResult } from "../../results";
|
|
13
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
14
|
+
|
|
15
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
16
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
13
17
|
|
|
14
18
|
// Shortcuts
|
|
15
19
|
export const casual = new Chrono(createCasualConfiguration());
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { Parser, ParsingContext } from "../../../chrono";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import * as references from "../../../common/casualReferences";
|
|
5
5
|
|
|
6
|
-
const PATTERN =
|
|
6
|
+
const PATTERN = /今日|きょう|当日|とうじつ|昨日|きのう|明日|あした|今夜|こんや|今夕|こんゆう|今晩|こんばん|今朝|けさ/i;
|
|
7
|
+
|
|
8
|
+
function normalizeTextToKanji(text: string) {
|
|
9
|
+
switch (text) {
|
|
10
|
+
case "きょう":
|
|
11
|
+
return "今日";
|
|
12
|
+
case "とうじつ":
|
|
13
|
+
return "当日";
|
|
14
|
+
case "きのう":
|
|
15
|
+
return "昨日";
|
|
16
|
+
case "あした":
|
|
17
|
+
return "明日";
|
|
18
|
+
case "こんや":
|
|
19
|
+
return "今夜";
|
|
20
|
+
case "こんゆう":
|
|
21
|
+
return "今夕";
|
|
22
|
+
case "こんばん":
|
|
23
|
+
return "今晩";
|
|
24
|
+
case "けさ":
|
|
25
|
+
return "今朝";
|
|
26
|
+
default:
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
7
30
|
|
|
8
31
|
export default class JPCasualDateParser implements Parser {
|
|
9
32
|
pattern() {
|
|
@@ -11,7 +34,7 @@ export default class JPCasualDateParser implements Parser {
|
|
|
11
34
|
}
|
|
12
35
|
|
|
13
36
|
extract(context: ParsingContext, match: RegExpMatchArray) {
|
|
14
|
-
const text = match[0];
|
|
37
|
+
const text = normalizeTextToKanji(match[0]);
|
|
15
38
|
|
|
16
39
|
const date = dayjs(context.refDate);
|
|
17
40
|
const components = context.createParsingComponents();
|
package/src/locales/nl/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { includeCommonConfiguration } from "../../configurations";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
9
|
+
import { ParsingResult } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import NLMergeDateRangeRefiner from "./refiners/NLMergeDateRangeRefiner";
|
|
11
12
|
import NLMergeDateTimeRefiner from "./refiners/NLMergeDateTimeRefiner";
|
|
12
13
|
import NLCasualDateParser from "./parsers/NLCasualDateParser";
|
|
@@ -25,6 +26,9 @@ import NLRelativeDateFormatParser from "./parsers/NLRelativeDateFormatParser";
|
|
|
25
26
|
import NLTimeUnitAgoFormatParser from "./parsers/NLTimeUnitAgoFormatParser";
|
|
26
27
|
import NLTimeUnitLaterFormatParser from "./parsers/NLTimeUnitLaterFormatParser";
|
|
27
28
|
|
|
29
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
30
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
31
|
+
|
|
28
32
|
// Shortcuts
|
|
29
33
|
export const casual = new Chrono(createCasualConfiguration());
|
|
30
34
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
-
import { Meridiem } from "../../../
|
|
4
|
+
import { Meridiem } from "../../../types";
|
|
5
5
|
import { assignSimilarDate, assignTheNextDay } from "../../../utils/dayjs";
|
|
6
6
|
import dayjs from "dayjs";
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { Meridiem } from "../../../
|
|
2
|
+
import { Meridiem } from "../../../types";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
4
|
import dayjs from "dayjs";
|
|
5
5
|
import { assignTheNextDay } from "../../../utils/dayjs";
|
package/src/locales/pt/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { includeCommonConfiguration } from "../../configurations";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
9
|
+
import { ParsingResult } from "../../results";
|
|
10
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
10
11
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
11
12
|
import PTWeekdayParser from "./parsers/PTWeekdayParser";
|
|
12
13
|
import PTTimeExpressionParser from "./parsers/PTTimeExpressionParser";
|
|
@@ -16,6 +17,9 @@ import PTMonthNameLittleEndianParser from "./parsers/PTMonthNameLittleEndianPars
|
|
|
16
17
|
import PTCasualDateParser from "./parsers/PTCasualDateParser";
|
|
17
18
|
import PTCasualTimeParser from "./parsers/PTCasualTimeParser";
|
|
18
19
|
|
|
20
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
21
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
22
|
+
|
|
19
23
|
// Shortcuts
|
|
20
24
|
export const casual = new Chrono(createCasualConfiguration());
|
|
21
25
|
export const strict = new Chrono(createConfiguration(true));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { Meridiem } from "../../../
|
|
2
|
+
import { Meridiem } from "../../../types";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
4
|
import { assignTheNextDay } from "../../../utils/dayjs";
|
|
5
5
|
import dayjs from "dayjs";
|
package/src/locales/ru/index.ts
CHANGED
|
@@ -18,11 +18,15 @@ import RUCasualTimeParser from "./parsers/RUCasualTimeParser";
|
|
|
18
18
|
import RUWeekdayParser from "./parsers/RUWeekdayParser";
|
|
19
19
|
import RURelativeDateFormatParser from "./parsers/RURelativeDateFormatParser";
|
|
20
20
|
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { Chrono, Configuration, Parser, Refiner } from "../../chrono";
|
|
22
|
+
import { ParsingResult } from "../../results";
|
|
23
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
23
24
|
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
24
25
|
import RUTimeUnitCasualRelativeFormatParser from "./parsers/RUTimeUnitCasualRelativeFormatParser";
|
|
25
26
|
|
|
27
|
+
export { Chrono, Parser, Refiner, ParsingResult };
|
|
28
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* Chrono object configured for parsing *casual* Russian
|
|
28
32
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents } from "../../../results";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
5
5
|
import { REGEX_PARTS } from "../constants";
|
|
6
6
|
|