chrono-node 2.3.6 → 2.3.9
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 +3 -3
- package/dist/calculation/mergingCalculation.js +1 -0
- package/dist/calculation/mergingCalculation.js.map +1 -0
- package/dist/calculation/weeks.js +1 -0
- package/dist/calculation/weeks.js.map +1 -0
- package/dist/calculation/years.js +1 -0
- package/dist/calculation/years.js.map +1 -0
- package/dist/chrono.js +1 -0
- package/dist/chrono.js.map +1 -0
- package/dist/common/abstractRefiners.js +1 -0
- package/dist/common/abstractRefiners.js.map +1 -0
- package/dist/common/casualReferences.d.ts +8 -0
- package/dist/common/casualReferences.js +65 -9
- package/dist/common/casualReferences.js.map +1 -0
- package/dist/common/parsers/AbstractParserWithWordBoundary.d.ts +1 -0
- package/dist/common/parsers/AbstractParserWithWordBoundary.js +5 -1
- package/dist/common/parsers/AbstractParserWithWordBoundary.js.map +1 -0
- package/dist/common/parsers/AbstractTimeExpressionParser.d.ts +2 -0
- package/dist/common/parsers/AbstractTimeExpressionParser.js +40 -27
- package/dist/common/parsers/AbstractTimeExpressionParser.js.map +1 -0
- package/dist/common/parsers/ISOFormatParser.js +1 -0
- package/dist/common/parsers/ISOFormatParser.js.map +1 -0
- package/dist/common/parsers/SlashDateFormatParser.js +1 -0
- package/dist/common/parsers/SlashDateFormatParser.js.map +1 -0
- package/dist/common/refiners/AbstractMergeDateRangeRefiner.js +1 -0
- package/dist/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -0
- package/dist/common/refiners/AbstractMergeDateTimeRefiner.js +1 -0
- package/dist/common/refiners/AbstractMergeDateTimeRefiner.js.map +1 -0
- package/dist/common/refiners/ExtractTimezoneAbbrRefiner.js +2 -1
- package/dist/common/refiners/ExtractTimezoneAbbrRefiner.js.map +1 -0
- package/dist/common/refiners/ExtractTimezoneOffsetRefiner.js +5 -1
- package/dist/common/refiners/ExtractTimezoneOffsetRefiner.js.map +1 -0
- package/dist/common/refiners/ForwardDateRefiner.js +1 -0
- package/dist/common/refiners/ForwardDateRefiner.js.map +1 -0
- package/dist/common/refiners/MergeWeekdayComponentRefiner.js +1 -0
- package/dist/common/refiners/MergeWeekdayComponentRefiner.js.map +1 -0
- package/dist/common/refiners/OverlapRemovalRefiner.js +1 -0
- package/dist/common/refiners/OverlapRemovalRefiner.js.map +1 -0
- package/dist/common/refiners/UnlikelyFormatFilter.js +1 -0
- package/dist/common/refiners/UnlikelyFormatFilter.js.map +1 -0
- package/dist/configurations.js +1 -0
- package/dist/configurations.js.map +1 -0
- package/dist/debugging.js +1 -0
- package/dist/debugging.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -0
- package/dist/locales/de/constants.d.ts +3 -3
- package/dist/locales/de/constants.js +39 -20
- package/dist/locales/de/constants.js.map +1 -0
- package/dist/locales/de/index.js +5 -0
- package/dist/locales/de/index.js.map +1 -0
- package/dist/locales/de/parsers/DECasualDateParser.js +1 -0
- package/dist/locales/de/parsers/DECasualDateParser.js.map +1 -0
- package/dist/locales/de/parsers/DECasualTimeParser.js +1 -0
- package/dist/locales/de/parsers/DECasualTimeParser.js.map +1 -0
- package/dist/locales/de/parsers/DEMonthNameLittleEndianParser.js +1 -0
- package/dist/locales/de/parsers/DEMonthNameLittleEndianParser.js.map +1 -0
- package/dist/locales/de/parsers/DESpecificTimeExpressionParser.d.ts +7 -0
- package/dist/locales/de/parsers/DESpecificTimeExpressionParser.js +115 -0
- package/dist/locales/de/parsers/DESpecificTimeExpressionParser.js.map +1 -0
- package/dist/locales/de/parsers/DETimeExpressionParser.d.ts +0 -1
- package/dist/locales/de/parsers/DETimeExpressionParser.js +4 -21
- package/dist/locales/de/parsers/DETimeExpressionParser.js.map +1 -0
- package/dist/locales/de/parsers/DETimeUnitRelativeFormatParser.d.ts +8 -0
- package/dist/locales/de/parsers/DETimeUnitRelativeFormatParser.js +35 -0
- package/dist/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -0
- package/dist/locales/de/parsers/DEWeekdayParser.js +1 -0
- package/dist/locales/de/parsers/DEWeekdayParser.js.map +1 -0
- package/dist/locales/de/refiners/DEMergeDateRangeRefiner.js +1 -0
- package/dist/locales/de/refiners/DEMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/de/refiners/DEMergeDateTimeRefiner.js +1 -0
- package/dist/locales/de/refiners/DEMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/en/constants.d.ts +2 -2
- package/dist/locales/en/constants.js +4 -0
- package/dist/locales/en/constants.js.map +1 -0
- package/dist/locales/en/index.js +3 -1
- package/dist/locales/en/index.js.map +1 -0
- package/dist/locales/en/parsers/ENCasualDateParser.js +1 -0
- package/dist/locales/en/parsers/ENCasualDateParser.js.map +1 -0
- package/dist/locales/en/parsers/ENCasualTimeParser.js +1 -0
- package/dist/locales/en/parsers/ENCasualTimeParser.js.map +1 -0
- package/dist/locales/en/parsers/ENCasualYearMonthDayParser.js +1 -0
- package/dist/locales/en/parsers/ENCasualYearMonthDayParser.js.map +1 -0
- package/dist/locales/en/parsers/ENMonthNameLittleEndianParser.js +1 -0
- package/dist/locales/en/parsers/ENMonthNameLittleEndianParser.js.map +1 -0
- package/dist/locales/en/parsers/ENMonthNameMiddleEndianParser.js +1 -0
- package/dist/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -0
- package/dist/locales/en/parsers/ENMonthNameParser.js +1 -0
- package/dist/locales/en/parsers/ENMonthNameParser.js.map +1 -0
- package/dist/locales/en/parsers/ENRelativeDateFormatParser.js +3 -2
- package/dist/locales/en/parsers/ENRelativeDateFormatParser.js.map +1 -0
- package/dist/locales/en/parsers/ENSlashMonthFormatParser.js +1 -0
- package/dist/locales/en/parsers/ENSlashMonthFormatParser.js.map +1 -0
- package/dist/locales/en/parsers/ENTimeExpressionParser.js +1 -0
- package/dist/locales/en/parsers/ENTimeExpressionParser.js.map +1 -0
- package/dist/locales/en/parsers/ENTimeUnitAgoFormatParser.js +1 -0
- package/dist/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +2 -1
- package/dist/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/locales/en/parsers/ENTimeUnitLaterFormatParser.js +1 -0
- package/dist/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -0
- package/dist/locales/en/parsers/ENTimeUnitWithinFormatParser.js +1 -0
- package/dist/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/locales/en/parsers/ENWeekdayParser.js +1 -0
- package/dist/locales/en/parsers/ENWeekdayParser.js.map +1 -0
- package/dist/locales/en/refiners/ENMergeDateRangeRefiner.js +1 -0
- package/dist/locales/en/refiners/ENMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/en/refiners/ENMergeDateTimeRefiner.js +1 -0
- package/dist/locales/en/refiners/ENMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/en/refiners/ENMergeRelativeDateRefiner.d.ts +7 -0
- package/dist/locales/en/refiners/ENMergeRelativeDateRefiner.js +36 -0
- package/dist/locales/en/refiners/ENMergeRelativeDateRefiner.js.map +1 -0
- package/dist/locales/fr/constants.js +1 -0
- package/dist/locales/fr/constants.js.map +1 -0
- package/dist/locales/fr/index.js +1 -0
- package/dist/locales/fr/index.js.map +1 -0
- package/dist/locales/fr/parsers/FRCasualDateParser.js +1 -0
- package/dist/locales/fr/parsers/FRCasualDateParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRCasualTimeParser.js +1 -0
- package/dist/locales/fr/parsers/FRCasualTimeParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRMonthNameLittleEndianParser.js +1 -0
- package/dist/locales/fr/parsers/FRMonthNameLittleEndianParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRSpecificTimeExpressionParser.js +1 -0
- package/dist/locales/fr/parsers/FRSpecificTimeExpressionParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRTimeExpressionParser.js +1 -0
- package/dist/locales/fr/parsers/FRTimeExpressionParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRTimeUnitAgoFormatParser.js +1 -0
- package/dist/locales/fr/parsers/FRTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +1 -0
- package/dist/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRTimeUnitWithinFormatParser.js +2 -1
- package/dist/locales/fr/parsers/FRTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/locales/fr/parsers/FRWeekdayParser.js +1 -0
- package/dist/locales/fr/parsers/FRWeekdayParser.js.map +1 -0
- package/dist/locales/fr/refiners/FRMergeDateRangeRefiner.js +1 -0
- package/dist/locales/fr/refiners/FRMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/fr/refiners/FRMergeDateTimeRefiner.js +1 -0
- package/dist/locales/fr/refiners/FRMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/ja/constants.js +1 -0
- package/dist/locales/ja/constants.js.map +1 -0
- package/dist/locales/ja/index.js +1 -0
- package/dist/locales/ja/index.js.map +1 -0
- package/dist/locales/ja/parsers/JPCasualDateParser.js +1 -0
- package/dist/locales/ja/parsers/JPCasualDateParser.js.map +1 -0
- package/dist/locales/ja/parsers/JPStandardParser.js +1 -0
- package/dist/locales/ja/parsers/JPStandardParser.js.map +1 -0
- package/dist/locales/ja/refiners/JPMergeDateRangeRefiner.js +1 -0
- package/dist/locales/ja/refiners/JPMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/nl/constants.js +1 -0
- package/dist/locales/nl/constants.js.map +1 -0
- package/dist/locales/nl/index.js +1 -0
- package/dist/locales/nl/index.js.map +1 -0
- package/dist/locales/nl/parsers/NLCasualDateParser.js +1 -0
- package/dist/locales/nl/parsers/NLCasualDateParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLCasualDateTimeParser.js +1 -0
- package/dist/locales/nl/parsers/NLCasualDateTimeParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLCasualTimeParser.js +1 -0
- package/dist/locales/nl/parsers/NLCasualTimeParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLCasualYearMonthDayParser.js +1 -0
- package/dist/locales/nl/parsers/NLCasualYearMonthDayParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLMonthNameMiddleEndianParser.js +1 -0
- package/dist/locales/nl/parsers/NLMonthNameMiddleEndianParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLMonthNameParser.js +1 -0
- package/dist/locales/nl/parsers/NLMonthNameParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLRelativeDateFormatParser.js +1 -0
- package/dist/locales/nl/parsers/NLRelativeDateFormatParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLSlashMonthFormatParser.js +1 -0
- package/dist/locales/nl/parsers/NLSlashMonthFormatParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLTimeExpressionParser.js +1 -0
- package/dist/locales/nl/parsers/NLTimeExpressionParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitAgoFormatParser.js +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitLaterFormatParser.js +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitLaterFormatParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitWithinFormatParser.js +1 -0
- package/dist/locales/nl/parsers/NLTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/locales/nl/parsers/NLWeekdayParser.js +1 -0
- package/dist/locales/nl/parsers/NLWeekdayParser.js.map +1 -0
- package/dist/locales/nl/refiners/NLMergeDateRangeRefiner.js +1 -0
- package/dist/locales/nl/refiners/NLMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/nl/refiners/NLMergeDateTimeRefiner.js +1 -0
- package/dist/locales/nl/refiners/NLMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/pt/constants.js +1 -0
- package/dist/locales/pt/constants.js.map +1 -0
- package/dist/locales/pt/index.js +1 -0
- package/dist/locales/pt/index.js.map +1 -0
- package/dist/locales/pt/parsers/PTCasualDateParser.js +1 -0
- package/dist/locales/pt/parsers/PTCasualDateParser.js.map +1 -0
- package/dist/locales/pt/parsers/PTCasualTimeParser.js +1 -0
- package/dist/locales/pt/parsers/PTCasualTimeParser.js.map +1 -0
- package/dist/locales/pt/parsers/PTMonthNameLittleEndianParser.js +1 -0
- package/dist/locales/pt/parsers/PTMonthNameLittleEndianParser.js.map +1 -0
- package/dist/locales/pt/parsers/PTTimeExpressionParser.js +1 -0
- package/dist/locales/pt/parsers/PTTimeExpressionParser.js.map +1 -0
- package/dist/locales/pt/parsers/PTWeekdayParser.js +1 -0
- package/dist/locales/pt/parsers/PTWeekdayParser.js.map +1 -0
- package/dist/locales/pt/refiners/PTMergeDateRangeRefiner.js +1 -0
- package/dist/locales/pt/refiners/PTMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/pt/refiners/PTMergeDateTimeRefiner.js +1 -0
- package/dist/locales/pt/refiners/PTMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/ru/constants.d.ts +33 -0
- package/dist/locales/ru/constants.js +302 -0
- package/dist/locales/ru/constants.js.map +1 -0
- package/dist/locales/ru/index.d.ts +8 -0
- package/dist/locales/ru/index.js +56 -0
- package/dist/locales/ru/index.js.map +1 -0
- package/dist/locales/ru/parsers/RUCasualDateParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RUCasualDateParser.js +52 -0
- package/dist/locales/ru/parsers/RUCasualDateParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUCasualTimeParser.d.ts +7 -0
- package/dist/locales/ru/parsers/RUCasualTimeParser.js +74 -0
- package/dist/locales/ru/parsers/RUCasualTimeParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUMonthNameLittleEndianParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RUMonthNameLittleEndianParser.js +59 -0
- package/dist/locales/ru/parsers/RUMonthNameLittleEndianParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUMonthNameParser.d.ts +7 -0
- package/dist/locales/ru/parsers/RUMonthNameParser.js +45 -0
- package/dist/locales/ru/parsers/RUMonthNameParser.js.map +1 -0
- package/dist/locales/ru/parsers/RURelativeDateFormatParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RURelativeDateFormatParser.js +60 -0
- package/dist/locales/ru/parsers/RURelativeDateFormatParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUTimeExpressionParser.d.ts +12 -0
- package/dist/locales/ru/parsers/RUTimeExpressionParser.js +57 -0
- package/dist/locales/ru/parsers/RUTimeExpressionParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUTimeUnitAgoFormatParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RUTimeUnitAgoFormatParser.js +22 -0
- package/dist/locales/ru/parsers/RUTimeUnitAgoFormatParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js +29 -0
- package/dist/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUTimeUnitWithinFormatParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RUTimeUnitWithinFormatParser.js +22 -0
- package/dist/locales/ru/parsers/RUTimeUnitWithinFormatParser.js.map +1 -0
- package/dist/locales/ru/parsers/RUWeekdayParser.d.ts +8 -0
- package/dist/locales/ru/parsers/RUWeekdayParser.js +55 -0
- package/dist/locales/ru/parsers/RUWeekdayParser.js.map +1 -0
- package/dist/locales/ru/refiners/RUMergeDateRangeRefiner.d.ts +4 -0
- package/dist/locales/ru/refiners/RUMergeDateRangeRefiner.js +13 -0
- package/dist/locales/ru/refiners/RUMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/ru/refiners/RUMergeDateTimeRefiner.d.ts +4 -0
- package/dist/locales/ru/refiners/RUMergeDateTimeRefiner.js +13 -0
- package/dist/locales/ru/refiners/RUMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/zh/hans/constants.js +1 -0
- package/dist/locales/zh/hans/constants.js.map +1 -0
- package/dist/locales/zh/hans/index.js +1 -0
- package/dist/locales/zh/hans/index.js.map +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansCasualDateParser.js +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansCasualDateParser.js.map +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansDateParser.js +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js.map +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansWeekdayParser.js +1 -0
- package/dist/locales/zh/hans/parsers/ZHHansWeekdayParser.js.map +1 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateRangeRefiner.js +1 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateTimeRefiner.js +1 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/zh/hant/constants.js +1 -0
- package/dist/locales/zh/hant/constants.js.map +1 -0
- package/dist/locales/zh/hant/index.js +1 -0
- package/dist/locales/zh/hant/index.js.map +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantCasualDateParser.js +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantCasualDateParser.js.map +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantDateParser.js +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js.map +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantWeekdayParser.js +1 -0
- package/dist/locales/zh/hant/parsers/ZHHantWeekdayParser.js.map +1 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateRangeRefiner.js +1 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateTimeRefiner.js +1 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/zh/index.d.ts +1 -1
- package/dist/locales/zh/index.js +14 -2
- package/dist/locales/zh/index.js.map +1 -0
- package/dist/results.d.ts +3 -3
- package/dist/results.js +2 -2
- package/dist/results.js.map +1 -0
- package/dist/timezone.d.ts +1 -1
- package/dist/timezone.js +4 -3
- package/dist/timezone.js.map +1 -0
- package/dist/utils/dayjs.js +1 -0
- package/dist/utils/dayjs.js.map +1 -0
- package/dist/utils/pattern.js +1 -0
- package/dist/utils/pattern.js.map +1 -0
- package/dist/utils/timeunits.js +1 -0
- package/dist/utils/timeunits.js.map +1 -0
- package/package.json +1 -1
- package/src/common/casualReferences.ts +64 -9
- package/src/common/parsers/AbstractParserWithWordBoundary.ts +5 -1
- package/src/common/parsers/AbstractTimeExpressionParser.ts +52 -28
- package/src/common/refiners/ExtractTimezoneAbbrRefiner.ts +3 -1
- package/src/common/refiners/ExtractTimezoneOffsetRefiner.ts +5 -1
- package/src/index.ts +2 -1
- package/src/locales/de/constants.ts +42 -22
- package/src/locales/de/index.ts +4 -0
- package/src/locales/de/parsers/DESpecificTimeExpressionParser.ts +150 -0
- package/src/locales/de/parsers/DETimeExpressionParser.ts +4 -23
- package/src/locales/de/parsers/DETimeUnitRelativeFormatParser.ts +42 -0
- package/src/locales/en/constants.ts +5 -2
- package/src/locales/en/index.ts +2 -1
- package/src/locales/en/parsers/ENRelativeDateFormatParser.ts +2 -2
- package/src/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.ts +1 -1
- package/src/locales/en/refiners/ENMergeRelativeDateRefiner.ts +58 -0
- package/src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/ru/constants.ts +344 -0
- package/src/locales/ru/index.ts +84 -0
- package/src/locales/ru/parsers/RUCasualDateParser.ts +44 -0
- package/src/locales/ru/parsers/RUCasualTimeParser.ts +56 -0
- package/src/locales/ru/parsers/RUMonthNameLittleEndianParser.ts +72 -0
- package/src/locales/ru/parsers/RUMonthNameParser.ts +61 -0
- package/src/locales/ru/parsers/RURelativeDateFormatParser.ts +75 -0
- package/src/locales/ru/parsers/RUTimeExpressionParser.ts +64 -0
- package/src/locales/ru/parsers/RUTimeUnitAgoFormatParser.ts +24 -0
- package/src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts +34 -0
- package/src/locales/ru/parsers/RUTimeUnitWithinFormatParser.ts +24 -0
- package/src/locales/ru/parsers/RUWeekdayParser.ts +63 -0
- package/src/locales/ru/refiners/RUMergeDateRangeRefiner.ts +13 -0
- package/src/locales/ru/refiners/RUMergeDateTimeRefiner.ts +13 -0
- package/src/locales/zh/index.ts +1 -1
- package/src/results.ts +5 -6
- package/src/timezone.ts +4 -4
- package/src/utils/timeunits.ts +2 -2
- package/test/de/de_month_name_little_endian.test.ts +12 -0
- package/test/de/de_time_exp.test.ts +59 -0
- package/test/de/de_time_units_casual_relative.test.ts +108 -0
- package/test/de/de_year.test.ts +147 -0
- package/test/en/en_merging_relative_dates.test.ts +51 -0
- package/test/en/en_relative.test.ts +67 -2
- package/test/en/en_time_units_ago.test.ts +3 -3
- package/test/en/en_time_units_casual_relative.test.ts +16 -0
- package/test/en/en_time_units_within.test.ts +2 -2
- package/test/en/en_timezone_exp.test.ts +30 -3
- package/test/en/negative_cases.test.ts +8 -0
- package/test/fr/fr_time_units_ago.test.ts +3 -3
- package/test/fr/fr_time_units_within.test.ts +9 -2
- package/test/nl/nl_relative.test.ts +2 -2
- package/test/nl/nl_time_units_ago.test.ts +3 -3
- package/test/ru/ru_casual.test.ts +147 -0
- package/test/ru/ru_month.test.ts +70 -0
- package/test/ru/ru_month_name_little_endian.test.ts +145 -0
- package/test/ru/ru_relative.test.ts +74 -0
- package/test/ru/ru_time_exp.test.ts +111 -0
- package/test/ru/ru_time_units_ago.test.ts +48 -0
- package/test/ru/ru_time_units_casual_relative.test.ts +112 -0
- package/test/ru/ru_time_units_within.test.ts +16 -0
- package/test/ru/ru_weekday.test.ts +52 -0
- package/test/system_timezone.test.ts +22 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
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*ночью|ночью|этим утром|утром|утра|в\\s*полдень|вечером|вечера|в\\s*полночь)` +
|
|
10
|
+
`${REGEX_PARTS.rightBoundary}`,
|
|
11
|
+
REGEX_PARTS.flags
|
|
12
|
+
);
|
|
13
|
+
export default class RUCasualTimeParser 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.refDate);
|
|
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("утра")) {
|
|
34
|
+
return references.morning(context.reference);
|
|
35
|
+
}
|
|
36
|
+
if (lowerText.match(/в\s*полдень/)) {
|
|
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", 0);
|
|
50
|
+
}
|
|
51
|
+
if (lowerText.match(/в\s*полночь/) || lowerText.endsWith("ночью")) {
|
|
52
|
+
return references.midnight(context.reference);
|
|
53
|
+
}
|
|
54
|
+
return component;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -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, parseYear } 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 RUMonthNameLittleEndianParser 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 = parseYear(match[YEAR_GROUP]);
|
|
57
|
+
result.start.assign("year", yearNumber);
|
|
58
|
+
} else {
|
|
59
|
+
const year = findYearClosestToRef(context.refDate, 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, parseYear } 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
|
+
* - Январь, 2012
|
|
25
|
+
* - Январь 2012
|
|
26
|
+
* - Январь
|
|
27
|
+
*/
|
|
28
|
+
export default class RUMonthNameParser 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 = parseYear(match[YEAR_GROUP]);
|
|
53
|
+
result.start.assign("year", year);
|
|
54
|
+
} else {
|
|
55
|
+
const year = findYearClosestToRef(context.refDate, 1, month);
|
|
56
|
+
result.start.imply("year", year);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 RURelativeDateFormatParser 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 (modifier == "на следующей" || modifier == "в следующем") {
|
|
33
|
+
const timeUnits = {};
|
|
34
|
+
timeUnits[timeunit] = 1;
|
|
35
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (modifier == "в прошлом" || modifier == "на прошлой") {
|
|
39
|
+
const timeUnits = {};
|
|
40
|
+
timeUnits[timeunit] = -1;
|
|
41
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const components = context.createParsingComponents();
|
|
45
|
+
let date = dayjs(context.reference.instant);
|
|
46
|
+
|
|
47
|
+
// This week
|
|
48
|
+
if (timeunit.match(/week/i)) {
|
|
49
|
+
date = date.add(-date.get("d"), "d");
|
|
50
|
+
components.imply("day", date.date());
|
|
51
|
+
components.imply("month", date.month() + 1);
|
|
52
|
+
components.imply("year", date.year());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// This month
|
|
56
|
+
else if (timeunit.match(/month/i)) {
|
|
57
|
+
date = date.add(-date.date() + 1, "d");
|
|
58
|
+
components.imply("day", date.date());
|
|
59
|
+
components.assign("year", date.year());
|
|
60
|
+
components.assign("month", date.month() + 1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// This year
|
|
64
|
+
else if (timeunit.match(/year/i)) {
|
|
65
|
+
date = date.add(-date.date() + 1, "d");
|
|
66
|
+
date = date.add(-date.month(), "month");
|
|
67
|
+
|
|
68
|
+
components.imply("day", date.date());
|
|
69
|
+
components.imply("month", date.month() + 1);
|
|
70
|
+
components.assign("year", date.year());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return components;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { Meridiem } from "../../../index";
|
|
4
|
+
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
5
|
+
import { REGEX_PARTS } from "../constants";
|
|
6
|
+
|
|
7
|
+
export default class RUTimeExpressionParser 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("после полудня")) {
|
|
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 RUTimeUnitAgoFormatParser 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 RUTimeUnitCasualRelativeFormatParser 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[2]);
|
|
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,24 @@
|
|
|
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(`(?:в течение|в течении)\\s*${PATTERN}`, REGEX_PARTS.flags);
|
|
8
|
+
|
|
9
|
+
const PATTERN_WITHOUT_PREFIX = new RegExp(PATTERN, "i");
|
|
10
|
+
|
|
11
|
+
export default class RUTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
12
|
+
patternLeftBoundary(): string {
|
|
13
|
+
return REGEX_PARTS.leftBoundary;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
innerPattern(context: ParsingContext): RegExp {
|
|
17
|
+
return context.option.forwardDate ? PATTERN_WITHOUT_PREFIX : PATTERN_WITH_PREFIX;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
21
|
+
const timeUnits = parseTimeUnits(match[1]);
|
|
22
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { REGEX_PARTS, WEEKDAY_DICTIONARY } from "../constants";
|
|
4
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
+
import { toDayJSWeekday } from "../../../calculation/weeks";
|
|
7
|
+
|
|
8
|
+
const PATTERN = new RegExp(
|
|
9
|
+
`(?:(?:,|\\(|()\\s*)?` +
|
|
10
|
+
`(?:в\\s*?)?` +
|
|
11
|
+
`(?:(эту|этот|прошлый|прошлую|следующий|следующую|следующего)\\s*)?` +
|
|
12
|
+
`(${matchAnyPattern(WEEKDAY_DICTIONARY)})` +
|
|
13
|
+
`(?:\\s*(?:,|\\)|)))?` +
|
|
14
|
+
`(?:\\s*на\\s*(этой|прошлой|следующей)\\s*неделе)?` +
|
|
15
|
+
`${REGEX_PARTS.rightBoundary}`,
|
|
16
|
+
REGEX_PARTS.flags
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const PREFIX_GROUP = 1;
|
|
20
|
+
const WEEKDAY_GROUP = 2;
|
|
21
|
+
const POSTFIX_GROUP = 3;
|
|
22
|
+
|
|
23
|
+
export default class RUWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
24
|
+
innerPattern(): RegExp {
|
|
25
|
+
return PATTERN;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
patternLeftBoundary(): string {
|
|
29
|
+
return REGEX_PARTS.leftBoundary;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
33
|
+
const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
|
34
|
+
const offset = WEEKDAY_DICTIONARY[dayOfWeek];
|
|
35
|
+
const prefix = match[PREFIX_GROUP];
|
|
36
|
+
const postfix = match[POSTFIX_GROUP];
|
|
37
|
+
let modifierWord = prefix || postfix;
|
|
38
|
+
modifierWord = modifierWord || "";
|
|
39
|
+
modifierWord = modifierWord.toLowerCase();
|
|
40
|
+
|
|
41
|
+
let modifier = null;
|
|
42
|
+
if (modifierWord == "прошлый" || modifierWord == "прошлую" || modifierWord == "прошлой") {
|
|
43
|
+
modifier = "last";
|
|
44
|
+
} else if (
|
|
45
|
+
modifierWord == "следующий" ||
|
|
46
|
+
modifierWord == "следующую" ||
|
|
47
|
+
modifierWord == "следующей" ||
|
|
48
|
+
modifierWord == "следующего"
|
|
49
|
+
) {
|
|
50
|
+
modifier = "next";
|
|
51
|
+
} else if (modifierWord == "этот" || modifierWord == "эту" || modifierWord == "этой") {
|
|
52
|
+
modifier = "this";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const date = toDayJSWeekday(context.refDate, offset, modifier);
|
|
56
|
+
return context
|
|
57
|
+
.createParsingComponents()
|
|
58
|
+
.assign("weekday", offset)
|
|
59
|
+
.imply("day", date.date())
|
|
60
|
+
.imply("month", date.month() + 1)
|
|
61
|
+
.imply("year", date.year());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -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
|
+
* - c 06.09.1989 [до|по] 11.12.1996
|
|
7
|
+
* - c пятницы и до среды
|
|
8
|
+
*/
|
|
9
|
+
export default class xf 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 English connecting phases
|
|
6
|
+
* - 2020-02-13 [в] 6:00
|
|
7
|
+
* - Завтра [,] 7:00
|
|
8
|
+
*/
|
|
9
|
+
export default class RUMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner {
|
|
10
|
+
patternBetween(): RegExp {
|
|
11
|
+
return new RegExp(`^\\s*(T|в|,|-)?\\s*$`);
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/locales/zh/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./hant";
|
|
2
|
-
export
|
|
2
|
+
export * as hans from "./hans";
|
package/src/results.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { Component, ParsedComponents, ParsedResult, ParsingReference } from "./index";
|
|
2
2
|
|
|
3
3
|
import quarterOfYear from "dayjs/plugin/quarterOfYear";
|
|
4
|
-
import dayjs, {
|
|
4
|
+
import dayjs, { QUnitType } from "dayjs";
|
|
5
5
|
import { assignSimilarDate, assignSimilarTime, implySimilarTime } from "./utils/dayjs";
|
|
6
6
|
import { toTimezoneOffset } from "./timezone";
|
|
7
7
|
dayjs.extend(quarterOfYear);
|
|
8
8
|
|
|
9
9
|
export class ReferenceWithTimezone {
|
|
10
10
|
readonly instant: Date;
|
|
11
|
-
readonly timezoneOffset?: number;
|
|
11
|
+
readonly timezoneOffset?: number | null;
|
|
12
12
|
|
|
13
13
|
constructor(input?: ParsingReference | Date) {
|
|
14
14
|
input = input ?? new Date();
|
|
15
15
|
if (input instanceof Date) {
|
|
16
16
|
this.instant = input;
|
|
17
|
-
this.timezoneOffset = -input.getTimezoneOffset();
|
|
18
17
|
} else {
|
|
19
18
|
this.instant = input.instant ?? new Date();
|
|
20
19
|
this.timezoneOffset = toTimezoneOffset(input.timezone);
|
|
@@ -133,7 +132,7 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
133
132
|
toString() {
|
|
134
133
|
return `[ParsingComponents {knownValues: ${JSON.stringify(this.knownValues)}, impliedValues: ${JSON.stringify(
|
|
135
134
|
this.impliedValues
|
|
136
|
-
)}}]`;
|
|
135
|
+
)}}, reference: ${JSON.stringify(this.reference)}]`;
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
dayjs() {
|
|
@@ -176,11 +175,11 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
176
175
|
|
|
177
176
|
static createRelativeFromReference(
|
|
178
177
|
reference: ReferenceWithTimezone,
|
|
179
|
-
fragments: { [c in
|
|
178
|
+
fragments: { [c in QUnitType]?: number }
|
|
180
179
|
): ParsingComponents {
|
|
181
180
|
let date = dayjs(reference.instant);
|
|
182
181
|
for (const key in fragments) {
|
|
183
|
-
date = date.add(fragments[key as
|
|
182
|
+
date = date.add(fragments[key as QUnitType], key as QUnitType);
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
const components = new ParsingComponents(reference);
|
package/src/timezone.ts
CHANGED
|
@@ -114,7 +114,7 @@ export const TIMEZONE_ABBR_MAP = {
|
|
|
114
114
|
MHT: 720,
|
|
115
115
|
MMT: 390,
|
|
116
116
|
MSD: 240,
|
|
117
|
-
MSK:
|
|
117
|
+
MSK: 180,
|
|
118
118
|
MST: -420,
|
|
119
119
|
MUT: 240,
|
|
120
120
|
MVT: 300,
|
|
@@ -192,8 +192,8 @@ export const TIMEZONE_ABBR_MAP = {
|
|
|
192
192
|
YEKT: 360,
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
export function toTimezoneOffset(timezoneInput
|
|
196
|
-
if (timezoneInput === null) {
|
|
195
|
+
export function toTimezoneOffset(timezoneInput?: string | number): number | null {
|
|
196
|
+
if (timezoneInput === null || timezoneInput === undefined) {
|
|
197
197
|
return null;
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -201,5 +201,5 @@ export function toTimezoneOffset(timezoneInput: string | number): number | null
|
|
|
201
201
|
return timezoneInput;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
return TIMEZONE_ABBR_MAP[timezoneInput] ??
|
|
204
|
+
return TIMEZONE_ABBR_MAP[timezoneInput] ?? null;
|
|
205
205
|
}
|
package/src/utils/timeunits.ts
CHANGED
|
@@ -18,8 +18,8 @@ export function addImpliedTimeUnits(components: ParsingComponents, timeUnits: Ti
|
|
|
18
18
|
|
|
19
19
|
let date = components.dayjs();
|
|
20
20
|
for (const key in timeUnits) {
|
|
21
|
-
// noinspection JSUnfilteredForInLoop
|
|
22
|
-
date = date.add(timeUnits[key], key as
|
|
21
|
+
// noinspection JSUnfilteredForInLoop,TypeScriptValidateTypes
|
|
22
|
+
date = date.add(timeUnits[key], key as QUnitType);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if ("day" in timeUnits || "d" in timeUnits || "week" in timeUnits || "month" in timeUnits || "year" in timeUnits) {
|
|
@@ -204,6 +204,18 @@ test("Test - Range expression", function () {
|
|
|
204
204
|
|
|
205
205
|
expect(result.end).toBeDate(new Date(2013, 10 - 1, 12, 12));
|
|
206
206
|
});
|
|
207
|
+
|
|
208
|
+
testSingleCase(chrono.de, "10. jänner 2012", new Date(2012, 7, 10), (result) => {
|
|
209
|
+
expect(result.start).not.toBeNull();
|
|
210
|
+
expect(result.start.get("year")).toBe(2012);
|
|
211
|
+
expect(result.start.get("month")).toBe(1);
|
|
212
|
+
expect(result.start.get("day")).toBe(10);
|
|
213
|
+
|
|
214
|
+
expect(result.index).toBe(0);
|
|
215
|
+
expect(result.text).toBe("10. jänner 2012");
|
|
216
|
+
|
|
217
|
+
expect(result.start).toBeDate(new Date(2012, 1 - 1, 10, 12));
|
|
218
|
+
});
|
|
207
219
|
});
|
|
208
220
|
|
|
209
221
|
test("Test - Combined expression", function () {
|