chrono-node 2.8.3 → 2.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/chrono.js +1 -1
- package/dist/cjs/chrono.js.map +1 -1
- package/dist/cjs/common/casualReferences.js +25 -27
- 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 +4 -4
- package/dist/cjs/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js.map +1 -1
- package/dist/cjs/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js +2 -2
- 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 +4 -4
- 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 +29 -0
- package/dist/cjs/locales/sv/constants.js +224 -0
- package/dist/cjs/locales/sv/constants.js.map +1 -0
- package/dist/cjs/locales/sv/index.d.ts +11 -0
- package/dist/cjs/locales/sv/index.js +52 -0
- package/dist/cjs/locales/sv/index.js.map +1 -0
- package/dist/cjs/locales/sv/parsers/SVCasualDateParser.d.ts +7 -0
- package/dist/cjs/locales/sv/parsers/SVCasualDateParser.js +135 -0
- package/dist/cjs/locales/sv/parsers/SVCasualDateParser.js.map +1 -0
- package/dist/cjs/locales/sv/parsers/SVMonthNameLittleEndianParser.d.ts +7 -0
- package/dist/cjs/locales/sv/parsers/SVMonthNameLittleEndianParser.js +49 -0
- package/dist/cjs/locales/sv/parsers/SVMonthNameLittleEndianParser.js.map +1 -0
- 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/sv/parsers/SVWeekdayParser.d.ts +7 -0
- package/dist/cjs/locales/sv/parsers/SVWeekdayParser.js +40 -0
- package/dist/cjs/locales/sv/parsers/SVWeekdayParser.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 +7 -4
- package/dist/cjs/results.js +86 -59
- 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/chrono.js +1 -1
- package/dist/esm/chrono.js.map +1 -1
- package/dist/esm/common/casualReferences.js +18 -17
- 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 +5 -5
- package/dist/esm/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js.map +1 -1
- package/dist/esm/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js +3 -3
- 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 +5 -5
- 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 +29 -0
- package/dist/esm/locales/sv/constants.js +217 -0
- package/dist/esm/locales/sv/constants.js.map +1 -0
- package/dist/esm/locales/sv/index.d.ts +11 -0
- package/dist/esm/locales/sv/index.js +38 -0
- package/dist/esm/locales/sv/index.js.map +1 -0
- package/dist/esm/locales/sv/parsers/SVCasualDateParser.d.ts +7 -0
- package/dist/esm/locales/sv/parsers/SVCasualDateParser.js +99 -0
- package/dist/esm/locales/sv/parsers/SVCasualDateParser.js.map +1 -0
- package/dist/esm/locales/sv/parsers/SVMonthNameLittleEndianParser.d.ts +7 -0
- package/dist/esm/locales/sv/parsers/SVMonthNameLittleEndianParser.js +46 -0
- package/dist/esm/locales/sv/parsers/SVMonthNameLittleEndianParser.js.map +1 -0
- 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/sv/parsers/SVWeekdayParser.d.ts +7 -0
- package/dist/esm/locales/sv/parsers/SVWeekdayParser.js +37 -0
- package/dist/esm/locales/sv/parsers/SVWeekdayParser.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 +7 -4
- package/dist/esm/results.js +87 -60
- 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 +1 -1
- 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/chrono.ts +2 -2
- package/src/common/casualReferences.ts +19 -23
- 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 +5 -5
- package/src/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.ts +3 -3
- 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 +5 -5
- 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 +237 -0
- package/src/locales/sv/index.ts +47 -0
- package/src/locales/sv/parsers/SVCasualDateParser.ts +118 -0
- package/src/locales/sv/parsers/SVMonthNameLittleEndianParser.ts +59 -0
- package/src/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.ts +42 -0
- package/src/locales/sv/parsers/SVWeekdayParser.ts +47 -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 +97 -59
- 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 +78 -4
- package/test/sv/sv_casual.test.ts +87 -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/sv/sv_weekday.test.ts +68 -0
- package/test/system_timezone.test.ts +36 -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,5 +1,5 @@
|
|
|
1
|
-
import { OpUnitType, QUnitType } from "dayjs";
|
|
2
1
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
2
|
+
import { Timeunit } from "../../types";
|
|
3
3
|
|
|
4
4
|
export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
|
|
5
5
|
"domingo": 0,
|
|
@@ -78,7 +78,7 @@ export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
78
78
|
"trece": 13,
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
81
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
82
82
|
"sec": "second",
|
|
83
83
|
"segundo": "second",
|
|
84
84
|
"segundos": "second",
|
|
@@ -91,8 +91,8 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
91
91
|
"hrs": "hour",
|
|
92
92
|
"hora": "hour",
|
|
93
93
|
"horas": "hour",
|
|
94
|
-
"día": "
|
|
95
|
-
"días": "
|
|
94
|
+
"día": "day",
|
|
95
|
+
"días": "day",
|
|
96
96
|
"semana": "week",
|
|
97
97
|
"semanas": "week",
|
|
98
98
|
"mes": "month",
|
|
@@ -155,7 +155,8 @@ const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
|
155
155
|
|
|
156
156
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
import { Duration } from "../../calculation/duration";
|
|
159
|
+
export function parseDuration(timeunitText): Duration {
|
|
159
160
|
const fragments = {};
|
|
160
161
|
let remainingText = timeunitText;
|
|
161
162
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -164,7 +165,7 @@ export function parseTimeUnits(timeunitText): { [c in OpUnitType | QUnitType]?:
|
|
|
164
165
|
remainingText = remainingText.substring(match[0].length);
|
|
165
166
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
166
167
|
}
|
|
167
|
-
return fragments as
|
|
168
|
+
return fragments as Duration;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { Meridiem } from "../../../types";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
-
import {
|
|
5
|
-
import dayjs from "dayjs";
|
|
4
|
+
import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
|
|
6
5
|
|
|
7
6
|
export default class ESCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
8
7
|
innerPattern() {
|
|
@@ -10,7 +9,7 @@ export default class ESCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
-
const targetDate =
|
|
12
|
+
const targetDate = context.refDate;
|
|
14
13
|
const component = context.createParsingComponents();
|
|
15
14
|
switch (match[1].toLowerCase()) {
|
|
16
15
|
case "tarde":
|
|
@@ -29,7 +28,10 @@ export default class ESCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
29
28
|
break;
|
|
30
29
|
|
|
31
30
|
case "medianoche":
|
|
32
|
-
|
|
31
|
+
const nextDay = new Date(targetDate.getTime());
|
|
32
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
33
|
+
assignSimilarDate(component, nextDay);
|
|
34
|
+
implySimilarTime(component, nextDay);
|
|
33
35
|
component.imply("hour", 0);
|
|
34
36
|
component.imply("minute", 0);
|
|
35
37
|
component.imply("second", 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
@@ -9,7 +9,7 @@ export default class ESTimeUnitWithinFormatParser extends AbstractParserWithWord
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
12
|
-
const timeUnits =
|
|
12
|
+
const timeUnits = parseDuration(match[1]);
|
|
13
13
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OpUnitType, QUnitType } from "dayjs";
|
|
2
1
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
2
|
+
import { Timeunit } from "../../types";
|
|
3
3
|
|
|
4
4
|
export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
|
|
5
5
|
"dimanche": 0,
|
|
@@ -76,7 +76,7 @@ export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
76
76
|
"treize": 13,
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
79
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
80
80
|
"sec": "second",
|
|
81
81
|
"seconde": "second",
|
|
82
82
|
"secondes": "second",
|
|
@@ -89,8 +89,8 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
89
89
|
"hrs": "hour",
|
|
90
90
|
"heure": "hour",
|
|
91
91
|
"heures": "hour",
|
|
92
|
-
"jour": "
|
|
93
|
-
"jours": "
|
|
92
|
+
"jour": "day",
|
|
93
|
+
"jours": "day",
|
|
94
94
|
"semaine": "week",
|
|
95
95
|
"semaines": "week",
|
|
96
96
|
"mois": "month",
|
|
@@ -165,7 +165,8 @@ const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
|
165
165
|
|
|
166
166
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
import { Duration } from "../../calculation/duration";
|
|
169
|
+
export function parseDuration(timeunitText): Duration {
|
|
169
170
|
const fragments = {};
|
|
170
171
|
let remainingText = timeunitText;
|
|
171
172
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -174,7 +175,7 @@ export function parseTimeUnits(timeunitText): { [c in OpUnitType | QUnitType]?:
|
|
|
174
175
|
remainingText = remainingText.substring(match[0].length);
|
|
175
176
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
176
177
|
}
|
|
177
|
-
return fragments as
|
|
178
|
+
return fragments as Duration;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
-
import dayjs from "dayjs";
|
|
4
3
|
import { Meridiem } from "../../../types";
|
|
5
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
|
-
import { assignSimilarDate } from "../../../utils/
|
|
5
|
+
import { assignSimilarDate } from "../../../utils/dates";
|
|
7
6
|
import * as references from "../../../common/casualReferences";
|
|
8
7
|
|
|
9
8
|
export default class FRCasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
@@ -12,7 +11,7 @@ export default class FRCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
15
|
-
|
|
14
|
+
const targetDate = context.refDate;
|
|
16
15
|
const lowerText = match[0].toLowerCase();
|
|
17
16
|
const component = context.createParsingComponents();
|
|
18
17
|
|
|
@@ -35,8 +34,9 @@ export default class FRCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
35
34
|
component.imply("hour", 22);
|
|
36
35
|
component.imply("meridiem", Meridiem.PM);
|
|
37
36
|
} else if (lowerText.match(/la\s*veille/)) {
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const previousDay = new Date(targetDate.getTime());
|
|
38
|
+
previousDay.setDate(previousDay.getDate() - 1);
|
|
39
|
+
assignSimilarDate(component, previousDay);
|
|
40
40
|
component.imply("hour", 0);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -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
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
-
import {
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
export default class FRTimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
8
8
|
constructor() {
|
|
@@ -14,8 +14,8 @@ export default class FRTimeUnitAgoFormatParser extends AbstractParserWithWordBou
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
17
|
-
const timeUnits =
|
|
18
|
-
const outputTimeUnits =
|
|
17
|
+
const timeUnits = parseDuration(match[1]);
|
|
18
|
+
const outputTimeUnits = reverseDuration(timeUnits);
|
|
19
19
|
|
|
20
20
|
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
21
21
|
}
|
|
@@ -2,8 +2,8 @@ import { ParsingContext } from "../../../chrono";
|
|
|
2
2
|
import { NUMBER_PATTERN, parseNumberPattern, TIME_UNIT_DICTIONARY } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
-
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
6
5
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
6
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
7
7
|
|
|
8
8
|
export default class FRTimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
9
9
|
constructor() {
|
|
@@ -35,7 +35,7 @@ export default class FRTimeUnitAgoFormatParser extends AbstractParserWithWordBou
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
if (/derni[eè]re?s?/.test(modifier) || /pass[ée]e?s?/.test(modifier) || /pr[ée]c[ée]dents?/.test(modifier)) {
|
|
38
|
-
timeUnits =
|
|
38
|
+
timeUnits = reverseDuration(timeUnits);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
@@ -9,7 +9,7 @@ export default class FRTimeUnitWithinFormatParser extends AbstractParserWithWord
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
12
|
-
const timeUnits =
|
|
12
|
+
const timeUnits = parseDuration(match[1]);
|
|
13
13
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -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
|
"domenica": 0,
|
|
@@ -115,7 +115,7 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
115
115
|
"trentunesimo": 31,
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
118
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
119
119
|
"sec": "second",
|
|
120
120
|
"secondo": "second",
|
|
121
121
|
"secondi": "second",
|
|
@@ -127,8 +127,8 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
127
127
|
"o": "hour",
|
|
128
128
|
"ora": "hour",
|
|
129
129
|
"ore": "hour",
|
|
130
|
-
"giorno": "
|
|
131
|
-
"giorni": "
|
|
130
|
+
"giorno": "day",
|
|
131
|
+
"giorni": "day",
|
|
132
132
|
"settimana": "week",
|
|
133
133
|
"settimane": "week",
|
|
134
134
|
"mese": "month",
|
|
@@ -211,7 +211,7 @@ const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
|
211
211
|
|
|
212
212
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern(`(?:(?:about|around)\\s{0,3})?`, SINGLE_TIME_UNIT_PATTERN);
|
|
213
213
|
|
|
214
|
-
export function
|
|
214
|
+
export function parseDuration(timeunitText): Duration {
|
|
215
215
|
const fragments = {};
|
|
216
216
|
let remainingText = timeunitText;
|
|
217
217
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -220,7 +220,7 @@ export function parseTimeUnits(timeunitText): TimeUnits {
|
|
|
220
220
|
remainingText = remainingText.substring(match[0].length).trim();
|
|
221
221
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
222
222
|
}
|
|
223
|
-
return fragments;
|
|
223
|
+
return fragments as Duration;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -1,19 +1,18 @@
|
|
|
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 } from "../../../utils/
|
|
4
|
+
import { assignSimilarDate } from "../../../utils/dates";
|
|
6
5
|
import * as references from "../../../common/casualReferences";
|
|
7
6
|
|
|
8
7
|
const PATTERN = /(ora|oggi|stasera|questa sera|domani|dmn|ieri\s*sera)(?=\W|$)/i;
|
|
9
8
|
|
|
10
|
-
export default class
|
|
9
|
+
export default class ITCasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
11
10
|
innerPattern(context: ParsingContext): RegExp {
|
|
12
11
|
return PATTERN;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
16
|
-
let targetDate =
|
|
15
|
+
let targetDate = context.refDate;
|
|
17
16
|
const lowerText = match[0].toLowerCase();
|
|
18
17
|
const component = context.createParsingComponents();
|
|
19
18
|
|
|
@@ -37,8 +36,10 @@ export default class ENCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
37
36
|
|
|
38
37
|
default:
|
|
39
38
|
if (lowerText.match(/ieri\s*sera/)) {
|
|
40
|
-
if (targetDate.
|
|
41
|
-
|
|
39
|
+
if (targetDate.getHours() > 6) {
|
|
40
|
+
const previousDay = new Date(targetDate.getTime());
|
|
41
|
+
previousDay.setDate(previousDay.getDate() - 1);
|
|
42
|
+
targetDate = previousDay;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
assignSimilarDate(component, targetDate);
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { Meridiem } from "../../../index";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
-
import
|
|
5
|
-
import { assignTheNextDay } from "../../../utils/dayjs";
|
|
4
|
+
import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
|
|
6
5
|
|
|
7
6
|
const PATTERN = /(?:questo|questa)?\s{0,3}(mattina|pomeriggio|sera|notte|mezzanotte|mezzogiorno)(?=\W|$)/i;
|
|
8
7
|
|
|
9
|
-
export default class
|
|
8
|
+
export default class ITCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
10
9
|
innerPattern() {
|
|
11
10
|
return PATTERN;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
15
|
-
const targetDate =
|
|
14
|
+
const targetDate = context.refDate;
|
|
16
15
|
const component = context.createParsingComponents();
|
|
17
16
|
|
|
18
17
|
switch (match[1].toLowerCase()) {
|
|
@@ -28,7 +27,10 @@ export default class ENCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
28
27
|
break;
|
|
29
28
|
|
|
30
29
|
case "mezzanotte":
|
|
31
|
-
|
|
30
|
+
const nextDay = new Date(targetDate.getTime());
|
|
31
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
32
|
+
assignSimilarDate(component, nextDay);
|
|
33
|
+
implySimilarTime(component, nextDay);
|
|
32
34
|
component.imply("hour", 0);
|
|
33
35
|
component.imply("minute", 0);
|
|
34
36
|
component.imply("second", 0);
|
|
@@ -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 { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
5
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
6
|
|
|
@@ -38,32 +37,31 @@ export default class ITRelativeDateFormatParser extends AbstractParserWithWordBo
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
const components = context.createParsingComponents();
|
|
41
|
-
let date =
|
|
40
|
+
let date = new Date(context.reference.instant.getTime());
|
|
42
41
|
|
|
43
42
|
// This week
|
|
44
43
|
if (unitWord.match(/settimana/i)) {
|
|
45
|
-
date
|
|
46
|
-
components.imply("day", date.
|
|
47
|
-
components.imply("month", date.
|
|
48
|
-
components.imply("year", date.
|
|
44
|
+
date.setDate(date.getDate() - date.getDay());
|
|
45
|
+
components.imply("day", date.getDate());
|
|
46
|
+
components.imply("month", date.getMonth() + 1);
|
|
47
|
+
components.imply("year", date.getFullYear());
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
// This month
|
|
52
51
|
else if (unitWord.match(/mese/i)) {
|
|
53
|
-
date
|
|
54
|
-
components.imply("day", date.
|
|
55
|
-
components.assign("year", date.
|
|
56
|
-
components.assign("month", date.
|
|
52
|
+
date.setDate(1);
|
|
53
|
+
components.imply("day", date.getDate());
|
|
54
|
+
components.assign("year", date.getFullYear());
|
|
55
|
+
components.assign("month", date.getMonth() + 1);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
// This year
|
|
60
59
|
else if (unitWord.match(/anno/i)) {
|
|
61
|
-
date
|
|
62
|
-
date
|
|
63
|
-
|
|
64
|
-
components.imply("
|
|
65
|
-
components.
|
|
66
|
-
components.assign("year", date.year());
|
|
60
|
+
date.setDate(1);
|
|
61
|
+
date.setMonth(0);
|
|
62
|
+
components.imply("day", date.getDate());
|
|
63
|
+
components.imply("month", date.getMonth() + 1);
|
|
64
|
+
components.assign("year", date.getFullYear());
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
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
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
-
import {
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
const PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:fa|prima|precedente)(?=(?:\\W|$))`, "i");
|
|
8
8
|
const STRICT_PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}fa(?=(?:\\W|$))`, "i");
|
|
@@ -17,8 +17,8 @@ export default class ENTimeUnitAgoFormatParser extends AbstractParserWithWordBou
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
20
|
-
const timeUnits =
|
|
21
|
-
const outputTimeUnits =
|
|
20
|
+
const timeUnits = parseDuration(match[1]);
|
|
21
|
+
const outputTimeUnits = reverseDuration(timeUnits);
|
|
22
22
|
|
|
23
23
|
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
24
24
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
|
-
import {
|
|
5
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
const PATTERN = new RegExp(
|
|
8
8
|
`(questo|ultimo|passato|prossimo|dopo|questa|ultima|passata|prossima|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
@@ -16,12 +16,12 @@ export default class ENTimeUnitCasualRelativeFormatParser extends AbstractParser
|
|
|
16
16
|
|
|
17
17
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
18
18
|
const prefix = match[1].toLowerCase();
|
|
19
|
-
let timeUnits =
|
|
19
|
+
let timeUnits = parseDuration(match[2]);
|
|
20
20
|
switch (prefix) {
|
|
21
21
|
case "last":
|
|
22
22
|
case "past":
|
|
23
23
|
case "-":
|
|
24
|
-
timeUnits =
|
|
24
|
+
timeUnits = reverseDuration(timeUnits);
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import {
|
|
2
|
+
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
@@ -21,7 +21,7 @@ export default class ENTimeUnitLaterFormatParser extends AbstractParserWithWordB
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
24
|
-
const fragments =
|
|
24
|
+
const fragments = parseDuration(match[GROUP_NUM_TIMEUNITS]);
|
|
25
25
|
return ParsingComponents.createRelativeFromReference(context.reference, fragments);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN,
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
@@ -20,7 +20,7 @@ export default class ENTimeUnitWithinFormatParser extends AbstractParserWithWord
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
23
|
-
const timeUnits =
|
|
23
|
+
const timeUnits = parseDuration(match[1]);
|
|
24
24
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MergingRefiner } from "../../../common/abstractRefiners";
|
|
2
2
|
import { ParsingComponents, ParsingResult, ReferenceWithTimezone } from "../../../results";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { parseDuration } from "../constants";
|
|
4
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
5
5
|
|
|
6
6
|
function hasImpliedEarlierReferenceDate(result: ParsingResult): boolean {
|
|
7
7
|
return result.text.match(/\s+(prima|dal)$/i) != null;
|
|
@@ -38,13 +38,13 @@ export default class ENMergeRelativeDateRefiner extends MergingRefiner {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
mergeResults(textBetween: string, currentResult: ParsingResult, nextResult: ParsingResult): ParsingResult {
|
|
41
|
-
let timeUnits =
|
|
41
|
+
let timeUnits = parseDuration(currentResult.text);
|
|
42
42
|
if (hasImpliedEarlierReferenceDate(currentResult)) {
|
|
43
|
-
timeUnits =
|
|
43
|
+
timeUnits = reverseDuration(timeUnits);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const components = ParsingComponents.createRelativeFromReference(
|
|
47
|
-
|
|
47
|
+
ReferenceWithTimezone.fromDate(nextResult.start.date()),
|
|
48
48
|
timeUnits
|
|
49
49
|
);
|
|
50
50
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Parser, ParsingContext } from "../../../chrono";
|
|
2
|
-
import dayjs from "dayjs";
|
|
3
2
|
import { Meridiem } from "../../../types";
|
|
4
3
|
import * as references from "../../../common/casualReferences";
|
|
5
4
|
|
|
@@ -36,7 +35,6 @@ export default class JPCasualDateParser implements Parser {
|
|
|
36
35
|
extract(context: ParsingContext, match: RegExpMatchArray) {
|
|
37
36
|
const text = normalizeTextToKanji(match[0]);
|
|
38
37
|
|
|
39
|
-
const date = dayjs(context.refDate);
|
|
40
38
|
const components = context.createParsingComponents();
|
|
41
39
|
|
|
42
40
|
switch (text) {
|
|
@@ -59,9 +57,10 @@ export default class JPCasualDateParser implements Parser {
|
|
|
59
57
|
components.assign("meridiem", Meridiem.AM);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
components.assign("
|
|
64
|
-
components.assign("
|
|
60
|
+
const date = context.refDate;
|
|
61
|
+
components.assign("day", date.getDate());
|
|
62
|
+
components.assign("month", date.getMonth() + 1);
|
|
63
|
+
components.assign("year", date.getFullYear());
|
|
65
64
|
return components;
|
|
66
65
|
}
|
|
67
66
|
}
|
|
@@ -2,8 +2,6 @@ import { Parser, ParsingContext } from "../../../chrono";
|
|
|
2
2
|
import { toHankaku } from "../constants";
|
|
3
3
|
import { findYearClosestToRef } from "../../../calculation/years";
|
|
4
4
|
|
|
5
|
-
import dayjs from "dayjs";
|
|
6
|
-
|
|
7
5
|
const PATTERN =
|
|
8
6
|
/(?:(?:([同今本])|((昭和|平成|令和)?([0-90-9]{1,4}|元)))年\s*)?([0-90-9]{1,2})月\s*([0-90-9]{1,2})日/i;
|
|
9
7
|
const SPECIAL_YEAR_GROUP = 1;
|
|
@@ -27,8 +25,7 @@ export default class JPStandardParser implements Parser {
|
|
|
27
25
|
});
|
|
28
26
|
|
|
29
27
|
if (match[SPECIAL_YEAR_GROUP] && match[SPECIAL_YEAR_GROUP].match("同|今|本")) {
|
|
30
|
-
|
|
31
|
-
components.assign("year", moment.year());
|
|
28
|
+
components.assign("year", context.reference.getDateWithAdjustedTimezone().getFullYear());
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
if (match[TYPICAL_YEAR_GROUP]) {
|