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,8 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
-
import { Meridiem } from "../../../types";
|
|
3
|
+
import { Meridiem, ParsedComponents } from "../../../types";
|
|
4
4
|
import { NUMBER, jaStringToNumber, toHankaku } from "../constants";
|
|
5
|
+
import { ParsingComponents } from "../../../results";
|
|
5
6
|
|
|
6
7
|
const FIRST_REG_PATTERN = new RegExp(
|
|
7
8
|
"(?:" +
|
|
@@ -10,7 +11,7 @@ const FIRST_REG_PATTERN = new RegExp(
|
|
|
10
11
|
"(?:[\\s,,、]*)" +
|
|
11
12
|
"(?:([0-90-9]+|[" +
|
|
12
13
|
Object.keys(NUMBER).join("") +
|
|
13
|
-
"]+)(?:\\s*)(
|
|
14
|
+
"]+)(?:\\s*)(?:時(?!間)|:|:)" +
|
|
14
15
|
"(?:\\s*)" +
|
|
15
16
|
"([0-90-9]+|半|[" +
|
|
16
17
|
Object.keys(NUMBER).join("") +
|
|
@@ -56,96 +57,23 @@ export default class JPTimeExpressionParser extends AbstractParserWithWordBounda
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
59
|
-
// This pattern can be
|
|
60
|
+
// This pattern can be overlapped Ex. [12] AM, 1[2] AM
|
|
60
61
|
if (match.index > 0 && context.text[match.index - 1].match(/\w/)) {
|
|
61
62
|
return null;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
const result = context.createParsingResult(match.index, match[0]);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
second = jaStringToNumber(match[SECOND_GROUP]);
|
|
75
|
-
}
|
|
76
|
-
if (second >= 60) return null;
|
|
77
|
-
result.start.assign("second", second);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
hour = parseInt(toHankaku(match[HOUR_GROUP]));
|
|
81
|
-
if (isNaN(hour)) {
|
|
82
|
-
hour = jaStringToNumber(match[HOUR_GROUP]);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ----- Minutes
|
|
86
|
-
if (match[MINUTE_GROUP]) {
|
|
87
|
-
if (match[MINUTE_GROUP] === "半") {
|
|
88
|
-
minute = 30;
|
|
89
|
-
} else {
|
|
90
|
-
minute = parseInt(toHankaku(match[MINUTE_GROUP]));
|
|
91
|
-
if (isNaN(minute)) {
|
|
92
|
-
minute = jaStringToNumber(match[MINUTE_GROUP]);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
} else if (hour > 100) {
|
|
96
|
-
minute = hour % 100;
|
|
97
|
-
hour = Math.floor(hour / 100);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (minute >= 60) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (hour > 24) {
|
|
66
|
+
result.start = createTimeComponents(
|
|
67
|
+
context,
|
|
68
|
+
match[HOUR_GROUP],
|
|
69
|
+
match[MINUTE_GROUP],
|
|
70
|
+
match[SECOND_GROUP],
|
|
71
|
+
match[AM_PM_HOUR_GROUP_1] ?? match[AM_PM_HOUR_GROUP_2]
|
|
72
|
+
);
|
|
73
|
+
if (!result.start) {
|
|
74
|
+
match.index += match[0].length; // Skip over potential overlapping pattern
|
|
105
75
|
return null;
|
|
106
76
|
}
|
|
107
|
-
if (hour >= 12) {
|
|
108
|
-
meridiem = Meridiem.PM;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// ----- AM & PM
|
|
112
|
-
if (match[AM_PM_HOUR_GROUP_1]) {
|
|
113
|
-
if (hour > 12) return null;
|
|
114
|
-
const AMPMString = match[AM_PM_HOUR_GROUP_1];
|
|
115
|
-
const FirstAMPMString = AMPMString[0].toLowerCase();
|
|
116
|
-
if (AMPMString === "午前" || FirstAMPMString === "a") {
|
|
117
|
-
meridiem = Meridiem.AM;
|
|
118
|
-
if (hour === 12) hour = 0;
|
|
119
|
-
} else if (AMPMString === "午後" || FirstAMPMString === "p") {
|
|
120
|
-
meridiem = Meridiem.PM;
|
|
121
|
-
if (hour != 12) hour += 12;
|
|
122
|
-
}
|
|
123
|
-
} else if (match[AM_PM_HOUR_GROUP_2]) {
|
|
124
|
-
if (hour > 12) return null;
|
|
125
|
-
const ampm = match[AM_PM_HOUR_GROUP_2][0].toLowerCase();
|
|
126
|
-
if (ampm === "a") {
|
|
127
|
-
meridiem = Meridiem.AM;
|
|
128
|
-
if (hour === 12) hour = 0;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (ampm === "p") {
|
|
132
|
-
meridiem = Meridiem.PM;
|
|
133
|
-
if (hour != 12) hour += 12;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
result.start.assign("hour", hour);
|
|
138
|
-
result.start.assign("minute", minute);
|
|
139
|
-
|
|
140
|
-
if (meridiem >= 0) {
|
|
141
|
-
result.start.assign("meridiem", meridiem);
|
|
142
|
-
} else {
|
|
143
|
-
if (hour < 12) {
|
|
144
|
-
result.start.imply("meridiem", 0);
|
|
145
|
-
} else {
|
|
146
|
-
result.start.imply("meridiem", 1);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
77
|
|
|
150
78
|
// =============================================================================================
|
|
151
79
|
// Extracting the 'to' chunk
|
|
@@ -153,129 +81,102 @@ export default class JPTimeExpressionParser extends AbstractParserWithWordBounda
|
|
|
153
81
|
|
|
154
82
|
match = SECOND_REG_PATTERN.exec(context.text.substring(result.index + result.text.length));
|
|
155
83
|
if (!match) {
|
|
156
|
-
// Not accept number only result
|
|
157
|
-
if (result.text.match(/^\d+$/)) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
84
|
return result;
|
|
161
85
|
}
|
|
162
86
|
|
|
163
|
-
result.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
87
|
+
result.text = result.text + match[0];
|
|
88
|
+
result.end = createTimeComponents(
|
|
89
|
+
context,
|
|
90
|
+
match[HOUR_GROUP],
|
|
91
|
+
match[MINUTE_GROUP],
|
|
92
|
+
match[SECOND_GROUP],
|
|
93
|
+
match[AM_PM_HOUR_GROUP_1] ?? match[AM_PM_HOUR_GROUP_2]
|
|
94
|
+
);
|
|
95
|
+
if (!result.end) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (!result.end.isCertain("meridiem") && result.start.isCertain("meridiem")) {
|
|
99
|
+
result.end.imply("meridiem", result.start.get("meridiem"));
|
|
100
|
+
if (result.start.get("meridiem") === Meridiem.PM) {
|
|
101
|
+
if (result.start.get("hour") - 12 > result.end.get("hour")) {
|
|
102
|
+
// 10pm - 1 (am)
|
|
103
|
+
result.end.imply("meridiem", Meridiem.AM);
|
|
104
|
+
} else if (result.end.get("hour") < 12) {
|
|
105
|
+
result.end.assign("hour", result.end.get("hour") + 12);
|
|
106
|
+
}
|
|
174
107
|
}
|
|
175
|
-
|
|
176
|
-
if (second >= 60) return null;
|
|
177
|
-
result.end.assign("second", second);
|
|
178
108
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (isNaN(hour)) {
|
|
182
|
-
hour = jaStringToNumber(match[HOUR_GROUP]);
|
|
109
|
+
if (result.end.date().getTime() < result.start.date().getTime()) {
|
|
110
|
+
result.end.imply("day", result.end.get("day") + 1);
|
|
183
111
|
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
184
115
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
116
|
+
function createTimeComponents(
|
|
117
|
+
context: ParsingContext,
|
|
118
|
+
matchHour: string | null,
|
|
119
|
+
matchMinute: string | null,
|
|
120
|
+
matchSecond: string | null,
|
|
121
|
+
matchAmPm: string | null
|
|
122
|
+
): ParsingComponents | null {
|
|
123
|
+
let hour = 0;
|
|
124
|
+
let meridiem = -1;
|
|
125
|
+
let targetComponents = context.createParsingComponents();
|
|
126
|
+
hour = parseInt(toHankaku(matchHour));
|
|
127
|
+
if (isNaN(hour)) {
|
|
128
|
+
hour = jaStringToNumber(matchHour);
|
|
129
|
+
}
|
|
130
|
+
if (hour > 24) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (matchMinute) {
|
|
135
|
+
let minute: number;
|
|
136
|
+
if (matchMinute === "半") {
|
|
137
|
+
minute = 30;
|
|
138
|
+
} else {
|
|
139
|
+
minute = parseInt(toHankaku(matchMinute));
|
|
140
|
+
if (isNaN(minute)) {
|
|
141
|
+
minute = jaStringToNumber(matchMinute);
|
|
194
142
|
}
|
|
195
|
-
} else if (hour > 100) {
|
|
196
|
-
minute = hour % 100;
|
|
197
|
-
hour = Math.floor(hour / 100);
|
|
198
143
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
144
|
+
if (minute >= 60) return null;
|
|
145
|
+
targetComponents.assign("minute", minute);
|
|
146
|
+
}
|
|
147
|
+
if (matchSecond) {
|
|
148
|
+
let second = parseInt(toHankaku(matchSecond));
|
|
149
|
+
if (isNaN(second)) {
|
|
150
|
+
second = jaStringToNumber(matchSecond);
|
|
202
151
|
}
|
|
152
|
+
if (second >= 60) return null;
|
|
153
|
+
targetComponents.assign("second", second);
|
|
154
|
+
}
|
|
203
155
|
|
|
204
|
-
|
|
156
|
+
if (matchAmPm) {
|
|
157
|
+
if (hour > 12) {
|
|
205
158
|
return null;
|
|
206
159
|
}
|
|
207
|
-
|
|
160
|
+
const AMPMString = matchAmPm;
|
|
161
|
+
if (AMPMString === "午前" || AMPMString[0].toLowerCase() === "a") {
|
|
162
|
+
meridiem = Meridiem.AM;
|
|
163
|
+
if (hour === 12) hour = 0;
|
|
164
|
+
} else if (AMPMString === "午後" || AMPMString[0].toLowerCase() === "p") {
|
|
208
165
|
meridiem = Meridiem.PM;
|
|
166
|
+
if (hour != 12) hour += 12;
|
|
209
167
|
}
|
|
168
|
+
}
|
|
210
169
|
|
|
211
|
-
|
|
212
|
-
if (match[AM_PM_HOUR_GROUP_1]) {
|
|
213
|
-
if (hour > 12) return null;
|
|
214
|
-
const AMPMString = match[AM_PM_HOUR_GROUP_1];
|
|
215
|
-
const FirstAMPMString = AMPMString[0].toLowerCase();
|
|
216
|
-
if (AMPMString === "午前" || FirstAMPMString === "a") {
|
|
217
|
-
meridiem = Meridiem.AM;
|
|
218
|
-
if (hour === 12) hour = 0;
|
|
219
|
-
} else if (AMPMString === "午後" || FirstAMPMString === "p") {
|
|
220
|
-
meridiem = Meridiem.PM;
|
|
221
|
-
if (hour != 12) hour += 12;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (!result.start.isCertain("meridiem")) {
|
|
225
|
-
if (meridiem === Meridiem.AM) {
|
|
226
|
-
result.start.imply("meridiem", Meridiem.AM);
|
|
227
|
-
|
|
228
|
-
if (result.start.get("hour") === 12) {
|
|
229
|
-
result.start.assign("hour", 0);
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
result.start.imply("meridiem", 1);
|
|
233
|
-
|
|
234
|
-
if (result.start.get("hour") != 12) {
|
|
235
|
-
result.start.assign("hour", result.start.get("hour") + 12);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
} else if (match[AM_PM_HOUR_GROUP_2]) {
|
|
240
|
-
if (hour > 12) return null;
|
|
241
|
-
const ampm = match[AM_PM_HOUR_GROUP_2][0].toLowerCase();
|
|
242
|
-
if (ampm === "a") {
|
|
243
|
-
meridiem = Meridiem.AM;
|
|
244
|
-
if (hour === 12) hour = 0;
|
|
245
|
-
}
|
|
170
|
+
targetComponents.assign("hour", hour);
|
|
246
171
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
result.text = result.text + match[0];
|
|
254
|
-
result.end.assign("hour", hour);
|
|
255
|
-
result.end.assign("minute", minute);
|
|
256
|
-
if (meridiem >= 0) {
|
|
257
|
-
result.end.assign("meridiem", meridiem);
|
|
172
|
+
if (meridiem >= 0) {
|
|
173
|
+
targetComponents.assign("meridiem", meridiem);
|
|
174
|
+
} else {
|
|
175
|
+
if (hour < 12) {
|
|
176
|
+
targetComponents.imply("meridiem", Meridiem.AM);
|
|
258
177
|
} else {
|
|
259
|
-
|
|
260
|
-
if (startAtPM) {
|
|
261
|
-
if (result.start.get("hour") - 12 > hour) {
|
|
262
|
-
// 10pm - 1 (am)
|
|
263
|
-
result.end.imply("meridiem", Meridiem.AM);
|
|
264
|
-
} else if (hour <= 12) {
|
|
265
|
-
result.end.assign("hour", hour + 12);
|
|
266
|
-
result.end.assign("meridiem", Meridiem.PM);
|
|
267
|
-
}
|
|
268
|
-
} else if (hour > 12) {
|
|
269
|
-
result.end.imply("meridiem", Meridiem.PM);
|
|
270
|
-
} else if (hour <= 12) {
|
|
271
|
-
result.end.imply("meridiem", Meridiem.AM);
|
|
272
|
-
}
|
|
178
|
+
targetComponents.imply("meridiem", Meridiem.PM);
|
|
273
179
|
}
|
|
274
|
-
|
|
275
|
-
if (result.end.date().getTime() < result.start.date().getTime()) {
|
|
276
|
-
result.end.imply("day", result.end.get("day") + 1);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return result;
|
|
280
180
|
}
|
|
181
|
+
return targetComponents;
|
|
281
182
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OpUnitType } 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
|
// Zondag
|
|
@@ -136,7 +136,7 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
136
136
|
"eenendertigste": 31,
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
export const TIME_UNIT_DICTIONARY: { [word: string]:
|
|
139
|
+
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
140
140
|
sec: "second",
|
|
141
141
|
second: "second",
|
|
142
142
|
seconden: "second",
|
|
@@ -152,8 +152,8 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType } = {
|
|
|
152
152
|
uur: "hour",
|
|
153
153
|
u: "hour",
|
|
154
154
|
uren: "hour",
|
|
155
|
-
dag: "
|
|
156
|
-
dagen: "
|
|
155
|
+
dag: "day",
|
|
156
|
+
dagen: "day",
|
|
157
157
|
week: "week",
|
|
158
158
|
weken: "week",
|
|
159
159
|
maand: "month",
|
|
@@ -220,7 +220,7 @@ const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
|
220
220
|
|
|
221
221
|
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern(`(?:(?:binnen|in)\\s*)?`, SINGLE_TIME_UNIT_PATTERN);
|
|
222
222
|
|
|
223
|
-
export function
|
|
223
|
+
export function parseDuration(timeunitText): Duration {
|
|
224
224
|
const fragments = {};
|
|
225
225
|
let remainingText = timeunitText;
|
|
226
226
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -229,7 +229,7 @@ export function parseTimeUnits(timeunitText): TimeUnits {
|
|
|
229
229
|
remainingText = remainingText.substring(match[0].length);
|
|
230
230
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
231
231
|
}
|
|
232
|
-
return fragments;
|
|
232
|
+
return fragments as Duration;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
function collectDateTimeFragment(fragments, match) {
|
|
@@ -2,8 +2,7 @@ import { ParsingContext } from "../../../chrono";
|
|
|
2
2
|
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
3
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
4
|
import { Meridiem } from "../../../types";
|
|
5
|
-
import { assignSimilarDate,
|
|
6
|
-
import dayjs from "dayjs";
|
|
5
|
+
import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
|
|
7
6
|
|
|
8
7
|
/*
|
|
9
8
|
* Find combined words
|
|
@@ -36,17 +35,22 @@ export default class NLCasualDateTimeParser extends AbstractParserWithWordBounda
|
|
|
36
35
|
const dateText = match[DATE_GROUP].toLowerCase();
|
|
37
36
|
const timeText = match[TIME_OF_DAY_GROUP].toLowerCase();
|
|
38
37
|
const component = context.createParsingComponents();
|
|
39
|
-
const targetDate =
|
|
38
|
+
const targetDate = context.refDate;
|
|
40
39
|
|
|
41
40
|
switch (dateText) {
|
|
42
41
|
case "gisteren":
|
|
43
|
-
|
|
42
|
+
const previousDay = new Date(targetDate.getTime());
|
|
43
|
+
previousDay.setDate(previousDay.getDate() - 1);
|
|
44
|
+
assignSimilarDate(component, previousDay);
|
|
44
45
|
break;
|
|
45
46
|
case "van":
|
|
46
47
|
assignSimilarDate(component, targetDate);
|
|
47
48
|
break;
|
|
48
49
|
case "morgen":
|
|
49
|
-
|
|
50
|
+
const nextDay = new Date(targetDate.getTime());
|
|
51
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
52
|
+
assignSimilarDate(component, nextDay);
|
|
53
|
+
implySimilarTime(component, nextDay);
|
|
50
54
|
break;
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -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 { assignTheNextDay } from "../../../utils/dayjs";
|
|
4
|
+
import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
|
|
6
5
|
|
|
7
6
|
const DAY_GROUP = 1;
|
|
8
7
|
const MOMENT_GROUP = 2;
|
|
@@ -13,7 +12,7 @@ export default class NLCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
16
|
-
const targetDate =
|
|
15
|
+
const targetDate = context.refDate;
|
|
17
16
|
const component = context.createParsingComponents();
|
|
18
17
|
|
|
19
18
|
if (match[DAY_GROUP] === "deze") {
|
|
@@ -36,7 +35,10 @@ export default class NLCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
36
35
|
break;
|
|
37
36
|
|
|
38
37
|
case "middernacht":
|
|
39
|
-
|
|
38
|
+
const nextDay = new Date(targetDate.getTime());
|
|
39
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
40
|
+
assignSimilarDate(component, nextDay);
|
|
41
|
+
implySimilarTime(component, nextDay);
|
|
40
42
|
component.imply("hour", 0);
|
|
41
43
|
component.imply("minute", 0);
|
|
42
44
|
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
|
|
|
@@ -37,32 +36,31 @@ export default class NLRelativeDateFormatParser extends AbstractParserWithWordBo
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
const components = context.createParsingComponents();
|
|
40
|
-
let date =
|
|
39
|
+
let date = new Date(context.reference.instant.getTime());
|
|
41
40
|
|
|
42
41
|
// This week
|
|
43
42
|
if (unitWord.match(/week/i)) {
|
|
44
|
-
date
|
|
45
|
-
components.imply("day", date.
|
|
46
|
-
components.imply("month", date.
|
|
47
|
-
components.imply("year", date.
|
|
43
|
+
date.setDate(date.getDate() - date.getDay());
|
|
44
|
+
components.imply("day", date.getDate());
|
|
45
|
+
components.imply("month", date.getMonth() + 1);
|
|
46
|
+
components.imply("year", date.getFullYear());
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
// This month
|
|
51
50
|
else if (unitWord.match(/maand/i)) {
|
|
52
|
-
date
|
|
53
|
-
components.imply("day", date.
|
|
54
|
-
components.assign("year", date.
|
|
55
|
-
components.assign("month", date.
|
|
51
|
+
date.setDate(1);
|
|
52
|
+
components.imply("day", date.getDate());
|
|
53
|
+
components.assign("year", date.getFullYear());
|
|
54
|
+
components.assign("month", date.getMonth() + 1);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
// This year
|
|
59
58
|
else if (unitWord.match(/jaar/i)) {
|
|
60
|
-
date
|
|
61
|
-
date
|
|
62
|
-
|
|
63
|
-
components.imply("
|
|
64
|
-
components.
|
|
65
|
-
components.assign("year", date.year());
|
|
59
|
+
date.setDate(1);
|
|
60
|
+
date.setMonth(0);
|
|
61
|
+
components.imply("day", date.getDate());
|
|
62
|
+
components.imply("month", date.getMonth() + 1);
|
|
63
|
+
components.assign("year", date.getFullYear());
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
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 + ")" + "(?:geleden|voor|eerder)(?=(?:\\W|$))", "i");
|
|
8
8
|
|
|
@@ -18,8 +18,8 @@ export default class NLTimeUnitAgoFormatParser extends AbstractParserWithWordBou
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
21
|
-
const timeUnits =
|
|
22
|
-
const outputTimeUnits =
|
|
21
|
+
const timeUnits = parseDuration(match[1]);
|
|
22
|
+
const outputTimeUnits = reverseDuration(timeUnits);
|
|
23
23
|
|
|
24
24
|
return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
|
|
25
25
|
}
|
|
@@ -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
|
`(dit|deze|vorig|afgelopen|(?:aan)?komend|over|\\+|-)e?\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
@@ -19,12 +19,12 @@ export default class NLTimeUnitCasualRelativeFormatParser extends AbstractParser
|
|
|
19
19
|
|
|
20
20
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
21
21
|
const prefix = match[PREFIX_WORD_GROUP].toLowerCase();
|
|
22
|
-
let timeUnits =
|
|
22
|
+
let timeUnits = parseDuration(match[TIME_UNIT_WORD_GROUP]);
|
|
23
23
|
switch (prefix) {
|
|
24
24
|
case "vorig":
|
|
25
25
|
case "afgelopen":
|
|
26
26
|
case "-":
|
|
27
|
-
timeUnits =
|
|
27
|
+
timeUnits = reverseDuration(timeUnits);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -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 NLTimeUnitLaterFormatParser 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";
|
|
@@ -9,7 +9,7 @@ export default class NLTimeUnitWithinFormatParser 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,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 PTCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
8
7
|
innerPattern() {
|
|
@@ -10,7 +9,7 @@ export default class PTCasualTimeParser 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":
|
|
@@ -30,7 +29,10 @@ export default class PTCasualTimeParser extends AbstractParserWithWordBoundaryCh
|
|
|
30
29
|
break;
|
|
31
30
|
|
|
32
31
|
case "meia-noite":
|
|
33
|
-
|
|
32
|
+
const nextDay = new Date(targetDate.getTime());
|
|
33
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
34
|
+
assignSimilarDate(component, nextDay);
|
|
35
|
+
implySimilarTime(component, nextDay);
|
|
34
36
|
component.imply("hour", 0);
|
|
35
37
|
component.imply("minute", 0);
|
|
36
38
|
component.imply("second", 0);
|