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,4 +1,3 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
1
|
import { ParsingContext } from "../../../../chrono";
|
|
3
2
|
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
3
|
import { NUMBER, zhStringToNumber } from "../constants";
|
|
@@ -74,54 +73,53 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
74
73
|
return null;
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
const refMoment = dayjs(context.refDate);
|
|
78
76
|
const result = context.createParsingResult(match.index, match[0]);
|
|
79
|
-
|
|
77
|
+
const startMoment = new Date(context.refDate.getTime());
|
|
80
78
|
|
|
81
79
|
// ----- Day
|
|
82
80
|
if (match[DAY_GROUP_1]) {
|
|
83
|
-
|
|
81
|
+
const day1 = match[DAY_GROUP_1];
|
|
84
82
|
if (day1 == "明" || day1 == "聽") {
|
|
85
83
|
// Check not "Tomorrow" on late night
|
|
86
|
-
if (
|
|
87
|
-
startMoment
|
|
84
|
+
if (context.refDate.getHours() > 1) {
|
|
85
|
+
startMoment.setDate(startMoment.getDate() + 1);
|
|
88
86
|
}
|
|
89
87
|
} else if (day1 == "昨" || day1 == "尋" || day1 == "琴") {
|
|
90
|
-
startMoment
|
|
88
|
+
startMoment.setDate(startMoment.getDate() - 1);
|
|
91
89
|
} else if (day1 == "前") {
|
|
92
|
-
startMoment
|
|
90
|
+
startMoment.setDate(startMoment.getDate() - 2);
|
|
93
91
|
} else if (day1 == "大前") {
|
|
94
|
-
startMoment
|
|
92
|
+
startMoment.setDate(startMoment.getDate() - 3);
|
|
95
93
|
} else if (day1 == "後") {
|
|
96
|
-
startMoment
|
|
94
|
+
startMoment.setDate(startMoment.getDate() + 2);
|
|
97
95
|
} else if (day1 == "大後") {
|
|
98
|
-
startMoment
|
|
96
|
+
startMoment.setDate(startMoment.getDate() + 3);
|
|
99
97
|
}
|
|
100
|
-
result.start.assign("day", startMoment.
|
|
101
|
-
result.start.assign("month", startMoment.
|
|
102
|
-
result.start.assign("year", startMoment.
|
|
98
|
+
result.start.assign("day", startMoment.getDate());
|
|
99
|
+
result.start.assign("month", startMoment.getMonth() + 1);
|
|
100
|
+
result.start.assign("year", startMoment.getFullYear());
|
|
103
101
|
} else if (match[DAY_GROUP_3]) {
|
|
104
|
-
|
|
102
|
+
const day3 = match[DAY_GROUP_3];
|
|
105
103
|
if (day3 == "明" || day3 == "聽") {
|
|
106
|
-
startMoment
|
|
104
|
+
startMoment.setDate(startMoment.getDate() + 1);
|
|
107
105
|
} else if (day3 == "昨" || day3 == "尋" || day3 == "琴") {
|
|
108
|
-
startMoment
|
|
106
|
+
startMoment.setDate(startMoment.getDate() - 1);
|
|
109
107
|
} else if (day3 == "前") {
|
|
110
|
-
startMoment
|
|
108
|
+
startMoment.setDate(startMoment.getDate() - 2);
|
|
111
109
|
} else if (day3 == "大前") {
|
|
112
|
-
startMoment
|
|
110
|
+
startMoment.setDate(startMoment.getDate() - 3);
|
|
113
111
|
} else if (day3 == "後") {
|
|
114
|
-
startMoment
|
|
112
|
+
startMoment.setDate(startMoment.getDate() + 2);
|
|
115
113
|
} else if (day3 == "大後") {
|
|
116
|
-
startMoment
|
|
114
|
+
startMoment.setDate(startMoment.getDate() + 3);
|
|
117
115
|
}
|
|
118
|
-
result.start.assign("day", startMoment.
|
|
119
|
-
result.start.assign("month", startMoment.
|
|
120
|
-
result.start.assign("year", startMoment.
|
|
116
|
+
result.start.assign("day", startMoment.getDate());
|
|
117
|
+
result.start.assign("month", startMoment.getMonth() + 1);
|
|
118
|
+
result.start.assign("year", startMoment.getFullYear());
|
|
121
119
|
} else {
|
|
122
|
-
result.start.imply("day", startMoment.
|
|
123
|
-
result.start.imply("month", startMoment.
|
|
124
|
-
result.start.imply("year", startMoment.
|
|
120
|
+
result.start.imply("day", startMoment.getDate());
|
|
121
|
+
result.start.imply("month", startMoment.getMonth() + 1);
|
|
122
|
+
result.start.imply("year", startMoment.getFullYear());
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
let hour = 0;
|
|
@@ -233,8 +231,8 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
233
231
|
// Extracting the 'to' chunk
|
|
234
232
|
// ==============================================================
|
|
235
233
|
|
|
236
|
-
|
|
237
|
-
if (!
|
|
234
|
+
const secondMatch = SECOND_REG_PATTERN.exec(context.text.substring(result.index + result.text.length));
|
|
235
|
+
if (!secondMatch) {
|
|
238
236
|
// Not accept number only result
|
|
239
237
|
if (result.text.match(/^\d+$/)) {
|
|
240
238
|
return null;
|
|
@@ -242,53 +240,53 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
242
240
|
return result;
|
|
243
241
|
}
|
|
244
242
|
|
|
245
|
-
|
|
243
|
+
const endMoment = new Date(startMoment.getTime());
|
|
246
244
|
result.end = context.createParsingComponents();
|
|
247
245
|
|
|
248
246
|
// ----- Day
|
|
249
|
-
if (
|
|
250
|
-
|
|
247
|
+
if (secondMatch[DAY_GROUP_1]) {
|
|
248
|
+
const day1 = secondMatch[DAY_GROUP_1];
|
|
251
249
|
if (day1 == "明" || day1 == "聽") {
|
|
252
250
|
// Check not "Tomorrow" on late night
|
|
253
|
-
if (
|
|
254
|
-
endMoment
|
|
251
|
+
if (context.refDate.getHours() > 1) {
|
|
252
|
+
endMoment.setDate(endMoment.getDate() + 1);
|
|
255
253
|
}
|
|
256
254
|
} else if (day1 == "昨" || day1 == "尋" || day1 == "琴") {
|
|
257
|
-
endMoment
|
|
255
|
+
endMoment.setDate(endMoment.getDate() - 1);
|
|
258
256
|
} else if (day1 == "前") {
|
|
259
|
-
endMoment
|
|
257
|
+
endMoment.setDate(endMoment.getDate() - 2);
|
|
260
258
|
} else if (day1 == "大前") {
|
|
261
|
-
endMoment
|
|
259
|
+
endMoment.setDate(endMoment.getDate() - 3);
|
|
262
260
|
} else if (day1 == "後") {
|
|
263
|
-
endMoment
|
|
261
|
+
endMoment.setDate(endMoment.getDate() + 2);
|
|
264
262
|
} else if (day1 == "大後") {
|
|
265
|
-
endMoment
|
|
263
|
+
endMoment.setDate(endMoment.getDate() + 3);
|
|
266
264
|
}
|
|
267
|
-
result.end.assign("day", endMoment.
|
|
268
|
-
result.end.assign("month", endMoment.
|
|
269
|
-
result.end.assign("year", endMoment.
|
|
270
|
-
} else if (
|
|
271
|
-
|
|
265
|
+
result.end.assign("day", endMoment.getDate());
|
|
266
|
+
result.end.assign("month", endMoment.getMonth() + 1);
|
|
267
|
+
result.end.assign("year", endMoment.getFullYear());
|
|
268
|
+
} else if (secondMatch[DAY_GROUP_3]) {
|
|
269
|
+
const day3 = secondMatch[DAY_GROUP_3];
|
|
272
270
|
if (day3 == "明" || day3 == "聽") {
|
|
273
|
-
endMoment
|
|
271
|
+
endMoment.setDate(endMoment.getDate() + 1);
|
|
274
272
|
} else if (day3 == "昨" || day3 == "尋" || day3 == "琴") {
|
|
275
|
-
endMoment
|
|
273
|
+
endMoment.setDate(endMoment.getDate() - 1);
|
|
276
274
|
} else if (day3 == "前") {
|
|
277
|
-
endMoment
|
|
275
|
+
endMoment.setDate(endMoment.getDate() - 2);
|
|
278
276
|
} else if (day3 == "大前") {
|
|
279
|
-
endMoment
|
|
277
|
+
endMoment.setDate(endMoment.getDate() - 3);
|
|
280
278
|
} else if (day3 == "後") {
|
|
281
|
-
endMoment
|
|
279
|
+
endMoment.setDate(endMoment.getDate() + 2);
|
|
282
280
|
} else if (day3 == "大後") {
|
|
283
|
-
endMoment
|
|
281
|
+
endMoment.setDate(endMoment.getDate() + 3);
|
|
284
282
|
}
|
|
285
|
-
result.end.assign("day", endMoment.
|
|
286
|
-
result.end.assign("month", endMoment.
|
|
287
|
-
result.end.assign("year", endMoment.
|
|
283
|
+
result.end.assign("day", endMoment.getDate());
|
|
284
|
+
result.end.assign("month", endMoment.getMonth() + 1);
|
|
285
|
+
result.end.assign("year", endMoment.getFullYear());
|
|
288
286
|
} else {
|
|
289
|
-
result.end.imply("day", endMoment.
|
|
290
|
-
result.end.imply("month", endMoment.
|
|
291
|
-
result.end.imply("year", endMoment.
|
|
287
|
+
result.end.imply("day", endMoment.getDate());
|
|
288
|
+
result.end.imply("month", endMoment.getMonth() + 1);
|
|
289
|
+
result.end.imply("year", endMoment.getFullYear());
|
|
292
290
|
}
|
|
293
291
|
|
|
294
292
|
hour = 0;
|
|
@@ -296,31 +294,31 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
296
294
|
meridiem = -1;
|
|
297
295
|
|
|
298
296
|
// ----- Second
|
|
299
|
-
if (
|
|
300
|
-
|
|
297
|
+
if (secondMatch[SECOND_GROUP]) {
|
|
298
|
+
let second = parseInt(secondMatch[SECOND_GROUP]);
|
|
301
299
|
if (isNaN(second)) {
|
|
302
|
-
second = zhStringToNumber(
|
|
300
|
+
second = zhStringToNumber(secondMatch[SECOND_GROUP]);
|
|
303
301
|
}
|
|
304
302
|
|
|
305
303
|
if (second >= 60) return null;
|
|
306
304
|
result.end.assign("second", second);
|
|
307
305
|
}
|
|
308
306
|
|
|
309
|
-
hour = parseInt(
|
|
307
|
+
hour = parseInt(secondMatch[HOUR_GROUP]);
|
|
310
308
|
if (isNaN(hour)) {
|
|
311
|
-
hour = zhStringToNumber(
|
|
309
|
+
hour = zhStringToNumber(secondMatch[HOUR_GROUP]);
|
|
312
310
|
}
|
|
313
311
|
|
|
314
312
|
// ----- Minutes
|
|
315
|
-
if (
|
|
316
|
-
if (
|
|
313
|
+
if (secondMatch[MINUTE_GROUP]) {
|
|
314
|
+
if (secondMatch[MINUTE_GROUP] == "半") {
|
|
317
315
|
minute = 30;
|
|
318
|
-
} else if (
|
|
316
|
+
} else if (secondMatch[MINUTE_GROUP] == "正" || secondMatch[MINUTE_GROUP] == "整") {
|
|
319
317
|
minute = 0;
|
|
320
318
|
} else {
|
|
321
|
-
minute = parseInt(
|
|
319
|
+
minute = parseInt(secondMatch[MINUTE_GROUP]);
|
|
322
320
|
if (isNaN(minute)) {
|
|
323
|
-
minute = zhStringToNumber(
|
|
321
|
+
minute = zhStringToNumber(secondMatch[MINUTE_GROUP]);
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
324
|
} else if (hour > 100) {
|
|
@@ -340,9 +338,9 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
340
338
|
}
|
|
341
339
|
|
|
342
340
|
// ----- AM & PM
|
|
343
|
-
if (
|
|
341
|
+
if (secondMatch[AM_PM_HOUR_GROUP]) {
|
|
344
342
|
if (hour > 12) return null;
|
|
345
|
-
var ampm =
|
|
343
|
+
var ampm = secondMatch[AM_PM_HOUR_GROUP][0].toLowerCase();
|
|
346
344
|
if (ampm == "a") {
|
|
347
345
|
meridiem = 0;
|
|
348
346
|
if (hour == 12) hour = 0;
|
|
@@ -368,8 +366,8 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
368
366
|
}
|
|
369
367
|
}
|
|
370
368
|
}
|
|
371
|
-
} else if (
|
|
372
|
-
|
|
369
|
+
} else if (secondMatch[ZH_AM_PM_HOUR_GROUP_1]) {
|
|
370
|
+
const zhAMPMString1 = secondMatch[ZH_AM_PM_HOUR_GROUP_1];
|
|
373
371
|
var zhAMPM1 = zhAMPMString1[0];
|
|
374
372
|
if (zhAMPM1 == "朝" || zhAMPM1 == "早") {
|
|
375
373
|
meridiem = 0;
|
|
@@ -378,8 +376,8 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
378
376
|
meridiem = 1;
|
|
379
377
|
if (hour != 12) hour += 12;
|
|
380
378
|
}
|
|
381
|
-
} else if (
|
|
382
|
-
|
|
379
|
+
} else if (secondMatch[ZH_AM_PM_HOUR_GROUP_2]) {
|
|
380
|
+
const zhAMPMString2 = secondMatch[ZH_AM_PM_HOUR_GROUP_2];
|
|
383
381
|
var zhAMPM2 = zhAMPMString2[0];
|
|
384
382
|
if (zhAMPM2 == "上" || zhAMPM2 == "朝" || zhAMPM2 == "早" || zhAMPM2 == "凌") {
|
|
385
383
|
meridiem = 0;
|
|
@@ -388,8 +386,8 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
388
386
|
meridiem = 1;
|
|
389
387
|
if (hour != 12) hour += 12;
|
|
390
388
|
}
|
|
391
|
-
} else if (
|
|
392
|
-
|
|
389
|
+
} else if (secondMatch[ZH_AM_PM_HOUR_GROUP_3]) {
|
|
390
|
+
const zhAMPMString3 = secondMatch[ZH_AM_PM_HOUR_GROUP_3];
|
|
393
391
|
var zhAMPM3 = zhAMPMString3[0];
|
|
394
392
|
if (zhAMPM3 == "上" || zhAMPM3 == "朝" || zhAMPM3 == "早" || zhAMPM3 == "凌") {
|
|
395
393
|
meridiem = 0;
|
|
@@ -400,7 +398,7 @@ export default class ZHHantTimeExpressionParser extends AbstractParserWithWordBo
|
|
|
400
398
|
}
|
|
401
399
|
}
|
|
402
400
|
|
|
403
|
-
result.text = result.text +
|
|
401
|
+
result.text = result.text + secondMatch[0];
|
|
404
402
|
result.end.assign("hour", hour);
|
|
405
403
|
result.end.assign("minute", minute);
|
|
406
404
|
if (meridiem >= 0) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
1
|
import { ParsingContext } from "../../../../chrono";
|
|
3
2
|
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
3
|
import { ParsingResult } from "../../../../results";
|
|
@@ -18,27 +17,29 @@ export default class ZHHantWeekdayParser extends AbstractParserWithWordBoundaryC
|
|
|
18
17
|
const offset = WEEKDAY_OFFSET[dayOfWeek];
|
|
19
18
|
if (offset === undefined) return null;
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
const date = new Date(context.refDate.getTime());
|
|
22
21
|
const startMomentFixed = false;
|
|
23
|
-
const refOffset =
|
|
22
|
+
const refOffset = date.getDay();
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
let diff = offset - refOffset;
|
|
25
|
+
if (Math.abs(diff - 7) < Math.abs(diff)) {
|
|
26
|
+
diff -= 7;
|
|
27
|
+
}
|
|
28
|
+
if (Math.abs(diff + 7) < Math.abs(diff)) {
|
|
29
|
+
diff += 7;
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
date.setDate(date.getDate() + diff);
|
|
33
|
+
|
|
33
34
|
result.start.assign("weekday", offset);
|
|
34
35
|
if (startMomentFixed) {
|
|
35
|
-
result.start.assign("day",
|
|
36
|
-
result.start.assign("month",
|
|
37
|
-
result.start.assign("year",
|
|
36
|
+
result.start.assign("day", date.getDate());
|
|
37
|
+
result.start.assign("month", date.getMonth() + 1);
|
|
38
|
+
result.start.assign("year", date.getFullYear());
|
|
38
39
|
} else {
|
|
39
|
-
result.start.imply("day",
|
|
40
|
-
result.start.imply("month",
|
|
41
|
-
result.start.imply("year",
|
|
40
|
+
result.start.imply("day", date.getDate());
|
|
41
|
+
result.start.imply("month", date.getMonth() + 1);
|
|
42
|
+
result.start.imply("year", date.getFullYear());
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
return result;
|
package/src/results.ts
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import { Component, ParsedComponents, ParsedResult, ParsingReference } from "./types";
|
|
1
|
+
import { Component, ParsedComponents, ParsedResult, ParsingReference, TimezoneAbbrMap } from "./types";
|
|
2
2
|
|
|
3
3
|
import quarterOfYear from "dayjs/plugin/quarterOfYear";
|
|
4
4
|
import dayjs, { QUnitType } from "dayjs";
|
|
5
5
|
import { assignSimilarDate, assignSimilarTime, implySimilarTime } from "./utils/dates";
|
|
6
6
|
import { toTimezoneOffset } from "./timezone";
|
|
7
|
-
import { addDuration, Duration } from "./calculation/duration";
|
|
7
|
+
import { addDuration, Duration, EmptyDuration } from "./calculation/duration";
|
|
8
8
|
dayjs.extend(quarterOfYear);
|
|
9
9
|
|
|
10
10
|
export class ReferenceWithTimezone {
|
|
11
11
|
readonly instant: Date;
|
|
12
12
|
readonly timezoneOffset?: number | null;
|
|
13
13
|
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
14
|
+
constructor(instant?: Date, timezoneOffset?: number) {
|
|
15
|
+
this.instant = instant ?? new Date();
|
|
16
|
+
this.timezoneOffset = timezoneOffset ?? null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static fromDate(date: Date): ReferenceWithTimezone {
|
|
20
|
+
return new ReferenceWithTimezone(date);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static fromInput(input?: ParsingReference | Date, timezoneOverrides?: TimezoneAbbrMap) {
|
|
16
24
|
if (input instanceof Date) {
|
|
17
|
-
|
|
18
|
-
this.timezoneOffset = null;
|
|
19
|
-
} else {
|
|
20
|
-
this.instant = input.instant ?? new Date();
|
|
21
|
-
this.timezoneOffset = toTimezoneOffset(input.timezone, this.instant);
|
|
25
|
+
return ReferenceWithTimezone.fromDate(input);
|
|
22
26
|
}
|
|
27
|
+
const instant: Date = input?.instant ?? new Date();
|
|
28
|
+
const timezoneOffset = toTimezoneOffset(input?.timezone, instant, timezoneOverrides);
|
|
29
|
+
return new ReferenceWithTimezone(instant, timezoneOffset);
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
/**
|
|
@@ -72,16 +79,62 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
const
|
|
76
|
-
this.imply("day",
|
|
77
|
-
this.imply("month",
|
|
78
|
-
this.imply("year",
|
|
82
|
+
const date = reference.getDateWithAdjustedTimezone();
|
|
83
|
+
this.imply("day", date.getDate());
|
|
84
|
+
this.imply("month", date.getMonth() + 1);
|
|
85
|
+
this.imply("year", date.getFullYear());
|
|
79
86
|
this.imply("hour", 12);
|
|
80
87
|
this.imply("minute", 0);
|
|
81
88
|
this.imply("second", 0);
|
|
82
89
|
this.imply("millisecond", 0);
|
|
83
90
|
}
|
|
84
91
|
|
|
92
|
+
static createRelativeFromReference(
|
|
93
|
+
reference: ReferenceWithTimezone,
|
|
94
|
+
duration: Duration = EmptyDuration
|
|
95
|
+
): ParsingComponents {
|
|
96
|
+
let date = addDuration(reference.getDateWithAdjustedTimezone(), duration);
|
|
97
|
+
|
|
98
|
+
const components = new ParsingComponents(reference);
|
|
99
|
+
components.addTag("result/relativeDate");
|
|
100
|
+
if ("hour" in duration || "minute" in duration || "second" in duration || "millisecond" in duration) {
|
|
101
|
+
components.addTag("result/relativeDateAndTime");
|
|
102
|
+
assignSimilarTime(components, date);
|
|
103
|
+
assignSimilarDate(components, date);
|
|
104
|
+
components.assign("timezoneOffset", reference.getTimezoneOffset());
|
|
105
|
+
} else {
|
|
106
|
+
implySimilarTime(components, date);
|
|
107
|
+
components.imply("timezoneOffset", reference.getTimezoneOffset());
|
|
108
|
+
|
|
109
|
+
if ("day" in duration) {
|
|
110
|
+
components.assign("day", date.getDate());
|
|
111
|
+
components.assign("month", date.getMonth() + 1);
|
|
112
|
+
components.assign("year", date.getFullYear());
|
|
113
|
+
components.assign("weekday", date.getDay());
|
|
114
|
+
} else if ("week" in duration) {
|
|
115
|
+
components.assign("day", date.getDate());
|
|
116
|
+
components.assign("month", date.getMonth() + 1);
|
|
117
|
+
components.assign("year", date.getFullYear());
|
|
118
|
+
components.imply("weekday", date.getDay());
|
|
119
|
+
} else {
|
|
120
|
+
components.imply("day", date.getDate());
|
|
121
|
+
if ("month" in duration) {
|
|
122
|
+
components.assign("month", date.getMonth() + 1);
|
|
123
|
+
components.assign("year", date.getFullYear());
|
|
124
|
+
} else {
|
|
125
|
+
components.imply("month", date.getMonth() + 1);
|
|
126
|
+
if ("year" in duration) {
|
|
127
|
+
components.assign("year", date.getFullYear());
|
|
128
|
+
} else {
|
|
129
|
+
components.imply("year", date.getFullYear());
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return components;
|
|
136
|
+
}
|
|
137
|
+
|
|
85
138
|
get(component: Component): number | null {
|
|
86
139
|
if (component in this.knownValues) {
|
|
87
140
|
return this.knownValues[component];
|
|
@@ -116,9 +169,37 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
116
169
|
return this;
|
|
117
170
|
}
|
|
118
171
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Add the `duration` into this component, mark the modified date and/or time as implied.
|
|
174
|
+
* @param duration
|
|
175
|
+
*/
|
|
176
|
+
addDurationAsImplied(duration: Duration): ParsingComponents {
|
|
177
|
+
const currentDate = this.dateWithoutTimezoneAdjustment();
|
|
178
|
+
const date = addDuration(currentDate, duration);
|
|
179
|
+
if ("day" in duration || "week" in duration || "month" in duration || "year" in duration) {
|
|
180
|
+
this.delete(["day", "weekday", "month", "year"]);
|
|
181
|
+
this.imply("day", date.getDate());
|
|
182
|
+
this.imply("weekday", date.getDay());
|
|
183
|
+
this.imply("month", date.getMonth() + 1);
|
|
184
|
+
this.imply("year", date.getFullYear());
|
|
185
|
+
}
|
|
186
|
+
if ("second" in duration || "minute" in duration || "hour" in duration) {
|
|
187
|
+
this.delete(["second", "minute", "hour"]);
|
|
188
|
+
this.imply("second", date.getSeconds());
|
|
189
|
+
this.imply("minute", date.getMinutes());
|
|
190
|
+
this.imply("hour", date.getHours());
|
|
191
|
+
}
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
delete(components: Component | Component[]) {
|
|
196
|
+
if (typeof components === "string") {
|
|
197
|
+
components = [components];
|
|
198
|
+
}
|
|
199
|
+
for (const component of components) {
|
|
200
|
+
delete this.knownValues[component];
|
|
201
|
+
delete this.impliedValues[component];
|
|
202
|
+
}
|
|
122
203
|
}
|
|
123
204
|
|
|
124
205
|
clone(): ParsingComponents {
|
|
@@ -215,49 +296,6 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
215
296
|
date.setFullYear(this.get("year"));
|
|
216
297
|
return date;
|
|
217
298
|
}
|
|
218
|
-
|
|
219
|
-
static createRelativeFromReference(reference: ReferenceWithTimezone, duration: Duration): ParsingComponents {
|
|
220
|
-
let date = addDuration(reference.getDateWithAdjustedTimezone(), duration);
|
|
221
|
-
|
|
222
|
-
const components = new ParsingComponents(reference);
|
|
223
|
-
components.addTag("result/relativeDate");
|
|
224
|
-
if (duration["hour"] || duration["minute"] || duration["second"]) {
|
|
225
|
-
components.addTag("result/relativeDateAndTime");
|
|
226
|
-
assignSimilarTime(components, date);
|
|
227
|
-
assignSimilarDate(components, date);
|
|
228
|
-
components.assign("timezoneOffset", reference.getTimezoneOffset());
|
|
229
|
-
} else {
|
|
230
|
-
implySimilarTime(components, date);
|
|
231
|
-
components.imply("timezoneOffset", reference.getTimezoneOffset());
|
|
232
|
-
|
|
233
|
-
if (duration["day"]) {
|
|
234
|
-
components.assign("day", date.getDate());
|
|
235
|
-
components.assign("month", date.getMonth() + 1);
|
|
236
|
-
components.assign("year", date.getFullYear());
|
|
237
|
-
components.assign("weekday", date.getDay());
|
|
238
|
-
} else if (duration["week"]) {
|
|
239
|
-
components.assign("day", date.getDate());
|
|
240
|
-
components.assign("month", date.getMonth() + 1);
|
|
241
|
-
components.assign("year", date.getFullYear());
|
|
242
|
-
components.imply("weekday", date.getDay());
|
|
243
|
-
} else {
|
|
244
|
-
components.imply("day", date.getDate());
|
|
245
|
-
if (duration["month"]) {
|
|
246
|
-
components.assign("month", date.getMonth() + 1);
|
|
247
|
-
components.assign("year", date.getFullYear());
|
|
248
|
-
} else {
|
|
249
|
-
components.imply("month", date.getMonth() + 1);
|
|
250
|
-
if (duration["year"]) {
|
|
251
|
-
components.assign("year", date.getFullYear());
|
|
252
|
-
} else {
|
|
253
|
-
components.imply("year", date.getFullYear());
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return components;
|
|
260
|
-
}
|
|
261
299
|
}
|
|
262
300
|
|
|
263
301
|
export class ParsingResult implements ParsedResult {
|
package/src/timezone.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
1
|
import { TimezoneAbbrMap, Weekday, Month } from "./types";
|
|
3
2
|
|
|
4
3
|
export const TIMEZONE_ABBR_MAP: TimezoneAbbrMap = {
|
|
@@ -310,10 +309,7 @@ export function toTimezoneOffset(
|
|
|
310
309
|
}
|
|
311
310
|
|
|
312
311
|
// Return DST offset if the refDate is during daylight savings
|
|
313
|
-
if (
|
|
314
|
-
dayjs(date).isAfter(matchedTimezone.dstStart(date.getFullYear())) &&
|
|
315
|
-
!dayjs(date).isAfter(matchedTimezone.dstEnd(date.getFullYear()))
|
|
316
|
-
) {
|
|
312
|
+
if (date > matchedTimezone.dstStart(date.getFullYear()) && !(date > matchedTimezone.dstEnd(date.getFullYear()))) {
|
|
317
313
|
return matchedTimezone.timezoneOffsetDuringDst;
|
|
318
314
|
}
|
|
319
315
|
|
package/src/types.ts
CHANGED
|
@@ -129,7 +129,7 @@ export type Component =
|
|
|
129
129
|
| "meridiem"
|
|
130
130
|
| "timezoneOffset";
|
|
131
131
|
|
|
132
|
-
export type Timeunit = "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond";
|
|
132
|
+
export type Timeunit = "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "quarter";
|
|
133
133
|
|
|
134
134
|
export enum Meridiem {
|
|
135
135
|
AM = 0,
|
|
@@ -114,3 +114,20 @@ test("Test - Closest Weekday Calculation", () => {
|
|
|
114
114
|
expect(getDaysToWeekday(refDate, Weekday.WEDNESDAY)).toBe(-3);
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
+
|
|
118
|
+
test("Test - Weekdays calculation with timezone", () => {
|
|
119
|
+
// Thu Feb 27 2025 17:00:00 GMT+0000
|
|
120
|
+
// Thu Feb 27 2025 09:00:00 GMT-0800 (PST)
|
|
121
|
+
// Fri Feb 28 2025 02:00:00 GMT+0900 (JST)
|
|
122
|
+
const refInstant = new Date("2025-02-27T17:00:00.000Z");
|
|
123
|
+
{
|
|
124
|
+
const reference = ReferenceWithTimezone.fromInput({ instant: refInstant, timezone: "JST" });
|
|
125
|
+
const output = createParsingComponentsAtWeekday(reference, Weekday.FRIDAY, "this");
|
|
126
|
+
expect(output.date()).toStrictEqual(new Date("Fri Feb 28 2025 12:00:00 GMT+0900 (JST)"));
|
|
127
|
+
}
|
|
128
|
+
{
|
|
129
|
+
const reference = ReferenceWithTimezone.fromInput({ instant: refInstant, timezone: "PST" });
|
|
130
|
+
const output = createParsingComponentsAtWeekday(reference, Weekday.FRIDAY, "this");
|
|
131
|
+
expect(output.date()).toStrictEqual(new Date("Fri Feb 28 2025 12:00:00 GMT-0800 (PST)"));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
@@ -432,6 +432,8 @@ test("Test - Parsing negative cases : [year-like] pattern", function () {
|
|
|
432
432
|
testUnexpectedResult(chrono, "2020");
|
|
433
433
|
|
|
434
434
|
testUnexpectedResult(chrono, "2020 ");
|
|
435
|
+
|
|
436
|
+
testUnexpectedResult(chrono, "2019 to 2020");
|
|
435
437
|
});
|
|
436
438
|
|
|
437
439
|
test("Test - Parsing negative cases : 'at [some numbers]'", function () {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as chrono from "../../src/";
|
|
2
|
+
import { testSingleCase } from "../test_util";
|
|
3
|
+
|
|
4
|
+
test("Test - Single Expression", () => {
|
|
5
|
+
testSingleCase(chrono.it.casual, "La scadenza è ora", new Date(2012, 7, 10, 8, 9, 10, 11), (result) => {
|
|
6
|
+
expect(result.index).toBe(14);
|
|
7
|
+
expect(result.text).toBe("ora");
|
|
8
|
+
|
|
9
|
+
expect(result.start).not.toBeNull();
|
|
10
|
+
expect(result.start.get("year")).toBe(2012);
|
|
11
|
+
expect(result.start.get("month")).toBe(8);
|
|
12
|
+
expect(result.start.get("day")).toBe(10);
|
|
13
|
+
expect(result.start.get("hour")).toBe(8);
|
|
14
|
+
expect(result.start.get("minute")).toBe(9);
|
|
15
|
+
expect(result.start.get("second")).toBe(10);
|
|
16
|
+
expect(result.start.get("millisecond")).toBe(11);
|
|
17
|
+
|
|
18
|
+
expect(result.start).toBeDate(new Date(2012, 7, 10, 8, 9, 10, 11));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
testSingleCase(chrono.it.casual, "La scadenza è oggi", new Date(2012, 7, 10, 14, 12), (result) => {
|
|
22
|
+
expect(result.index).toBe(14);
|
|
23
|
+
expect(result.text).toBe("oggi");
|
|
24
|
+
|
|
25
|
+
expect(result.start).not.toBeNull();
|
|
26
|
+
expect(result.start.get("year")).toBe(2012);
|
|
27
|
+
expect(result.start.get("month")).toBe(8);
|
|
28
|
+
expect(result.start.get("day")).toBe(10);
|
|
29
|
+
|
|
30
|
+
expect(result.start).toBeDate(new Date(2012, 7, 10, 14, 12));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
testSingleCase(chrono.it.casual, "La scadenza è domani", new Date(2012, 7, 10, 17, 10), (result) => {
|
|
34
|
+
expect(result.index).toBe(14);
|
|
35
|
+
expect(result.text).toBe("domani");
|
|
36
|
+
|
|
37
|
+
expect(result.start).not.toBeNull();
|
|
38
|
+
expect(result.start.get("year")).toBe(2012);
|
|
39
|
+
expect(result.start.get("month")).toBe(8);
|
|
40
|
+
expect(result.start.get("day")).toBe(11);
|
|
41
|
+
|
|
42
|
+
expect(result.start).toBeDate(new Date(2012, 7, 11, 17, 10));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as chrono from "../../src/";
|
|
2
|
+
import { testSingleCase, testUnexpectedResult } from "../test_util";
|
|
3
|
+
|
|
4
|
+
test("Test - Single expression", () => {
|
|
5
|
+
testSingleCase(chrono.it, "10 Agosto 2012", new Date(2012, 7, 10), (result) => {
|
|
6
|
+
expect(result.start).not.toBeNull();
|
|
7
|
+
expect(result.start.get("year")).toBe(2012);
|
|
8
|
+
expect(result.start.get("month")).toBe(8);
|
|
9
|
+
expect(result.start.get("day")).toBe(10);
|
|
10
|
+
|
|
11
|
+
expect(result.index).toBe(0);
|
|
12
|
+
expect(result.text).toBe("10 Agosto 2012");
|
|
13
|
+
|
|
14
|
+
expect(result.start).toBeDate(new Date(2012, 8 - 1, 10, 12));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
testSingleCase(chrono.it, "La scadenza è il 10 Agosto", new Date(2012, 7, 10), (result) => {
|
|
18
|
+
expect(result.index).toBe(17);
|
|
19
|
+
expect(result.text).toBe("10 Agosto");
|
|
20
|
+
|
|
21
|
+
expect(result.start).not.toBeNull();
|
|
22
|
+
expect(result.start.get("year")).toBe(2012);
|
|
23
|
+
expect(result.start.get("month")).toBe(8);
|
|
24
|
+
expect(result.start.get("day")).toBe(10);
|
|
25
|
+
|
|
26
|
+
expect(result.start).toBeDate(new Date(2012, 8 - 1, 10, 12));
|
|
27
|
+
});
|
|
28
|
+
});
|