chrono-node 2.3.7 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/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/calculation/weekdays.d.ts +7 -0
- package/dist/common/calculation/weekdays.js +68 -0
- package/dist/common/calculation/weekdays.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 +11 -1
- package/dist/index.js +14 -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 +3 -8
- 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 +4 -3
- package/dist/locales/en/constants.js +4 -0
- package/dist/locales/en/constants.js.map +1 -0
- package/dist/locales/en/index.js +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +4 -9
- 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.js +1 -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 +5 -10
- 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 +4 -9
- 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 +5 -10
- 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 +301 -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 +49 -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 +5 -4
- package/dist/results.js +16 -12
- package/dist/results.js.map +1 -0
- package/dist/timezone.d.ts +1 -1
- package/dist/timezone.js +3 -2
- 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/chrono.ts +3 -1
- package/src/common/calculation/weekdays.ts +89 -0
- 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 +12 -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/de/parsers/DEWeekdayParser.ts +2 -8
- package/src/locales/en/constants.ts +7 -3
- package/src/locales/en/parsers/ENWeekdayParser.ts +3 -9
- package/src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/fr/parsers/FRWeekdayParser.ts +4 -10
- package/src/locales/nl/parsers/NLWeekdayParser.ts +3 -9
- package/src/locales/pt/parsers/PTWeekdayParser.ts +4 -10
- package/src/locales/ru/constants.ts +342 -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 +57 -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 +32 -21
- package/src/timezone.ts +3 -3
- package/src/utils/timeunits.ts +2 -2
- package/test/calculation.test.ts +116 -0
- 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.test.ts +10 -0
- package/test/en/en_relative.test.ts +47 -2
- package/test/en/en_time_units_ago.test.ts +3 -3
- package/test/en/en_time_units_within.test.ts +2 -2
- package/test/en/en_timezone_exp.test.ts +30 -3
- package/test/en/en_weekday.test.ts +116 -1
- 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
- package/src/calculation/weeks.ts +0 -38
|
@@ -3,23 +3,23 @@ import { ParsingComponents, ParsingResult } from "../../results";
|
|
|
3
3
|
import { Meridiem } from "../../index";
|
|
4
4
|
|
|
5
5
|
// prettier-ignore
|
|
6
|
-
function primaryTimePattern(primaryPrefix: string, primarySuffix: string) {
|
|
6
|
+
function primaryTimePattern(leftBoundary: string, primaryPrefix: string, primarySuffix: string, flags: string) {
|
|
7
7
|
return new RegExp(
|
|
8
|
-
|
|
8
|
+
`${leftBoundary}` +
|
|
9
9
|
`${primaryPrefix}` +
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
`(\\d{1,4})` +
|
|
11
|
+
`(?:` +
|
|
12
|
+
`(?:\\.|:|:)` +
|
|
13
|
+
`(\\d{1,2})` +
|
|
14
|
+
`(?:` +
|
|
15
|
+
`(?::|:)` +
|
|
16
|
+
`(\\d{2})` +
|
|
17
|
+
`(?:\\.(\\d{1,6}))?` +
|
|
18
|
+
`)?` +
|
|
19
|
+
`)?` +
|
|
20
|
+
`(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?` +
|
|
21
21
|
`${primarySuffix}`,
|
|
22
|
-
|
|
22
|
+
flags
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -27,16 +27,16 @@ function primaryTimePattern(primaryPrefix: string, primarySuffix: string) {
|
|
|
27
27
|
function followingTimePatten(followingPhase: string, followingSuffix: string) {
|
|
28
28
|
return new RegExp(
|
|
29
29
|
`^(${followingPhase})` +
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
`(\\d{1,4})` +
|
|
31
|
+
`(?:` +
|
|
32
|
+
`(?:\\.|\\:|\\:)` +
|
|
33
|
+
`(\\d{1,2})` +
|
|
34
|
+
`(?:` +
|
|
35
|
+
`(?:\\.|\\:|\\:)` +
|
|
36
|
+
`(\\d{1,2})(?:\\.(\\d{1,6}))?` +
|
|
37
|
+
`)?` +
|
|
38
|
+
`)?` +
|
|
39
|
+
`(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?` +
|
|
40
40
|
`${followingSuffix}`,
|
|
41
41
|
"i"
|
|
42
42
|
);
|
|
@@ -57,12 +57,20 @@ export abstract class AbstractTimeExpressionParser implements Parser {
|
|
|
57
57
|
this.strictMode = strictMode;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
patternFlags(): string {
|
|
61
|
+
return "i";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
primaryPatternLeftBoundary(): string {
|
|
65
|
+
return `(^|\\s|T|\\b)`;
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
primarySuffix(): string {
|
|
61
|
-
return
|
|
69
|
+
return `(?=\\W|$)`;
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
followingSuffix(): string {
|
|
65
|
-
return
|
|
73
|
+
return `(?=\\W|$)`;
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
pattern(context: ParsingContext): RegExp {
|
|
@@ -84,6 +92,12 @@ export abstract class AbstractTimeExpressionParser implements Parser {
|
|
|
84
92
|
const remainingText = context.text.substring(match.index);
|
|
85
93
|
const followingPattern = this.getFollowingTimePatternThroughCache();
|
|
86
94
|
const followingMatch = followingPattern.exec(remainingText);
|
|
95
|
+
|
|
96
|
+
// Pattern "456-12", "2022-12" should not be time without proper context
|
|
97
|
+
if (text.match(/^\d{3,4}/) && followingMatch && followingMatch[0].match(/^\s*([+-])\s*\d{2,4}$/)) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
87
101
|
if (
|
|
88
102
|
!followingMatch ||
|
|
89
103
|
// Pattern "YY.YY -XXXX" is more like timezone offset
|
|
@@ -305,11 +319,16 @@ export abstract class AbstractTimeExpressionParser implements Parser {
|
|
|
305
319
|
}
|
|
306
320
|
|
|
307
321
|
private checkAndReturnWithoutFollowingPattern(result) {
|
|
308
|
-
// Single digit (e.g "1") should not be counted as time expression
|
|
322
|
+
// Single digit (e.g "1") should not be counted as time expression (without proper context)
|
|
309
323
|
if (result.text.match(/^\d$/)) {
|
|
310
324
|
return null;
|
|
311
325
|
}
|
|
312
326
|
|
|
327
|
+
// Three or more digit (e.g. "203", "2014") should not be counted as time expression (without proper context)
|
|
328
|
+
if (result.text.match(/^\d\d\d+$/)) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
|
|
313
332
|
// Instead of "am/pm", it ends with "a" or "p" (e.g "1a", "123p"), this seems unlikely
|
|
314
333
|
if (result.text.match(/\d[apAP]$/)) {
|
|
315
334
|
return null;
|
|
@@ -383,7 +402,12 @@ export abstract class AbstractTimeExpressionParser implements Parser {
|
|
|
383
402
|
return this.cachedPrimaryTimePattern;
|
|
384
403
|
}
|
|
385
404
|
|
|
386
|
-
this.cachedPrimaryTimePattern = primaryTimePattern(
|
|
405
|
+
this.cachedPrimaryTimePattern = primaryTimePattern(
|
|
406
|
+
this.primaryPatternLeftBoundary(),
|
|
407
|
+
primaryPrefix,
|
|
408
|
+
primarySuffix,
|
|
409
|
+
this.patternFlags()
|
|
410
|
+
);
|
|
387
411
|
this.cachedPrimaryPrefix = primaryPrefix;
|
|
388
412
|
this.cachedPrimarySuffix = primarySuffix;
|
|
389
413
|
return this.cachedPrimaryTimePattern;
|
|
@@ -221,7 +221,9 @@ export default class ExtractTimezoneAbbrRefiner implements Refiner {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
context.debug(() => {
|
|
224
|
-
console.log(
|
|
224
|
+
console.log(
|
|
225
|
+
`Extracting timezone: '${timezoneAbbr}' into: ${extractedTimezoneOffset} for: ${result.start}`
|
|
226
|
+
);
|
|
225
227
|
});
|
|
226
228
|
|
|
227
229
|
const currentTimezoneOffset = result.start.get("timezoneOffset");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsingContext, Refiner } from "../../chrono";
|
|
2
2
|
import { ParsingResult } from "../../results";
|
|
3
3
|
|
|
4
|
-
const TIMEZONE_OFFSET_PATTERN = new RegExp("^\\s*(
|
|
4
|
+
const TIMEZONE_OFFSET_PATTERN = new RegExp("^\\s*(?:\\(?(?:GMT|UTC)\\s?)?([+-])(\\d{1,2})(?::?(\\d{2}))?\\)?", "i");
|
|
5
5
|
const TIMEZONE_OFFSET_SIGN_GROUP = 1;
|
|
6
6
|
const TIMEZONE_OFFSET_HOUR_OFFSET_GROUP = 2;
|
|
7
7
|
const TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP = 3;
|
|
@@ -26,6 +26,10 @@ export default class ExtractTimezoneOffsetRefiner implements Refiner {
|
|
|
26
26
|
const hourOffset = parseInt(match[TIMEZONE_OFFSET_HOUR_OFFSET_GROUP]);
|
|
27
27
|
const minuteOffset = parseInt(match[TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP] || "0");
|
|
28
28
|
let timezoneOffset = hourOffset * 60 + minuteOffset;
|
|
29
|
+
// No timezones have offsets greater than 14 hours, so disregard this match
|
|
30
|
+
if (timezoneOffset > 14 * 60) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
29
33
|
if (match[TIMEZONE_OFFSET_SIGN_GROUP] === "-") {
|
|
30
34
|
timezoneOffset = -timezoneOffset;
|
|
31
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -99,6 +99,16 @@ export enum Meridiem {
|
|
|
99
99
|
PM = 1,
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
export enum Weekday {
|
|
103
|
+
SUNDAY = 0,
|
|
104
|
+
MONDAY = 1,
|
|
105
|
+
TUESDAY = 2,
|
|
106
|
+
WEDNESDAY = 3,
|
|
107
|
+
THURSDAY = 4,
|
|
108
|
+
FRIDAY = 5,
|
|
109
|
+
SATURDAY = 6,
|
|
110
|
+
}
|
|
111
|
+
|
|
102
112
|
// Export all locales
|
|
103
113
|
import * as de from "./locales/de";
|
|
104
114
|
import * as fr from "./locales/fr";
|
|
@@ -106,7 +116,8 @@ import * as ja from "./locales/ja";
|
|
|
106
116
|
import * as pt from "./locales/pt";
|
|
107
117
|
import * as nl from "./locales/nl";
|
|
108
118
|
import * as zh from "./locales/zh";
|
|
109
|
-
|
|
119
|
+
import * as ru from "./locales/ru";
|
|
120
|
+
export { de, fr, ja, pt, nl, zh, ru };
|
|
110
121
|
|
|
111
122
|
/**
|
|
112
123
|
* A shortcut for {@link en | chrono.en.strict}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OpUnitType } from "dayjs";
|
|
1
|
+
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";
|
|
@@ -22,9 +22,12 @@ export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
|
|
|
22
22
|
|
|
23
23
|
export const MONTH_DICTIONARY: { [word: string]: number } = {
|
|
24
24
|
"januar": 1,
|
|
25
|
+
"jänner": 1,
|
|
26
|
+
"janner": 1,
|
|
25
27
|
"jan": 1,
|
|
26
28
|
"jan.": 1,
|
|
27
29
|
"februar": 2,
|
|
30
|
+
"feber": 2,
|
|
28
31
|
"feb": 2,
|
|
29
32
|
"feb.": 2,
|
|
30
33
|
"märz": 3,
|
|
@@ -64,6 +67,10 @@ export const MONTH_DICTIONARY: { [word: string]: number } = {
|
|
|
64
67
|
|
|
65
68
|
export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
66
69
|
"eins": 1,
|
|
70
|
+
"eine": 1,
|
|
71
|
+
"einem": 1,
|
|
72
|
+
"einen": 1,
|
|
73
|
+
"einer": 1,
|
|
67
74
|
"zwei": 2,
|
|
68
75
|
"drei": 3,
|
|
69
76
|
"vier": 4,
|
|
@@ -79,29 +86,37 @@ export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
79
86
|
"zwoelf": 12,
|
|
80
87
|
};
|
|
81
88
|
|
|
82
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType } = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } = {
|
|
90
|
+
sek: "second",
|
|
91
|
+
sekunde: "second",
|
|
92
|
+
sekunden: "second",
|
|
86
93
|
min: "minute",
|
|
87
|
-
mins: "minute",
|
|
88
94
|
minute: "minute",
|
|
89
|
-
|
|
95
|
+
minuten: "minute",
|
|
90
96
|
h: "hour",
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
std: "hour",
|
|
98
|
+
stunde: "hour",
|
|
99
|
+
stunden: "hour",
|
|
100
|
+
tag: "d",
|
|
101
|
+
tage: "d",
|
|
102
|
+
tagen: "d",
|
|
103
|
+
woche: "week",
|
|
104
|
+
wochen: "week",
|
|
105
|
+
monat: "month",
|
|
106
|
+
monate: "month",
|
|
107
|
+
monaten: "month",
|
|
108
|
+
monats: "month",
|
|
109
|
+
quartal: "quarter",
|
|
110
|
+
quartals: "quarter",
|
|
111
|
+
quartale: "quarter",
|
|
112
|
+
quartalen: "quarter",
|
|
113
|
+
a: "year",
|
|
114
|
+
j: "year",
|
|
115
|
+
jr: "year",
|
|
116
|
+
jahr: "year",
|
|
117
|
+
jahre: "year",
|
|
118
|
+
jahren: "year",
|
|
119
|
+
jahres: "year",
|
|
105
120
|
};
|
|
106
121
|
|
|
107
122
|
//-----------------------------
|
|
@@ -131,7 +146,7 @@ export function parseNumberPattern(match: string): number {
|
|
|
131
146
|
|
|
132
147
|
//-----------------------------
|
|
133
148
|
|
|
134
|
-
export const YEAR_PATTERN = `(?:[0-9]{1,4}(?:\\s*[vn]\\.?\\s*C(?:hr)
|
|
149
|
+
export const YEAR_PATTERN = `(?:[0-9]{1,4}(?:\\s*[vn]\\.?\\s*(?:C(?:hr)?|(?:u\\.?|d\\.?(?:\\s*g\\.?)?)?\\s*Z)\\.?|\\s*(?:u\\.?|d\\.?(?:\\s*g\\.)?)\\s*Z\\.?)?)`;
|
|
135
150
|
export function parseYear(match: string): number {
|
|
136
151
|
if (/v/i.test(match)) {
|
|
137
152
|
// v.Chr.
|
|
@@ -143,6 +158,11 @@ export function parseYear(match: string): number {
|
|
|
143
158
|
return parseInt(match.replace(/[^0-9]+/gi, ""));
|
|
144
159
|
}
|
|
145
160
|
|
|
161
|
+
if (/z/i.test(match)) {
|
|
162
|
+
// n.Chr. as "uZ" or "dgZ"
|
|
163
|
+
return parseInt(match.replace(/[^0-9]+/gi, ""));
|
|
164
|
+
}
|
|
165
|
+
|
|
146
166
|
const rawYearNumber = parseInt(match);
|
|
147
167
|
return findMostLikelyADYear(rawYearNumber);
|
|
148
168
|
}
|
package/src/locales/de/index.ts
CHANGED
|
@@ -5,11 +5,13 @@ import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
|
5
5
|
import ISOFormatParser from "../../common/parsers/ISOFormatParser";
|
|
6
6
|
import DETimeExpressionParser from "./parsers/DETimeExpressionParser";
|
|
7
7
|
import DEWeekdayParser from "./parsers/DEWeekdayParser";
|
|
8
|
+
import DESpecificTimeExpressionParser from "./parsers/DESpecificTimeExpressionParser";
|
|
8
9
|
import DEMergeDateRangeRefiner from "./refiners/DEMergeDateRangeRefiner";
|
|
9
10
|
import DEMergeDateTimeRefiner from "./refiners/DEMergeDateTimeRefiner";
|
|
10
11
|
import DECasualDateParser from "./parsers/DECasualDateParser";
|
|
11
12
|
import DECasualTimeParser from "./parsers/DECasualTimeParser";
|
|
12
13
|
import DEMonthNameLittleEndianParser from "./parsers/DEMonthNameLittleEndianParser";
|
|
14
|
+
import DETimeUnitRelativeFormatParser from "./parsers/DETimeUnitRelativeFormatParser";
|
|
13
15
|
|
|
14
16
|
// Shortcuts
|
|
15
17
|
export const casual = new Chrono(createCasualConfiguration());
|
|
@@ -27,6 +29,7 @@ export function createCasualConfiguration(littleEndian = true): Configuration {
|
|
|
27
29
|
const option = createConfiguration(false, littleEndian);
|
|
28
30
|
option.parsers.unshift(new DECasualTimeParser());
|
|
29
31
|
option.parsers.unshift(new DECasualDateParser());
|
|
32
|
+
option.parsers.unshift(new DETimeUnitRelativeFormatParser());
|
|
30
33
|
return option;
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -37,6 +40,7 @@ export function createConfiguration(strictMode = true, littleEndian = true): Con
|
|
|
37
40
|
new ISOFormatParser(),
|
|
38
41
|
new SlashDateFormatParser(littleEndian),
|
|
39
42
|
new DETimeExpressionParser(),
|
|
43
|
+
new DESpecificTimeExpressionParser(),
|
|
40
44
|
new DEMonthNameLittleEndianParser(),
|
|
41
45
|
new DEWeekdayParser(),
|
|
42
46
|
],
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Parser, ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
+
import { Meridiem } from "../../../index";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 8h10m00s
|
|
7
|
+
* 8h10m00
|
|
8
|
+
* 8h10
|
|
9
|
+
* 8 Uhr
|
|
10
|
+
* 8h10m00s Uhr
|
|
11
|
+
* 8:10 Uhr
|
|
12
|
+
*/
|
|
13
|
+
const FIRST_REG_PATTERN = new RegExp(
|
|
14
|
+
"(^|\\s|T)" +
|
|
15
|
+
"(?:(?:um|von)\\s*)?" +
|
|
16
|
+
"(\\d{1,2})(?:h|:)?" +
|
|
17
|
+
"(?:(\\d{1,2})(?:m|:)?)?" +
|
|
18
|
+
"(?:(\\d{1,2})(?:s)?)?" +
|
|
19
|
+
"(?:\\s*Uhr)?" +
|
|
20
|
+
"(?:\\s*(morgens|vormittags|nachmittags|abends|nachts|am\\s+(?:Morgen|Vormittag|Nachmittag|Abend)|in\\s+der\\s+Nacht))?" +
|
|
21
|
+
"(?=\\W|$)",
|
|
22
|
+
"i"
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const SECOND_REG_PATTERN = new RegExp(
|
|
26
|
+
"^\\s*(\\-|\\–|\\~|\\〜|bis(?:\\s+um)?|\\?)\\s*" +
|
|
27
|
+
"(\\d{1,2})(?:h|:)?" +
|
|
28
|
+
"(?:(\\d{1,2})(?:m|:)?)?" +
|
|
29
|
+
"(?:(\\d{1,2})(?:s)?)?" +
|
|
30
|
+
"(?:\\s*Uhr)?" +
|
|
31
|
+
"(?:\\s*(morgens|vormittags|nachmittags|abends|nachts|am\\s+(?:Morgen|Vormittag|Nachmittag|Abend)|in\\s+der\\s+Nacht))?" +
|
|
32
|
+
"(?=\\W|$)",
|
|
33
|
+
"i"
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const HOUR_GROUP = 2;
|
|
37
|
+
const MINUTE_GROUP = 3;
|
|
38
|
+
const SECOND_GROUP = 4;
|
|
39
|
+
const AM_PM_HOUR_GROUP = 5;
|
|
40
|
+
|
|
41
|
+
export default class DESpecificTimeExpressionParser implements Parser {
|
|
42
|
+
pattern(context): RegExp {
|
|
43
|
+
return FIRST_REG_PATTERN;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
extract(context: ParsingContext, match: RegExpMatchArray): ParsingResult | null {
|
|
47
|
+
const result = context.createParsingResult(match.index + match[1].length, match[0].substring(match[1].length));
|
|
48
|
+
|
|
49
|
+
// This looks more like a year e.g. 2020
|
|
50
|
+
if (result.text.match(/^\d{4}$/)) {
|
|
51
|
+
match.index += match[0].length;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
result.start = DESpecificTimeExpressionParser.extractTimeComponent(result.start.clone(), match);
|
|
56
|
+
if (!result.start) {
|
|
57
|
+
match.index += match[0].length;
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const remainingText = context.text.substring(match.index + match[0].length);
|
|
62
|
+
const secondMatch = SECOND_REG_PATTERN.exec(remainingText);
|
|
63
|
+
if (secondMatch) {
|
|
64
|
+
result.end = DESpecificTimeExpressionParser.extractTimeComponent(result.start.clone(), secondMatch);
|
|
65
|
+
if (result.end) {
|
|
66
|
+
result.text += secondMatch[0];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private static extractTimeComponent(
|
|
74
|
+
extractingComponents: ParsingComponents,
|
|
75
|
+
match: RegExpMatchArray
|
|
76
|
+
): ParsingComponents | null {
|
|
77
|
+
let hour = 0;
|
|
78
|
+
let minute = 0;
|
|
79
|
+
let meridiem = null;
|
|
80
|
+
|
|
81
|
+
// ----- Hours
|
|
82
|
+
hour = parseInt(match[HOUR_GROUP]);
|
|
83
|
+
|
|
84
|
+
// ----- Minutes
|
|
85
|
+
if (match[MINUTE_GROUP] != null) {
|
|
86
|
+
minute = parseInt(match[MINUTE_GROUP]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (minute >= 60 || hour > 24) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (hour >= 12) {
|
|
94
|
+
meridiem = Meridiem.PM;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ----- AM & PM
|
|
98
|
+
if (match[AM_PM_HOUR_GROUP] != null) {
|
|
99
|
+
if (hour > 12) return null;
|
|
100
|
+
const ampm = match[AM_PM_HOUR_GROUP].toLowerCase();
|
|
101
|
+
if (ampm.match(/morgen|vormittag/)) {
|
|
102
|
+
meridiem = Meridiem.AM;
|
|
103
|
+
if (hour == 12) {
|
|
104
|
+
hour = 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (ampm.match(/nachmittag|abend/)) {
|
|
109
|
+
meridiem = Meridiem.PM;
|
|
110
|
+
if (hour != 12) {
|
|
111
|
+
hour += 12;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (ampm.match(/nacht/)) {
|
|
116
|
+
if (hour == 12) {
|
|
117
|
+
meridiem = Meridiem.AM;
|
|
118
|
+
hour = 0;
|
|
119
|
+
} else if (hour < 6) {
|
|
120
|
+
meridiem = Meridiem.AM;
|
|
121
|
+
} else {
|
|
122
|
+
meridiem = Meridiem.PM;
|
|
123
|
+
hour += 12;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
extractingComponents.assign("hour", hour);
|
|
129
|
+
extractingComponents.assign("minute", minute);
|
|
130
|
+
if (meridiem !== null) {
|
|
131
|
+
extractingComponents.assign("meridiem", meridiem);
|
|
132
|
+
} else {
|
|
133
|
+
if (hour < 12) {
|
|
134
|
+
extractingComponents.imply("meridiem", Meridiem.AM);
|
|
135
|
+
} else {
|
|
136
|
+
extractingComponents.imply("meridiem", Meridiem.PM);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ----- Second
|
|
141
|
+
if (match[SECOND_GROUP] != null) {
|
|
142
|
+
const second = parseInt(match[SECOND_GROUP]);
|
|
143
|
+
if (second >= 60) return null;
|
|
144
|
+
|
|
145
|
+
extractingComponents.assign("second", second);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return extractingComponents;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
2
2
|
import { ParsingComponents } from "../../../results";
|
|
3
3
|
import { ParsingContext } from "../../../chrono";
|
|
4
|
-
import { Meridiem } from "../../../index";
|
|
5
4
|
|
|
6
5
|
export default class DETimeExpressionParser extends AbstractTimeExpressionParser {
|
|
7
6
|
primaryPrefix(): string {
|
|
@@ -12,30 +11,12 @@ export default class DETimeExpressionParser extends AbstractTimeExpressionParser
|
|
|
12
11
|
return "\\s*(?:\\-|\\–|\\~|\\〜|bis)\\s*";
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
primarySuffix(): string {
|
|
16
|
-
return "(?:\\s*uhr)?(?:\\s*(?:morgens|vormittags|nachmittags|abends|nachts))?(?=\\W|$)";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
14
|
extractPrimaryTimeComponents(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | null {
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
components.assign("meridiem", Meridiem.AM);
|
|
24
|
-
const hour = components.get("hour");
|
|
25
|
-
if (hour < 12) {
|
|
26
|
-
components.assign("hour", components.get("hour"));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (match[0].endsWith("nachmittags") || match[0].endsWith("abends") || match[0].endsWith("nachts")) {
|
|
31
|
-
components.assign("meridiem", Meridiem.PM);
|
|
32
|
-
const hour = components.get("hour");
|
|
33
|
-
if (hour < 12) {
|
|
34
|
-
components.assign("hour", components.get("hour") + 12);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
15
|
+
// This looks more like a year e.g. 2020
|
|
16
|
+
if (match[0].match(/^\s*\d{4}\s*$/)) {
|
|
17
|
+
return null;
|
|
37
18
|
}
|
|
38
19
|
|
|
39
|
-
return
|
|
20
|
+
return super.extractPrimaryTimeComponents(context, match);
|
|
40
21
|
}
|
|
41
22
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { NUMBER_PATTERN, parseNumberPattern, TIME_UNIT_DICTIONARY } from "../constants";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
6
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
|
+
|
|
8
|
+
export default class DETimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
innerPattern(): RegExp {
|
|
14
|
+
return new RegExp(
|
|
15
|
+
`(?:\\s*((?:nächste|kommende|folgende|letzte|vergangene|vorige|vor(?:her|an)gegangene)(?:s|n|m|r)?|vor|in)\\s*)?` +
|
|
16
|
+
`(${NUMBER_PATTERN})?` +
|
|
17
|
+
`(?:\\s*(nächste|kommende|folgende|letzte|vergangene|vorige|vor(?:her|an)gegangene)(?:s|n|m|r)?)?` +
|
|
18
|
+
`\\s*(${matchAnyPattern(TIME_UNIT_DICTIONARY)})`,
|
|
19
|
+
"i"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
24
|
+
const num = match[2] ? parseNumberPattern(match[2]) : 1;
|
|
25
|
+
const unit = TIME_UNIT_DICTIONARY[match[4].toLowerCase()];
|
|
26
|
+
let timeUnits = {};
|
|
27
|
+
timeUnits[unit] = num;
|
|
28
|
+
|
|
29
|
+
// Modifier
|
|
30
|
+
let modifier = match[1] || match[3] || "";
|
|
31
|
+
modifier = modifier.toLowerCase();
|
|
32
|
+
if (!modifier) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (/vor/.test(modifier) || /letzte/.test(modifier) || /vergangen/.test(modifier)) {
|
|
37
|
+
timeUnits = reverseTimeUnits(timeUnits);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -3,7 +3,7 @@ import { ParsingComponents } from "../../../results";
|
|
|
3
3
|
import { WEEKDAY_DICTIONARY } from "../constants";
|
|
4
4
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
5
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
-
import {
|
|
6
|
+
import { createParsingComponentsAtWeekday } from "../../../common/calculation/weekdays";
|
|
7
7
|
|
|
8
8
|
const PATTERN = new RegExp(
|
|
9
9
|
"(?:(?:\\,|\\(|\\()\\s*)?" +
|
|
@@ -44,12 +44,6 @@ export default class DEWeekdayParser extends AbstractParserWithWordBoundaryCheck
|
|
|
44
44
|
modifier = "this";
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
return context
|
|
49
|
-
.createParsingComponents()
|
|
50
|
-
.assign("weekday", offset)
|
|
51
|
-
.imply("day", date.date())
|
|
52
|
-
.imply("month", date.month() + 1)
|
|
53
|
-
.imply("year", date.year());
|
|
47
|
+
return createParsingComponentsAtWeekday(context.reference, offset, modifier);
|
|
54
48
|
}
|
|
55
49
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { OpUnitType } from "dayjs";
|
|
1
|
+
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 "../../index";
|
|
5
6
|
|
|
6
|
-
export const WEEKDAY_DICTIONARY: { [word: string]:
|
|
7
|
+
export const WEEKDAY_DICTIONARY: { [word: string]: Weekday } = {
|
|
7
8
|
sunday: 0,
|
|
8
9
|
sun: 0,
|
|
9
10
|
"sun.": 0,
|
|
@@ -133,7 +134,7 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
133
134
|
"thirty-first": 31,
|
|
134
135
|
};
|
|
135
136
|
|
|
136
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType } = {
|
|
137
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } = {
|
|
137
138
|
sec: "second",
|
|
138
139
|
second: "second",
|
|
139
140
|
seconds: "second",
|
|
@@ -152,6 +153,9 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType } = {
|
|
|
152
153
|
weeks: "week",
|
|
153
154
|
month: "month",
|
|
154
155
|
months: "month",
|
|
156
|
+
qtr: "quarter",
|
|
157
|
+
quarter: "quarter",
|
|
158
|
+
quarters: "quarter",
|
|
155
159
|
y: "year",
|
|
156
160
|
yr: "year",
|
|
157
161
|
year: "year",
|
|
@@ -3,7 +3,7 @@ import { ParsingComponents } from "../../../results";
|
|
|
3
3
|
import { WEEKDAY_DICTIONARY } from "../constants";
|
|
4
4
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
5
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
-
import {
|
|
6
|
+
import { createParsingComponentsAtWeekday } from "../../../common/calculation/weekdays";
|
|
7
7
|
|
|
8
8
|
const PATTERN = new RegExp(
|
|
9
9
|
"(?:(?:\\,|\\(|\\()\\s*)?" +
|
|
@@ -27,7 +27,7 @@ export default class ENWeekdayParser extends AbstractParserWithWordBoundaryCheck
|
|
|
27
27
|
|
|
28
28
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
29
29
|
const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
|
30
|
-
const
|
|
30
|
+
const weekday = WEEKDAY_DICTIONARY[dayOfWeek];
|
|
31
31
|
const prefix = match[PREFIX_GROUP];
|
|
32
32
|
const postfix = match[POSTFIX_GROUP];
|
|
33
33
|
let modifierWord = prefix || postfix;
|
|
@@ -43,12 +43,6 @@ export default class ENWeekdayParser extends AbstractParserWithWordBoundaryCheck
|
|
|
43
43
|
modifier = "this";
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
return context
|
|
48
|
-
.createParsingComponents()
|
|
49
|
-
.assign("weekday", offset)
|
|
50
|
-
.imply("day", date.date())
|
|
51
|
-
.imply("month", date.month() + 1)
|
|
52
|
-
.imply("year", date.year());
|
|
46
|
+
return createParsingComponentsAtWeekday(context.reference, weekday, modifier);
|
|
53
47
|
}
|
|
54
48
|
}
|
|
@@ -5,7 +5,7 @@ import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/
|
|
|
5
5
|
|
|
6
6
|
export default class FRTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
7
7
|
innerPattern(): RegExp {
|
|
8
|
-
return new RegExp(`(?:dans|en|pour|pendant)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
|
8
|
+
return new RegExp(`(?:dans|en|pour|pendant|de)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|