chrono-node 2.8.4 → 2.9.0
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/dist/cjs/calculation/duration.d.ts +5 -0
- package/dist/cjs/calculation/duration.js +6 -0
- package/dist/cjs/calculation/duration.js.map +1 -1
- package/dist/cjs/calculation/mergingCalculation.js +5 -4
- package/dist/cjs/calculation/mergingCalculation.js.map +1 -1
- package/dist/cjs/calculation/weekdays.js +1 -2
- package/dist/cjs/calculation/weekdays.js.map +1 -1
- package/dist/cjs/calculation/years.js +11 -16
- package/dist/cjs/calculation/years.js.map +1 -1
- package/dist/cjs/common/casualReferences.d.ts +1 -1
- package/dist/cjs/common/casualReferences.js +29 -31
- package/dist/cjs/common/casualReferences.js.map +1 -1
- package/dist/cjs/common/parsers/AbstractTimeExpressionParser.js +3 -0
- package/dist/cjs/common/parsers/AbstractTimeExpressionParser.js.map +1 -1
- package/dist/cjs/common/refiners/AbstractMergeDateRangeRefiner.js +20 -19
- package/dist/cjs/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -1
- package/dist/cjs/common/refiners/ForwardDateRefiner.js +16 -24
- package/dist/cjs/common/refiners/ForwardDateRefiner.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/locales/de/constants.d.ts +4 -4
- package/dist/cjs/locales/de/constants.js +5 -5
- package/dist/cjs/locales/de/constants.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DECasualDateParser.js +18 -15
- package/dist/cjs/locales/de/parsers/DECasualDateParser.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DECasualTimeParser.js +4 -9
- package/dist/cjs/locales/de/parsers/DECasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.js +2 -2
- package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/de/parsers/DETimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/de/parsers/DETimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/constants.d.ts +5 -6
- package/dist/cjs/locales/en/constants.js +5 -5
- package/dist/cjs/locales/en/constants.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENCasualDateParser.js +7 -9
- package/dist/cjs/locales/en/parsers/ENCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENRelativeDateFormatParser.js +14 -18
- package/dist/cjs/locales/en/parsers/ENRelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitAgoFormatParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitLaterFormatParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js +1 -5
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js +3 -3
- package/dist/cjs/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js.map +1 -1
- package/dist/cjs/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js +1 -1
- package/dist/cjs/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js.map +1 -1
- package/dist/cjs/locales/es/constants.d.ts +4 -5
- package/dist/cjs/locales/es/constants.js +4 -4
- package/dist/cjs/locales/es/constants.js.map +1 -1
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js +6 -7
- package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/es/parsers/ESTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/es/parsers/ESTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/fr/constants.d.ts +4 -5
- package/dist/cjs/locales/fr/constants.js +4 -4
- package/dist/cjs/locales/fr/constants.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRCasualDateParser.js +6 -9
- package/dist/cjs/locales/fr/parsers/FRCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRTimeUnitAgoFormatParser.js +3 -3
- package/dist/cjs/locales/fr/parsers/FRTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +2 -2
- package/dist/cjs/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/fr/parsers/FRTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/fr/parsers/FRTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/constants.d.ts +4 -4
- package/dist/cjs/locales/it/constants.js +4 -4
- package/dist/cjs/locales/it/constants.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITCasualDateParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITCasualDateParser.js +9 -11
- package/dist/cjs/locales/it/parsers/ITCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITCasualTimeParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js +8 -9
- package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js +14 -18
- package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js +3 -3
- package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +3 -3
- package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/refiners/ITMergeRelativeDateRefiner.js +3 -3
- package/dist/cjs/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js +4 -8
- package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPStandardParser.js +1 -6
- package/dist/cjs/locales/ja/parsers/JPStandardParser.js.map +1 -1
- package/dist/cjs/locales/ja/parsers/JPTimeExpressionParser.d.ts +1 -1
- package/dist/cjs/locales/ja/parsers/JPTimeExpressionParser.js +77 -187
- package/dist/cjs/locales/ja/parsers/JPTimeExpressionParser.js.map +1 -1
- package/dist/cjs/locales/nl/constants.d.ts +4 -4
- package/dist/cjs/locales/nl/constants.js +4 -4
- package/dist/cjs/locales/nl/constants.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualDateTimeParser.js +10 -9
- package/dist/cjs/locales/nl/parsers/NLCasualDateTimeParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js +6 -7
- package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLRelativeDateFormatParser.js +14 -18
- package/dist/cjs/locales/nl/parsers/NLRelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLTimeUnitAgoFormatParser.js +3 -3
- package/dist/cjs/locales/nl/parsers/NLTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js +3 -3
- package/dist/cjs/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLTimeUnitLaterFormatParser.js +1 -1
- package/dist/cjs/locales/nl/parsers/NLTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/cjs/locales/nl/parsers/NLTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/nl/parsers/NLTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js +6 -7
- package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/ru/constants.d.ts +4 -4
- package/dist/cjs/locales/ru/constants.js +7 -7
- package/dist/cjs/locales/ru/constants.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RUCasualTimeParser.js +6 -9
- package/dist/cjs/locales/ru/parsers/RUCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RURelativeDateFormatParser.js +14 -18
- package/dist/cjs/locales/ru/parsers/RURelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RUTimeUnitAgoFormatParser.js +3 -3
- package/dist/cjs/locales/ru/parsers/RUTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js +3 -3
- package/dist/cjs/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/ru/parsers/RUTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/ru/parsers/RUTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/sv/constants.d.ts +8 -4
- package/dist/cjs/locales/sv/constants.js +25 -7
- package/dist/cjs/locales/sv/constants.js.map +1 -1
- package/dist/cjs/locales/sv/index.js +2 -0
- package/dist/cjs/locales/sv/index.js.map +1 -1
- package/dist/cjs/locales/sv/parsers/SVCasualDateParser.js +14 -13
- package/dist/cjs/locales/sv/parsers/SVCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.d.ts +9 -0
- package/dist/cjs/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js +34 -0
- package/dist/cjs/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/cjs/locales/uk/constants.d.ts +4 -4
- package/dist/cjs/locales/uk/constants.js +8 -8
- package/dist/cjs/locales/uk/constants.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js +6 -9
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js +14 -18
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +3 -3
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +3 -3
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansCasualDateParser.js +23 -27
- package/dist/cjs/locales/zh/hans/parsers/ZHHansCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.js +2 -7
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +20 -21
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js +17 -22
- package/dist/cjs/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +71 -76
- package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansWeekdayParser.js +14 -19
- package/dist/cjs/locales/zh/hans/parsers/ZHHansWeekdayParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantCasualDateParser.js +23 -27
- package/dist/cjs/locales/zh/hant/parsers/ZHHantCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.js +2 -7
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +20 -21
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js +17 -22
- package/dist/cjs/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +73 -78
- package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantWeekdayParser.js +14 -19
- package/dist/cjs/locales/zh/hant/parsers/ZHHantWeekdayParser.js.map +1 -1
- package/dist/cjs/results.d.ts +3 -4
- package/dist/cjs/results.js +74 -60
- package/dist/cjs/results.js.map +1 -1
- package/dist/cjs/timezone.js +1 -6
- package/dist/cjs/timezone.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -1
- package/dist/esm/calculation/duration.d.ts +5 -0
- package/dist/esm/calculation/duration.js +5 -0
- package/dist/esm/calculation/duration.js.map +1 -1
- package/dist/esm/calculation/mergingCalculation.js +5 -4
- package/dist/esm/calculation/mergingCalculation.js.map +1 -1
- package/dist/esm/calculation/weekdays.js +1 -2
- package/dist/esm/calculation/weekdays.js.map +1 -1
- package/dist/esm/calculation/years.js +11 -13
- package/dist/esm/calculation/years.js.map +1 -1
- package/dist/esm/common/casualReferences.d.ts +1 -1
- package/dist/esm/common/casualReferences.js +21 -20
- package/dist/esm/common/casualReferences.js.map +1 -1
- package/dist/esm/common/parsers/AbstractTimeExpressionParser.js +3 -0
- package/dist/esm/common/parsers/AbstractTimeExpressionParser.js.map +1 -1
- package/dist/esm/common/refiners/AbstractMergeDateRangeRefiner.js +20 -19
- package/dist/esm/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -1
- package/dist/esm/common/refiners/ForwardDateRefiner.js +16 -21
- package/dist/esm/common/refiners/ForwardDateRefiner.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/locales/de/constants.d.ts +4 -4
- package/dist/esm/locales/de/constants.js +4 -4
- package/dist/esm/locales/de/constants.js.map +1 -1
- package/dist/esm/locales/de/parsers/DECasualDateParser.js +13 -10
- package/dist/esm/locales/de/parsers/DECasualDateParser.js.map +1 -1
- package/dist/esm/locales/de/parsers/DECasualTimeParser.js +3 -5
- package/dist/esm/locales/de/parsers/DECasualTimeParser.js.map +1 -1
- package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.js +2 -2
- package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/de/parsers/DETimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/de/parsers/DETimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/en/constants.d.ts +5 -6
- package/dist/esm/locales/en/constants.js +7 -7
- package/dist/esm/locales/en/constants.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENCasualDateParser.js +6 -5
- package/dist/esm/locales/en/parsers/ENCasualDateParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENRelativeDateFormatParser.js +14 -15
- package/dist/esm/locales/en/parsers/ENRelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitAgoFormatParser.js +2 -2
- package/dist/esm/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +2 -2
- package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js +2 -2
- package/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js +2 -6
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js +4 -4
- package/dist/esm/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js.map +1 -1
- package/dist/esm/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js +2 -2
- package/dist/esm/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js.map +1 -1
- package/dist/esm/locales/es/constants.d.ts +4 -5
- package/dist/esm/locales/es/constants.js +3 -3
- package/dist/esm/locales/es/constants.js.map +1 -1
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.js +6 -4
- package/dist/esm/locales/es/parsers/ESCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/es/parsers/ESTimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/es/parsers/ESTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/fr/constants.d.ts +4 -5
- package/dist/esm/locales/fr/constants.js +3 -3
- package/dist/esm/locales/fr/constants.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRCasualDateParser.js +5 -5
- package/dist/esm/locales/fr/parsers/FRCasualDateParser.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRTimeUnitAgoFormatParser.js +4 -4
- package/dist/esm/locales/fr/parsers/FRTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +2 -2
- package/dist/esm/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/fr/parsers/FRTimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/fr/parsers/FRTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/it/constants.d.ts +4 -4
- package/dist/esm/locales/it/constants.js +3 -3
- package/dist/esm/locales/it/constants.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITCasualDateParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITCasualDateParser.js +7 -6
- package/dist/esm/locales/it/parsers/ITCasualDateParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITCasualTimeParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITCasualTimeParser.js +7 -5
- package/dist/esm/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js +14 -15
- package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js +4 -4
- package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +4 -4
- package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js +2 -2
- package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/it/refiners/ITMergeRelativeDateRefiner.js +4 -4
- package/dist/esm/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js +4 -5
- package/dist/esm/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPStandardParser.js +1 -3
- package/dist/esm/locales/ja/parsers/JPStandardParser.js.map +1 -1
- package/dist/esm/locales/ja/parsers/JPTimeExpressionParser.d.ts +1 -1
- package/dist/esm/locales/ja/parsers/JPTimeExpressionParser.js +75 -186
- package/dist/esm/locales/ja/parsers/JPTimeExpressionParser.js.map +1 -1
- package/dist/esm/locales/nl/constants.d.ts +4 -4
- package/dist/esm/locales/nl/constants.js +3 -3
- package/dist/esm/locales/nl/constants.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualDateTimeParser.js +9 -5
- package/dist/esm/locales/nl/parsers/NLCasualDateTimeParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js +6 -4
- package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLRelativeDateFormatParser.js +14 -15
- package/dist/esm/locales/nl/parsers/NLRelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLTimeUnitAgoFormatParser.js +4 -4
- package/dist/esm/locales/nl/parsers/NLTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js +4 -4
- package/dist/esm/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLTimeUnitLaterFormatParser.js +2 -2
- package/dist/esm/locales/nl/parsers/NLTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/esm/locales/nl/parsers/NLTimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/nl/parsers/NLTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js +6 -4
- package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/ru/constants.d.ts +4 -4
- package/dist/esm/locales/ru/constants.js +6 -6
- package/dist/esm/locales/ru/constants.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RUCasualTimeParser.js +6 -6
- package/dist/esm/locales/ru/parsers/RUCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RURelativeDateFormatParser.js +14 -15
- package/dist/esm/locales/ru/parsers/RURelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RUTimeUnitAgoFormatParser.js +4 -4
- package/dist/esm/locales/ru/parsers/RUTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js +4 -4
- package/dist/esm/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/ru/parsers/RUTimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/ru/parsers/RUTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/sv/constants.d.ts +8 -4
- package/dist/esm/locales/sv/constants.js +23 -5
- package/dist/esm/locales/sv/constants.js.map +1 -1
- package/dist/esm/locales/sv/index.js +2 -0
- package/dist/esm/locales/sv/index.js.map +1 -1
- package/dist/esm/locales/sv/parsers/SVCasualDateParser.js +14 -10
- package/dist/esm/locales/sv/parsers/SVCasualDateParser.js.map +1 -1
- package/dist/esm/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.d.ts +9 -0
- package/dist/esm/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js +32 -0
- package/dist/esm/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js.map +1 -0
- package/dist/esm/locales/uk/constants.d.ts +4 -4
- package/dist/esm/locales/uk/constants.js +7 -7
- package/dist/esm/locales/uk/constants.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js +6 -6
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js +14 -15
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +4 -4
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +4 -4
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +2 -2
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansCasualDateParser.js +23 -24
- package/dist/esm/locales/zh/hans/parsers/ZHHansCasualDateParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.js +2 -4
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +20 -18
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js +17 -19
- package/dist/esm/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +71 -73
- package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansWeekdayParser.js +14 -16
- package/dist/esm/locales/zh/hans/parsers/ZHHansWeekdayParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantCasualDateParser.js +23 -24
- package/dist/esm/locales/zh/hant/parsers/ZHHantCasualDateParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.js +2 -4
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +20 -18
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js +17 -19
- package/dist/esm/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +73 -75
- package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantWeekdayParser.js +14 -16
- package/dist/esm/locales/zh/hant/parsers/ZHHantWeekdayParser.js.map +1 -1
- package/dist/esm/results.d.ts +3 -4
- package/dist/esm/results.js +75 -58
- package/dist/esm/results.js.map +1 -1
- package/dist/esm/timezone.js +1 -3
- package/dist/esm/timezone.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/package.json +2 -4
- package/src/calculation/duration.ts +10 -0
- package/src/calculation/mergingCalculation.ts +5 -4
- package/src/calculation/weekdays.ts +2 -2
- package/src/calculation/years.ts +11 -16
- package/src/common/casualReferences.ts +23 -33
- package/src/common/parsers/AbstractTimeExpressionParser.ts +6 -0
- package/src/common/refiners/AbstractMergeDateRangeRefiner.ts +20 -21
- package/src/common/refiners/ForwardDateRefiner.ts +17 -22
- package/src/index.ts +3 -1
- package/src/locales/de/constants.ts +8 -8
- package/src/locales/de/parsers/DECasualDateParser.ts +13 -10
- package/src/locales/de/parsers/DECasualTimeParser.ts +3 -5
- package/src/locales/de/parsers/DETimeUnitRelativeFormatParser.ts +2 -2
- package/src/locales/de/parsers/DETimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/en/constants.ts +12 -13
- package/src/locales/en/parsers/ENCasualDateParser.ts +6 -5
- package/src/locales/en/parsers/ENRelativeDateFormatParser.ts +14 -16
- package/src/locales/en/parsers/ENTimeUnitAgoFormatParser.ts +2 -2
- package/src/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.ts +2 -2
- package/src/locales/en/parsers/ENTimeUnitLaterFormatParser.ts +2 -2
- package/src/locales/en/parsers/ENTimeUnitWithinFormatParser.ts +2 -7
- package/src/locales/en/refiners/ENMergeRelativeAfterDateRefiner.ts +4 -4
- package/src/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.ts +2 -2
- package/src/locales/es/constants.ts +7 -6
- package/src/locales/es/parsers/ESCasualTimeParser.ts +6 -4
- package/src/locales/es/parsers/ESTimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/fr/constants.ts +7 -6
- package/src/locales/fr/parsers/FRCasualDateParser.ts +5 -5
- package/src/locales/fr/parsers/FRTimeUnitAgoFormatParser.ts +4 -4
- package/src/locales/fr/parsers/FRTimeUnitRelativeFormatParser.ts +2 -2
- package/src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/it/constants.ts +7 -7
- package/src/locales/it/parsers/ITCasualDateParser.ts +7 -6
- package/src/locales/it/parsers/ITCasualTimeParser.ts +7 -5
- package/src/locales/it/parsers/ITRelativeDateFormatParser.ts +14 -16
- package/src/locales/it/parsers/ITTimeUnitAgoFormatParser.ts +4 -4
- package/src/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.ts +4 -4
- package/src/locales/it/parsers/ITTimeUnitLaterFormatParser.ts +2 -2
- package/src/locales/it/parsers/ITTimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/it/refiners/ITMergeRelativeDateRefiner.ts +4 -4
- package/src/locales/ja/parsers/JPCasualDateParser.ts +4 -5
- package/src/locales/ja/parsers/JPStandardParser.ts +1 -4
- package/src/locales/ja/parsers/JPTimeExpressionParser.ts +91 -190
- package/src/locales/nl/constants.ts +7 -7
- package/src/locales/nl/parsers/NLCasualDateTimeParser.ts +9 -5
- package/src/locales/nl/parsers/NLCasualTimeParser.ts +6 -4
- package/src/locales/nl/parsers/NLRelativeDateFormatParser.ts +14 -16
- package/src/locales/nl/parsers/NLTimeUnitAgoFormatParser.ts +4 -4
- package/src/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.ts +4 -4
- package/src/locales/nl/parsers/NLTimeUnitLaterFormatParser.ts +2 -2
- package/src/locales/nl/parsers/NLTimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/pt/parsers/PTCasualTimeParser.ts +6 -4
- package/src/locales/ru/constants.ts +10 -10
- package/src/locales/ru/parsers/RUCasualTimeParser.ts +6 -6
- package/src/locales/ru/parsers/RURelativeDateFormatParser.ts +15 -18
- package/src/locales/ru/parsers/RUTimeUnitAgoFormatParser.ts +4 -4
- package/src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts +4 -4
- package/src/locales/ru/parsers/RUTimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/sv/constants.ts +31 -9
- package/src/locales/sv/index.ts +2 -0
- package/src/locales/sv/parsers/SVCasualDateParser.ts +14 -10
- package/src/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.ts +42 -0
- package/src/locales/uk/constants.ts +11 -11
- package/src/locales/uk/parsers/UKCasualTimeParser.ts +6 -6
- package/src/locales/uk/parsers/UKRelativeDateFormatParser.ts +14 -16
- package/src/locales/uk/parsers/UKTimeUnitAgoFormatParser.ts +4 -4
- package/src/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.ts +4 -4
- package/src/locales/uk/parsers/UKTimeUnitWithinFormatParser.ts +2 -2
- package/src/locales/zh/hans/parsers/ZHHansCasualDateParser.ts +23 -24
- package/src/locales/zh/hans/parsers/ZHHansDateParser.ts +2 -4
- package/src/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.ts +20 -18
- package/src/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.ts +18 -18
- package/src/locales/zh/hans/parsers/ZHHansTimeExpressionParser.ts +71 -73
- package/src/locales/zh/hans/parsers/ZHHansWeekdayParser.ts +16 -15
- package/src/locales/zh/hant/parsers/ZHHantCasualDateParser.ts +23 -24
- package/src/locales/zh/hant/parsers/ZHHantDateParser.ts +2 -4
- package/src/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.ts +20 -18
- package/src/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.ts +18 -18
- package/src/locales/zh/hant/parsers/ZHHantTimeExpressionParser.ts +73 -75
- package/src/locales/zh/hant/parsers/ZHHantWeekdayParser.ts +16 -15
- package/src/results.ts +82 -58
- package/src/timezone.ts +1 -5
- package/src/types.ts +1 -1
- package/test/calculation_weekdays.test.ts +17 -0
- package/test/en/en_time_exp.test.ts +2 -0
- package/test/it/it_casual.test.ts +44 -0
- package/test/it/it_month_name_little_endian.test.ts +28 -0
- package/test/it/it_weekday.test.ts +37 -0
- package/test/ja/ja_time_exp.test.ts +82 -21
- package/test/result.test.ts +74 -0
- package/test/sv/sv_casual.test.ts +42 -0
- package/test/sv/sv_month_name_little_endian.test.ts +48 -0
- package/test/sv/sv_time_units_casual_relative.test.ts +143 -0
- package/test/zh/hans/zh_hans_casual.test.ts +14 -0
- package/test/zh/hans/zh_hans_date.test.ts +14 -0
- package/test/zh/hans/zh_hans_deadline.test.ts +39 -0
- package/test/zh/hans/zh_hans_time_exp.test.ts +51 -0
- package/test/zh/hans/zh_hans_weekday.test.ts +87 -0
- package/test/zh/hant/zh_hant_casual.test.ts +14 -0
- package/test/zh/hant/zh_hant_date.test.ts +14 -0
- package/test/zh/hant/zh_hant_weekday.test.ts +43 -0
- package/dist/cjs/utils/dayjs.d.ts +0 -8
- package/dist/cjs/utils/dayjs.js +0 -48
- package/dist/cjs/utils/dayjs.js.map +0 -1
- package/dist/cjs/utils/timeunits.d.ts +0 -7
- package/dist/cjs/utils/timeunits.js +0 -30
- package/dist/cjs/utils/timeunits.js.map +0 -1
- package/dist/esm/utils/dayjs.d.ts +0 -8
- package/dist/esm/utils/dayjs.js +0 -40
- package/dist/esm/utils/dayjs.js.map +0 -1
- package/dist/esm/utils/timeunits.d.ts +0 -7
- package/dist/esm/utils/timeunits.js +0 -26
- package/dist/esm/utils/timeunits.js.map +0 -1
- package/src/utils/dayjs.ts +0 -52
- package/src/utils/timeunits.ts +0 -47
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OpUnitType, QUnitType } from "dayjs";
|
|
2
1
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
3
2
|
import { findMostLikelyADYear } from "../../calculation/years";
|
|
4
|
-
import {
|
|
3
|
+
import { Duration } from "../../calculation/duration";
|
|
4
|
+
import { Timeunit } from "../../types";
|
|
5
5
|
|
|
6
6
|
export const REGEX_PARTS = {
|
|
7
7
|
leftBoundary: "([^\\p{L}\\p{N}_]|^)",
|
|
@@ -201,7 +201,7 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
201
201
|
"тридцать первого": 31,
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
204
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
205
205
|
сек: "second",
|
|
206
206
|
секунда: "second",
|
|
207
207
|
секунд: "second",
|
|
@@ -230,11 +230,11 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
230
230
|
часика: "hour",
|
|
231
231
|
часике: "hour",
|
|
232
232
|
часик: "hour",
|
|
233
|
-
день: "
|
|
234
|
-
дня: "
|
|
235
|
-
дней: "
|
|
236
|
-
суток: "
|
|
237
|
-
сутки: "
|
|
233
|
+
день: "day",
|
|
234
|
+
дня: "day",
|
|
235
|
+
дней: "day",
|
|
236
|
+
суток: "day",
|
|
237
|
+
сутки: "day",
|
|
238
238
|
неделя: "week",
|
|
239
239
|
неделе: "week",
|
|
240
240
|
недели: "week",
|
|
@@ -326,7 +326,7 @@ const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
|
326
326
|
|
|
327
327
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern(`(?:(?:около|примерно)\\s{0,3})?`, SINGLE_TIME_UNIT_PATTERN);
|
|
328
328
|
|
|
329
|
-
export function
|
|
329
|
+
export function parseDuration(timeunitText): Duration {
|
|
330
330
|
const fragments = {};
|
|
331
331
|
let remainingText = timeunitText;
|
|
332
332
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -335,7 +335,7 @@ export function parseTimeUnits(timeunitText): TimeUnits {
|
|
|
335
335
|
remainingText = remainingText.substring(match[0].length).trim();
|
|
336
336
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
337
337
|
}
|
|
338
|
-
return fragments;
|
|
338
|
+
return fragments as Duration;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import * as references from "../../../common/casualReferences";
|
|
3
|
-
import { assignSimilarDate } from "../../../utils/
|
|
4
|
-
import dayjs from "dayjs";
|
|
3
|
+
import { assignSimilarDate } from "../../../utils/dates";
|
|
5
4
|
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
6
5
|
|
|
7
6
|
export default class RUCasualTimeParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
@@ -10,7 +9,7 @@ export default class RUCasualTimeParser extends AbstractParserWithLeftRightBound
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
-
let targetDate =
|
|
12
|
+
let targetDate = context.refDate;
|
|
14
13
|
const lowerText = match[0].toLowerCase();
|
|
15
14
|
const component = context.createParsingComponents();
|
|
16
15
|
|
|
@@ -33,9 +32,10 @@ export default class RUCasualTimeParser extends AbstractParserWithLeftRightBound
|
|
|
33
32
|
return references.yesterdayEvening(context.reference);
|
|
34
33
|
}
|
|
35
34
|
if (lowerText.match(/следующей\s*ночью/)) {
|
|
36
|
-
const daysToAdd = targetDate.
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const daysToAdd = targetDate.getHours() < 22 ? 1 : 2;
|
|
36
|
+
const nextDay = new Date(targetDate.getTime());
|
|
37
|
+
nextDay.setDate(nextDay.getDate() + daysToAdd);
|
|
38
|
+
assignSimilarDate(component, nextDay);
|
|
39
39
|
component.imply("hour", 0);
|
|
40
40
|
}
|
|
41
41
|
if (lowerText.match(/в\s*полночь/) || lowerText.endsWith("ночью")) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TIME_UNIT_DICTIONARY } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import dayjs from "dayjs";
|
|
5
|
-
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
4
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
5
|
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
8
6
|
|
|
@@ -34,32 +32,31 @@ export default class RURelativeDateFormatParser extends AbstractParserWithLeftRi
|
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
const components = context.createParsingComponents();
|
|
37
|
-
let date =
|
|
35
|
+
let date = new Date(context.reference.instant.getTime());
|
|
38
36
|
|
|
39
37
|
// This week
|
|
40
38
|
if (timeunit.match(/week/i)) {
|
|
41
|
-
date
|
|
42
|
-
components.imply("day", date.
|
|
43
|
-
components.imply("month", date.
|
|
44
|
-
components.imply("year", date.
|
|
39
|
+
date.setDate(date.getDate() - date.getDay());
|
|
40
|
+
components.imply("day", date.getDate());
|
|
41
|
+
components.imply("month", date.getMonth() + 1);
|
|
42
|
+
components.imply("year", date.getFullYear());
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
// This month
|
|
48
46
|
else if (timeunit.match(/month/i)) {
|
|
49
|
-
date
|
|
50
|
-
components.imply("day", date.
|
|
51
|
-
components.assign("year", date.
|
|
52
|
-
components.assign("month", date.
|
|
47
|
+
date.setDate(1);
|
|
48
|
+
components.imply("day", date.getDate());
|
|
49
|
+
components.assign("year", date.getFullYear());
|
|
50
|
+
components.assign("month", date.getMonth() + 1);
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
// This year
|
|
56
54
|
else if (timeunit.match(/year/i)) {
|
|
57
|
-
date
|
|
58
|
-
date
|
|
59
|
-
|
|
60
|
-
components.imply("
|
|
61
|
-
components.
|
|
62
|
-
components.assign("year", date.year());
|
|
55
|
+
date.setDate(1);
|
|
56
|
+
date.setMonth(0);
|
|
57
|
+
components.imply("day", date.getDate());
|
|
58
|
+
components.imply("month", date.getMonth() + 1);
|
|
59
|
+
components.assign("year", date.getFullYear());
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
return components;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import {
|
|
2
|
+
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
5
4
|
import { AbstractParserWithLeftBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
export default class RUTimeUnitAgoFormatParser extends AbstractParserWithLeftBoundaryChecking {
|
|
8
8
|
innerPatternString(context: ParsingContext): string {
|
|
@@ -10,8 +10,8 @@ export default class RUTimeUnitAgoFormatParser extends AbstractParserWithLeftBou
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
-
const timeUnits =
|
|
14
|
-
const outputTimeUnits =
|
|
13
|
+
const timeUnits = parseDuration(match[1]);
|
|
14
|
+
const outputTimeUnits = reverseDuration(timeUnits);
|
|
15
15
|
|
|
16
16
|
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, REGEX_PARTS } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
5
4
|
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
export default class RUTimeUnitCasualRelativeFormatParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
8
8
|
innerPatternString(context: ParsingContext): string {
|
|
@@ -11,12 +11,12 @@ export default class RUTimeUnitCasualRelativeFormatParser extends AbstractParser
|
|
|
11
11
|
|
|
12
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
13
13
|
const prefix = match[1].toLowerCase();
|
|
14
|
-
let timeUnits =
|
|
14
|
+
let timeUnits = parseDuration(match[2]);
|
|
15
15
|
switch (prefix) {
|
|
16
16
|
case "последние":
|
|
17
17
|
case "прошлые":
|
|
18
18
|
case "-":
|
|
19
|
-
timeUnits =
|
|
19
|
+
timeUnits = reverseDuration(timeUnits);
|
|
20
20
|
break;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, REGEX_PARTS } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
@@ -17,7 +17,7 @@ export default class RUTimeUnitWithinFormatParser extends AbstractParserWithWord
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
20
|
-
const timeUnits =
|
|
20
|
+
const timeUnits = parseDuration(match[1]);
|
|
21
21
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OpUnitType, QUnitType } from "dayjs";
|
|
2
1
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
3
2
|
import { findMostLikelyADYear } from "../../calculation/years";
|
|
4
|
-
import {
|
|
3
|
+
import { Duration } from "../../calculation/duration";
|
|
4
|
+
import { Timeunit } from "../../types";
|
|
5
5
|
|
|
6
6
|
export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
|
|
7
7
|
"söndag": 0,
|
|
@@ -132,29 +132,46 @@ export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
132
132
|
"tusen": 1000,
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
135
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
136
|
+
"sek": "second",
|
|
136
137
|
"sekund": "second",
|
|
137
138
|
"sekunder": "second",
|
|
138
|
-
"
|
|
139
|
+
"min": "minute",
|
|
139
140
|
"minut": "minute",
|
|
140
141
|
"minuter": "minute",
|
|
141
|
-
"
|
|
142
|
+
"tim": "hour",
|
|
142
143
|
"timme": "hour",
|
|
143
144
|
"timmar": "hour",
|
|
144
|
-
"tim": "hour",
|
|
145
145
|
"dag": "day",
|
|
146
146
|
"dagar": "day",
|
|
147
147
|
"vecka": "week",
|
|
148
148
|
"veckor": "week",
|
|
149
|
+
"mån": "month",
|
|
149
150
|
"månad": "month",
|
|
150
151
|
"månader": "month",
|
|
151
|
-
"mån": "month",
|
|
152
152
|
"år": "year",
|
|
153
153
|
"kvartаl": "quarter",
|
|
154
154
|
"kvartal": "quarter",
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
export
|
|
157
|
+
export const TIME_UNIT_NO_ABBR_DICTIONARY: { [word: string]: Timeunit } = {
|
|
158
|
+
"sekund": "second",
|
|
159
|
+
"sekunder": "second",
|
|
160
|
+
"minut": "minute",
|
|
161
|
+
"minuter": "minute",
|
|
162
|
+
"timme": "hour",
|
|
163
|
+
"timmar": "hour",
|
|
164
|
+
"dag": "day",
|
|
165
|
+
"dagar": "day",
|
|
166
|
+
"vecka": "week",
|
|
167
|
+
"veckor": "week",
|
|
168
|
+
"månad": "month",
|
|
169
|
+
"månader": "month",
|
|
170
|
+
"år": "year",
|
|
171
|
+
"kvartal": "quarter",
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export function parseDuration(timeunitText): Duration {
|
|
158
175
|
const fragments = {};
|
|
159
176
|
let remainingText = timeunitText;
|
|
160
177
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -163,7 +180,7 @@ export function parseTimeUnits(timeunitText): TimeUnits {
|
|
|
163
180
|
remainingText = remainingText.substring(match[0].length);
|
|
164
181
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
165
182
|
}
|
|
166
|
-
return fragments;
|
|
183
|
+
return fragments as Duration;
|
|
167
184
|
}
|
|
168
185
|
|
|
169
186
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -179,7 +196,12 @@ export const TIME_UNIT_PATTERN = `(?:${matchAnyPattern(TIME_UNIT_DICTIONARY)})`;
|
|
|
179
196
|
const SINGLE_TIME_UNIT_PATTERN = `(${NUMBER_PATTERN})\\s{0,5}(${matchAnyPattern(TIME_UNIT_DICTIONARY)})\\s{0,5}`;
|
|
180
197
|
const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
181
198
|
|
|
199
|
+
const SINGLE_TIME_UNIT_NO_ABBR_PATTERN = `(${NUMBER_PATTERN})\\s{0,5}(${matchAnyPattern(
|
|
200
|
+
TIME_UNIT_NO_ABBR_DICTIONARY
|
|
201
|
+
)})\\s{0,5}`;
|
|
202
|
+
|
|
182
203
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
|
204
|
+
export const TIME_UNITS_NO_ABBR_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_NO_ABBR_PATTERN);
|
|
183
205
|
|
|
184
206
|
export function parseNumberPattern(match: string): number {
|
|
185
207
|
const num = match.toLowerCase();
|
package/src/locales/sv/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
|
6
6
|
import ISOFormatParser from "../../common/parsers/ISOFormatParser";
|
|
7
7
|
import SVWeekdayParser from "./parsers/SVWeekdayParser";
|
|
8
8
|
import SVMonthNameLittleEndianParser from "./parsers/SVMonthNameLittleEndianParser";
|
|
9
|
+
import SVTimeUnitCasualRelativeFormatParser from "./parsers/SVTimeUnitCasualRelativeFormatParser";
|
|
9
10
|
import SVCasualDateParser from "./parsers/SVCasualDateParser";
|
|
10
11
|
|
|
11
12
|
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
@@ -37,6 +38,7 @@ export function createConfiguration(strictMode = true, littleEndian = true): Con
|
|
|
37
38
|
new SlashDateFormatParser(littleEndian),
|
|
38
39
|
new SVMonthNameLittleEndianParser(),
|
|
39
40
|
new SVWeekdayParser(),
|
|
41
|
+
new SVTimeUnitCasualRelativeFormatParser(),
|
|
40
42
|
],
|
|
41
43
|
refiners: [],
|
|
42
44
|
},
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
-
import dayjs from "dayjs";
|
|
4
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
-
import { assignSimilarDate,
|
|
4
|
+
import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
|
|
6
5
|
import * as references from "../../../common/casualReferences";
|
|
7
6
|
|
|
8
7
|
const PATTERN = new RegExp(
|
|
@@ -21,7 +20,7 @@ export default class SVCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
24
|
-
|
|
23
|
+
const targetDate = context.refDate;
|
|
25
24
|
const dateKeyword = (match[DATE_GROUP] || "").toLowerCase();
|
|
26
25
|
const timeKeyword = (match[TIME_GROUP] || "").toLowerCase();
|
|
27
26
|
|
|
@@ -37,20 +36,25 @@ export default class SVCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
37
36
|
|
|
38
37
|
case "imorgon":
|
|
39
38
|
case "imorn":
|
|
40
|
-
|
|
39
|
+
const nextDay = new Date(targetDate.getTime());
|
|
40
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
41
|
+
assignSimilarDate(component, nextDay);
|
|
42
|
+
implySimilarTime(component, nextDay);
|
|
41
43
|
break;
|
|
42
44
|
|
|
43
45
|
case "igår":
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const previousDay = new Date(targetDate.getTime());
|
|
47
|
+
previousDay.setDate(previousDay.getDate() - 1);
|
|
48
|
+
assignSimilarDate(component, previousDay);
|
|
49
|
+
implySimilarTime(component, previousDay);
|
|
47
50
|
break;
|
|
48
51
|
|
|
49
52
|
case "förrgår":
|
|
50
53
|
case "i förrgår":
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
const twoDaysAgo = new Date(targetDate.getTime());
|
|
55
|
+
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2);
|
|
56
|
+
assignSimilarDate(component, twoDaysAgo);
|
|
57
|
+
implySimilarTime(component, twoDaysAgo);
|
|
54
58
|
break;
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, TIME_UNITS_NO_ABBR_PATTERN } from "../constants";
|
|
2
|
+
import { ParsingContext } from "../../../chrono";
|
|
3
|
+
import { ParsingComponents } from "../../../results";
|
|
4
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
|
+
|
|
7
|
+
const PATTERN = new RegExp(
|
|
8
|
+
`(denna|den här|förra|passerade|nästa|kommande|efter|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
9
|
+
"i"
|
|
10
|
+
);
|
|
11
|
+
const PATTERN_NO_ABBR = new RegExp(
|
|
12
|
+
`(denna|den här|förra|passerade|nästa|kommande|efter|\\+|-)\\s*(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`,
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default class SVTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
17
|
+
constructor(private allowAbbreviations: boolean = true) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
innerPattern(): RegExp {
|
|
22
|
+
return this.allowAbbreviations ? PATTERN : PATTERN_NO_ABBR;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
26
|
+
const prefix = match[1].toLowerCase();
|
|
27
|
+
let duration = parseDuration(match[2]);
|
|
28
|
+
if (!duration) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
switch (prefix) {
|
|
33
|
+
case "förra":
|
|
34
|
+
case "passerade":
|
|
35
|
+
case "-":
|
|
36
|
+
duration = reverseDuration(duration);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return ParsingComponents.createRelativeFromReference(context.reference, duration);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OpUnitType, QUnitType } from "dayjs";
|
|
2
1
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
3
2
|
import { findMostLikelyADYear } from "../../calculation/years";
|
|
4
|
-
import {
|
|
3
|
+
import { Duration } from "../../calculation/duration";
|
|
4
|
+
import { Timeunit } from "../../types";
|
|
5
5
|
|
|
6
6
|
export const REGEX_PARTS = {
|
|
7
7
|
leftBoundary: "([^\\p{L}\\p{N}_]|^)",
|
|
@@ -211,7 +211,7 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
211
211
|
"тридцять першого": 31,
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
214
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
215
215
|
сек: "second",
|
|
216
216
|
секунда: "second",
|
|
217
217
|
секунд: "second",
|
|
@@ -240,12 +240,12 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
240
240
|
годинок: "hour",
|
|
241
241
|
годинки: "hour",
|
|
242
242
|
годинку: "hour",
|
|
243
|
-
день: "
|
|
244
|
-
дня: "
|
|
245
|
-
днів: "
|
|
246
|
-
дні: "
|
|
247
|
-
доба: "
|
|
248
|
-
добу: "
|
|
243
|
+
день: "day",
|
|
244
|
+
дня: "day",
|
|
245
|
+
днів: "day",
|
|
246
|
+
дні: "day",
|
|
247
|
+
доба: "day",
|
|
248
|
+
добу: "day",
|
|
249
249
|
тиждень: "week",
|
|
250
250
|
тижню: "week",
|
|
251
251
|
тижня: "week",
|
|
@@ -330,7 +330,7 @@ export const TIME_UNITS_PATTERN = repeatedTimeunitPattern(
|
|
|
330
330
|
SINGLE_TIME_UNIT_PATTERN
|
|
331
331
|
);
|
|
332
332
|
|
|
333
|
-
export function
|
|
333
|
+
export function parseDuration(timeunitText): Duration {
|
|
334
334
|
const fragments = {};
|
|
335
335
|
let remainingText = timeunitText;
|
|
336
336
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -339,7 +339,7 @@ export function parseTimeUnits(timeunitText): TimeUnits {
|
|
|
339
339
|
remainingText = remainingText.substring(match[0].length).trim();
|
|
340
340
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
341
341
|
}
|
|
342
|
-
return fragments;
|
|
342
|
+
return fragments as Duration;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import * as references from "../../../common/casualReferences";
|
|
3
|
-
import { assignSimilarDate } from "../../../utils/
|
|
4
|
-
import dayjs from "dayjs";
|
|
3
|
+
import { assignSimilarDate } from "../../../utils/dates";
|
|
5
4
|
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
6
5
|
|
|
7
6
|
export default class UKCasualTimeParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
@@ -10,7 +9,7 @@ export default class UKCasualTimeParser extends AbstractParserWithLeftRightBound
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
-
let targetDate =
|
|
12
|
+
let targetDate = context.refDate;
|
|
14
13
|
const lowerText = match[0].toLowerCase();
|
|
15
14
|
const component = context.createParsingComponents();
|
|
16
15
|
|
|
@@ -33,9 +32,10 @@ export default class UKCasualTimeParser extends AbstractParserWithLeftRightBound
|
|
|
33
32
|
return references.yesterdayEvening(context.reference);
|
|
34
33
|
}
|
|
35
34
|
if (lowerText.match(/наступної\s*ночі/)) {
|
|
36
|
-
const daysToAdd = targetDate.
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const daysToAdd = targetDate.getHours() < 22 ? 1 : 2;
|
|
36
|
+
const nextDay = new Date(targetDate.getTime());
|
|
37
|
+
nextDay.setDate(nextDay.getDate() + daysToAdd);
|
|
38
|
+
assignSimilarDate(component, nextDay);
|
|
39
39
|
component.imply("hour", 1);
|
|
40
40
|
}
|
|
41
41
|
if (lowerText.match(/цієї\s*ночі/)) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TIME_UNIT_DICTIONARY } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import dayjs from "dayjs";
|
|
5
4
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
6
5
|
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
7
6
|
|
|
@@ -44,32 +43,31 @@ export default class UKRelativeDateFormatParser extends AbstractParserWithLeftRi
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
const components = context.createParsingComponents();
|
|
47
|
-
let date =
|
|
46
|
+
let date = new Date(context.reference.instant.getTime());
|
|
48
47
|
|
|
49
48
|
// This week
|
|
50
49
|
if (timeunit.match(/week/i)) {
|
|
51
|
-
date
|
|
52
|
-
components.imply("day", date.
|
|
53
|
-
components.imply("month", date.
|
|
54
|
-
components.imply("year", date.
|
|
50
|
+
date.setDate(date.getDate() - date.getDay());
|
|
51
|
+
components.imply("day", date.getDate());
|
|
52
|
+
components.imply("month", date.getMonth() + 1);
|
|
53
|
+
components.imply("year", date.getFullYear());
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
// This month
|
|
58
57
|
else if (timeunit.match(/month/i)) {
|
|
59
|
-
date
|
|
60
|
-
components.imply("day", date.
|
|
61
|
-
components.assign("year", date.
|
|
62
|
-
components.assign("month", date.
|
|
58
|
+
date.setDate(1);
|
|
59
|
+
components.imply("day", date.getDate());
|
|
60
|
+
components.assign("year", date.getFullYear());
|
|
61
|
+
components.assign("month", date.getMonth() + 1);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
// This year
|
|
66
65
|
else if (timeunit.match(/year/i)) {
|
|
67
|
-
date
|
|
68
|
-
date
|
|
69
|
-
|
|
70
|
-
components.imply("
|
|
71
|
-
components.
|
|
72
|
-
components.assign("year", date.year());
|
|
66
|
+
date.setDate(1);
|
|
67
|
+
date.setMonth(0);
|
|
68
|
+
components.imply("day", date.getDate());
|
|
69
|
+
components.imply("month", date.getMonth() + 1);
|
|
70
|
+
components.assign("year", date.getFullYear());
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
return components;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import {
|
|
2
|
+
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
5
4
|
import { AbstractParserWithLeftBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
export default class UKTimeUnitAgoFormatParser extends AbstractParserWithLeftBoundaryChecking {
|
|
8
8
|
innerPatternString(context: ParsingContext): string {
|
|
@@ -10,8 +10,8 @@ export default class UKTimeUnitAgoFormatParser extends AbstractParserWithLeftBou
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
-
const timeUnits =
|
|
14
|
-
const outputTimeUnits =
|
|
13
|
+
const timeUnits = parseDuration(match[1]);
|
|
14
|
+
const outputTimeUnits = reverseDuration(timeUnits);
|
|
15
15
|
|
|
16
16
|
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, REGEX_PARTS } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
5
4
|
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
export default class UKTimeUnitCasualRelativeFormatParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
8
8
|
innerPatternString(context: ParsingContext): string {
|
|
@@ -11,12 +11,12 @@ export default class UKTimeUnitCasualRelativeFormatParser extends AbstractParser
|
|
|
11
11
|
|
|
12
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
13
13
|
const prefix = match[1].toLowerCase();
|
|
14
|
-
let timeUnits =
|
|
14
|
+
let timeUnits = parseDuration(match[3]);
|
|
15
15
|
switch (prefix) {
|
|
16
16
|
case "останні":
|
|
17
17
|
case "минулі":
|
|
18
18
|
case "-":
|
|
19
|
-
timeUnits =
|
|
19
|
+
timeUnits = reverseDuration(timeUnits);
|
|
20
20
|
break;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, REGEX_PARTS } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
@@ -17,7 +17,7 @@ export default class UKTimeUnitWithinFormatParser extends AbstractParserWithWord
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
20
|
-
const timeUnits =
|
|
20
|
+
const timeUnits = parseDuration(match[1]);
|
|
21
21
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
22
22
|
}
|
|
23
23
|
}
|