chrono-node 2.10.0 → 2.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/calculation/duration.js +12 -7
- package/dist/cjs/calculation/duration.js.map +1 -1
- package/dist/cjs/common/refiners/AbstractMergeDateTimeRefiner.js +6 -3
- package/dist/cjs/common/refiners/AbstractMergeDateTimeRefiner.js.map +1 -1
- package/dist/cjs/common/refiners/MergeWeekdayComponentRefiner.js +2 -1
- package/dist/cjs/common/refiners/MergeWeekdayComponentRefiner.js.map +1 -1
- package/dist/cjs/locales/en/configuration.js +4 -0
- package/dist/cjs/locales/en/configuration.js.map +1 -1
- package/dist/cjs/locales/en/constants.d.ts +1 -1
- package/dist/cjs/locales/en/constants.js +1 -1
- package/dist/cjs/locales/en/constants.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENEndOfCurrentMonthParser.d.ts +7 -0
- package/dist/cjs/locales/en/parsers/ENEndOfCurrentMonthParser.js +23 -0
- package/dist/cjs/locales/en/parsers/ENEndOfCurrentMonthParser.js.map +1 -0
- package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENSlashMonthFormatParser.d.ts +1 -1
- package/dist/cjs/locales/en/parsers/ENSlashMonthFormatParser.js +3 -0
- package/dist/cjs/locales/en/parsers/ENSlashMonthFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/en/refiners/ENEndOfPeriodRefiner.d.ts +7 -0
- package/dist/cjs/locales/en/refiners/ENEndOfPeriodRefiner.js +81 -0
- package/dist/cjs/locales/en/refiners/ENEndOfPeriodRefiner.js.map +1 -0
- package/dist/cjs/locales/fr/constants.js +13 -0
- package/dist/cjs/locales/fr/constants.js.map +1 -1
- package/dist/cjs/locales/it/configuration.d.ts +5 -0
- package/dist/cjs/locales/it/configuration.js +66 -0
- package/dist/cjs/locales/it/configuration.js.map +1 -0
- package/dist/cjs/locales/it/constants.d.ts +8 -4
- package/dist/cjs/locales/it/constants.js +216 -90
- package/dist/cjs/locales/it/constants.js.map +1 -1
- package/dist/cjs/locales/it/index.d.ts +9 -7
- package/dist/cjs/locales/it/index.js +13 -51
- package/dist/cjs/locales/it/index.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITCasualDateParser.js +19 -10
- 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 +70 -37
- package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITMonthNameLittleEndianParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITMonthNameLittleEndianParser.js +6 -6
- package/dist/cjs/locales/it/parsers/ITMonthNameLittleEndianParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITMonthNameMiddleEndianParser.d.ts +4 -2
- package/dist/cjs/locales/it/parsers/ITMonthNameMiddleEndianParser.js +17 -6
- package/dist/cjs/locales/it/parsers/ITMonthNameMiddleEndianParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITMonthNameParser.d.ts +2 -2
- package/dist/cjs/locales/it/parsers/ITMonthNameParser.js +5 -4
- package/dist/cjs/locales/it/parsers/ITMonthNameParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js +21 -7
- package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITSlashMonthFormatParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITSlashMonthFormatParser.js +2 -2
- package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.d.ts +3 -2
- package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.js +37 -29
- package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js +9 -7
- package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.d.ts +3 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +17 -9
- package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js +9 -6
- package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.d.ts +3 -1
- package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js +21 -6
- package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/ITWeekdayParser.d.ts +1 -1
- package/dist/cjs/locales/it/parsers/ITWeekdayParser.js +21 -12
- package/dist/cjs/locales/it/parsers/ITWeekdayParser.js.map +1 -1
- package/dist/cjs/locales/it/parsers/{ITCasualYearMonthDayParser.d.ts → ITYearMonthDayParser.d.ts} +3 -1
- package/dist/cjs/locales/it/parsers/{ITCasualYearMonthDayParser.js → ITYearMonthDayParser.js} +20 -8
- package/dist/cjs/locales/it/parsers/ITYearMonthDayParser.js.map +1 -0
- package/dist/cjs/locales/it/refiners/ITExtractYearSuffixRefiner.d.ts +5 -0
- package/dist/cjs/locales/it/refiners/ITExtractYearSuffixRefiner.js +34 -0
- package/dist/cjs/locales/it/refiners/ITExtractYearSuffixRefiner.js.map +1 -0
- package/dist/cjs/locales/it/refiners/ITMergeDateRangeRefiner.d.ts +1 -1
- package/dist/cjs/locales/it/refiners/ITMergeDateRangeRefiner.js +3 -3
- package/dist/cjs/locales/it/refiners/ITMergeDateRangeRefiner.js.map +1 -1
- package/dist/cjs/locales/it/refiners/ITMergeDateTimeRefiner.d.ts +1 -1
- package/dist/cjs/locales/it/refiners/ITMergeDateTimeRefiner.js +3 -3
- package/dist/cjs/locales/it/refiners/ITMergeDateTimeRefiner.js.map +1 -1
- package/dist/cjs/locales/it/refiners/ITMergeRelativeAfterDateRefiner.d.ts +6 -0
- package/dist/cjs/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js +30 -0
- package/dist/cjs/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js.map +1 -0
- package/dist/cjs/locales/it/refiners/{ITMergeRelativeDateRefiner.d.ts → ITMergeRelativeFollowByDateRefiner.d.ts} +1 -1
- package/dist/cjs/locales/it/refiners/{ITMergeRelativeDateRefiner.js → ITMergeRelativeFollowByDateRefiner.js} +8 -8
- package/dist/cjs/locales/it/refiners/ITMergeRelativeFollowByDateRefiner.js.map +1 -0
- package/dist/cjs/locales/it/refiners/ITUnlikelyFormatFilter.d.ts +6 -0
- package/dist/cjs/locales/it/refiners/ITUnlikelyFormatFilter.js +26 -0
- package/dist/cjs/locales/it/refiners/ITUnlikelyFormatFilter.js.map +1 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansAgoFormatParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansAgoFormatParser.js +3 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.js +3 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -1
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +3 -0
- package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantAgoFormatParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantAgoFormatParser.js +3 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.js +3 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -1
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +1 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +3 -0
- package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -1
- package/dist/esm/calculation/duration.js +5 -0
- package/dist/esm/calculation/duration.js.map +1 -1
- package/dist/esm/common/refiners/AbstractMergeDateTimeRefiner.js +6 -3
- package/dist/esm/common/refiners/AbstractMergeDateTimeRefiner.js.map +1 -1
- package/dist/esm/common/refiners/MergeWeekdayComponentRefiner.js +2 -1
- package/dist/esm/common/refiners/MergeWeekdayComponentRefiner.js.map +1 -1
- package/dist/esm/locales/en/configuration.js +4 -0
- package/dist/esm/locales/en/configuration.js.map +1 -1
- package/dist/esm/locales/en/constants.d.ts +1 -1
- package/dist/esm/locales/en/constants.js +1 -1
- package/dist/esm/locales/en/constants.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENEndOfCurrentMonthParser.d.ts +7 -0
- package/dist/esm/locales/en/parsers/ENEndOfCurrentMonthParser.js +20 -0
- package/dist/esm/locales/en/parsers/ENEndOfCurrentMonthParser.js.map +1 -0
- package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.js +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENSlashMonthFormatParser.d.ts +1 -1
- package/dist/esm/locales/en/parsers/ENSlashMonthFormatParser.js +3 -0
- package/dist/esm/locales/en/parsers/ENSlashMonthFormatParser.js.map +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js +1 -1
- package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/en/refiners/ENEndOfPeriodRefiner.d.ts +7 -0
- package/dist/esm/locales/en/refiners/ENEndOfPeriodRefiner.js +78 -0
- package/dist/esm/locales/en/refiners/ENEndOfPeriodRefiner.js.map +1 -0
- package/dist/esm/locales/fr/constants.js +13 -0
- package/dist/esm/locales/fr/constants.js.map +1 -1
- package/dist/esm/locales/it/configuration.d.ts +5 -0
- package/dist/esm/locales/it/configuration.js +60 -0
- package/dist/esm/locales/it/configuration.js.map +1 -0
- package/dist/esm/locales/it/constants.d.ts +8 -4
- package/dist/esm/locales/it/constants.js +256 -117
- package/dist/esm/locales/it/constants.js.map +1 -1
- package/dist/esm/locales/it/index.d.ts +9 -7
- package/dist/esm/locales/it/index.js +8 -48
- package/dist/esm/locales/it/index.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITCasualDateParser.js +19 -10
- 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 +37 -37
- package/dist/esm/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITMonthNameLittleEndianParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITMonthNameLittleEndianParser.js +5 -5
- package/dist/esm/locales/it/parsers/ITMonthNameLittleEndianParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITMonthNameMiddleEndianParser.d.ts +4 -2
- package/dist/esm/locales/it/parsers/ITMonthNameMiddleEndianParser.js +17 -5
- package/dist/esm/locales/it/parsers/ITMonthNameMiddleEndianParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITMonthNameParser.d.ts +2 -2
- package/dist/esm/locales/it/parsers/ITMonthNameParser.js +4 -3
- package/dist/esm/locales/it/parsers/ITMonthNameParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js +21 -7
- package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITSlashMonthFormatParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITSlashMonthFormatParser.js +1 -1
- package/dist/esm/locales/it/parsers/ITTimeExpressionParser.d.ts +3 -2
- package/dist/esm/locales/it/parsers/ITTimeExpressionParser.js +35 -27
- package/dist/esm/locales/it/parsers/ITTimeExpressionParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js +9 -7
- package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.d.ts +3 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +18 -9
- package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js +9 -6
- package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.d.ts +3 -1
- package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js +22 -6
- package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/ITWeekdayParser.d.ts +1 -1
- package/dist/esm/locales/it/parsers/ITWeekdayParser.js +21 -12
- package/dist/esm/locales/it/parsers/ITWeekdayParser.js.map +1 -1
- package/dist/esm/locales/it/parsers/{ITCasualYearMonthDayParser.d.ts → ITYearMonthDayParser.d.ts} +3 -1
- package/dist/esm/locales/it/parsers/{ITCasualYearMonthDayParser.js → ITYearMonthDayParser.js} +20 -7
- package/dist/esm/locales/it/parsers/ITYearMonthDayParser.js.map +1 -0
- package/dist/esm/locales/it/refiners/ITExtractYearSuffixRefiner.d.ts +5 -0
- package/dist/esm/locales/it/refiners/ITExtractYearSuffixRefiner.js +31 -0
- package/dist/esm/locales/it/refiners/ITExtractYearSuffixRefiner.js.map +1 -0
- package/dist/esm/locales/it/refiners/ITMergeDateRangeRefiner.d.ts +1 -1
- package/dist/esm/locales/it/refiners/ITMergeDateRangeRefiner.js +2 -2
- package/dist/esm/locales/it/refiners/ITMergeDateRangeRefiner.js.map +1 -1
- package/dist/esm/locales/it/refiners/ITMergeDateTimeRefiner.d.ts +1 -1
- package/dist/esm/locales/it/refiners/ITMergeDateTimeRefiner.js +2 -2
- package/dist/esm/locales/it/refiners/ITMergeDateTimeRefiner.js.map +1 -1
- package/dist/esm/locales/it/refiners/ITMergeRelativeAfterDateRefiner.d.ts +6 -0
- package/dist/esm/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js +27 -0
- package/dist/esm/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js.map +1 -0
- package/dist/esm/locales/it/refiners/{ITMergeRelativeDateRefiner.d.ts → ITMergeRelativeFollowByDateRefiner.d.ts} +1 -1
- package/dist/esm/locales/it/refiners/{ITMergeRelativeDateRefiner.js → ITMergeRelativeFollowByDateRefiner.js} +7 -7
- package/dist/esm/locales/it/refiners/ITMergeRelativeFollowByDateRefiner.js.map +1 -0
- package/dist/esm/locales/it/refiners/ITUnlikelyFormatFilter.d.ts +6 -0
- package/dist/esm/locales/it/refiners/ITUnlikelyFormatFilter.js +23 -0
- package/dist/esm/locales/it/refiners/ITUnlikelyFormatFilter.js.map +1 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansAgoFormatParser.d.ts +1 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansAgoFormatParser.js +3 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.d.ts +1 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.js +3 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -1
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +1 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +3 -0
- package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantAgoFormatParser.d.ts +1 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantAgoFormatParser.js +3 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.d.ts +1 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.js +3 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -1
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +1 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +3 -0
- package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -1
- package/package.json +1 -1
- package/src/calculation/duration.ts +5 -0
- package/src/common/refiners/AbstractMergeDateTimeRefiner.ts +13 -5
- package/src/common/refiners/MergeWeekdayComponentRefiner.ts +6 -1
- package/src/locales/en/configuration.ts +4 -0
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/parsers/ENEndOfCurrentMonthParser.ts +25 -0
- package/src/locales/en/parsers/ENMonthNameMiddleEndianParser.ts +1 -1
- package/src/locales/en/parsers/ENSlashMonthFormatParser.ts +7 -1
- package/src/locales/en/parsers/ENTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/en/refiners/ENEndOfPeriodRefiner.ts +101 -0
- package/src/locales/fr/constants.ts +13 -0
- package/src/locales/it/configuration.ts +85 -0
- package/src/locales/it/constants.ts +273 -123
- package/src/locales/it/index.ts +14 -73
- package/src/locales/it/parsers/ITCasualDateParser.ts +20 -12
- package/src/locales/it/parsers/ITCasualTimeParser.ts +39 -44
- package/src/locales/it/parsers/ITMonthNameLittleEndianParser.ts +6 -6
- package/src/locales/it/parsers/ITMonthNameMiddleEndianParser.ts +34 -17
- package/src/locales/it/parsers/ITMonthNameParser.ts +9 -8
- package/src/locales/it/parsers/ITRelativeDateFormatParser.ts +33 -12
- package/src/locales/it/parsers/ITSlashMonthFormatParser.ts +1 -1
- package/src/locales/it/parsers/ITTimeExpressionParser.ts +42 -28
- package/src/locales/it/parsers/ITTimeUnitAgoFormatParser.ts +9 -8
- package/src/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.ts +21 -11
- package/src/locales/it/parsers/ITTimeUnitLaterFormatParser.ts +12 -6
- package/src/locales/it/parsers/ITTimeUnitWithinFormatParser.ts +28 -8
- package/src/locales/it/parsers/ITWeekdayParser.ts +23 -13
- package/src/locales/it/parsers/{ITCasualYearMonthDayParser.ts → ITYearMonthDayParser.ts} +19 -8
- package/src/locales/it/refiners/ITExtractYearSuffixRefiner.ts +34 -0
- package/src/locales/it/refiners/ITMergeDateRangeRefiner.ts +5 -9
- package/src/locales/it/refiners/ITMergeDateTimeRefiner.ts +5 -5
- package/src/locales/it/refiners/ITMergeRelativeAfterDateRefiner.ts +46 -0
- package/src/locales/it/refiners/{ITMergeRelativeDateRefiner.ts → ITMergeRelativeFollowByDateRefiner.ts} +10 -10
- package/src/locales/it/refiners/ITUnlikelyFormatFilter.ts +31 -0
- package/src/locales/zh/hans/parsers/ZHHansAgoFormatParser.ts +6 -0
- package/src/locales/zh/hans/parsers/ZHHansDateParser.ts +6 -0
- package/src/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.ts +6 -0
- package/src/locales/zh/hant/parsers/ZHHantAgoFormatParser.ts +6 -0
- package/src/locales/zh/hant/parsers/ZHHantDateParser.ts +6 -0
- package/src/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.ts +6 -0
- package/dist/cjs/locales/it/parsers/ITCasualYearMonthDayParser.js.map +0 -1
- package/dist/cjs/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +0 -1
- package/dist/esm/locales/it/parsers/ITCasualYearMonthDayParser.js.map +0 -1
- package/dist/esm/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +0 -1
|
@@ -4,7 +4,7 @@ import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/
|
|
|
4
4
|
import { assignSimilarDate } from "../../../utils/dates";
|
|
5
5
|
import * as references from "../../../common/casualReferences";
|
|
6
6
|
|
|
7
|
-
const PATTERN = /(ora|oggi|stasera|
|
|
7
|
+
const PATTERN = /(adesso|ora|oggi|stasera|stanotte|domani|dopodomani|ieri|ieri\s*sera|ieri\s*notte)(?=\W|$)/i;
|
|
8
8
|
|
|
9
9
|
export default class ITCasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
10
10
|
innerPattern(context: ParsingContext): RegExp {
|
|
@@ -14,28 +14,37 @@ export default class ITCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
14
14
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
15
15
|
let targetDate = context.refDate;
|
|
16
16
|
const lowerText = match[0].toLowerCase();
|
|
17
|
-
|
|
17
|
+
let component = context.createParsingComponents();
|
|
18
18
|
|
|
19
19
|
switch (lowerText) {
|
|
20
|
+
case "adesso":
|
|
20
21
|
case "ora":
|
|
21
|
-
|
|
22
|
+
component = references.now(context.reference);
|
|
23
|
+
break;
|
|
22
24
|
|
|
23
25
|
case "oggi":
|
|
24
|
-
|
|
26
|
+
component = references.today(context.reference);
|
|
27
|
+
break;
|
|
25
28
|
|
|
26
29
|
case "ieri":
|
|
27
|
-
|
|
30
|
+
component = references.yesterday(context.reference);
|
|
31
|
+
break;
|
|
28
32
|
|
|
29
33
|
case "domani":
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
component = references.tomorrow(context.reference);
|
|
35
|
+
break;
|
|
32
36
|
|
|
33
37
|
case "stasera":
|
|
34
|
-
case "
|
|
35
|
-
|
|
38
|
+
case "stanotte":
|
|
39
|
+
component = references.tonight(context.reference);
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case "dopodomani":
|
|
43
|
+
component = references.theDayAfter(context.reference, 2);
|
|
44
|
+
break;
|
|
36
45
|
|
|
37
46
|
default:
|
|
38
|
-
if (lowerText.match(/ieri\s*sera/)) {
|
|
47
|
+
if (lowerText.match(/ieri\s*sera/) || lowerText.match(/ieri\s*notte/)) {
|
|
39
48
|
if (targetDate.getHours() > 6) {
|
|
40
49
|
const previousDay = new Date(targetDate.getTime());
|
|
41
50
|
previousDay.setDate(previousDay.getDate() - 1);
|
|
@@ -45,10 +54,9 @@ export default class ITCasualDateParser extends AbstractParserWithWordBoundaryCh
|
|
|
45
54
|
assignSimilarDate(component, targetDate);
|
|
46
55
|
component.imply("hour", 0);
|
|
47
56
|
}
|
|
48
|
-
|
|
49
57
|
break;
|
|
50
58
|
}
|
|
51
|
-
|
|
59
|
+
component.addTag("parser/ITCasualDateParser");
|
|
52
60
|
return component;
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -1,57 +1,52 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { Meridiem } from "../../../index";
|
|
3
2
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
-
import
|
|
3
|
+
import * as casualReferences from "../../../common/casualReferences";
|
|
5
4
|
|
|
6
|
-
const PATTERN =
|
|
5
|
+
const PATTERN =
|
|
6
|
+
/(stamattina|stasera|stanotte|stamani)|(questa\s*)?(mattina|pomeriggio|sera|notte|mezzanotte|mezzogiorno)(?=\W|$)/i;
|
|
7
7
|
|
|
8
8
|
export default class ITCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
9
9
|
innerPattern() {
|
|
10
10
|
return PATTERN;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
component.imply("hour", 12);
|
|
51
|
-
component.addTag("casualReference/noon");
|
|
52
|
-
break;
|
|
13
|
+
let component = null;
|
|
14
|
+
|
|
15
|
+
// Handle compound words like "stamattina", "stasera", etc.
|
|
16
|
+
if (match[1]) {
|
|
17
|
+
switch (match[1].toLowerCase()) {
|
|
18
|
+
case "stamattina":
|
|
19
|
+
case "stamani":
|
|
20
|
+
component = casualReferences.morning(context.reference);
|
|
21
|
+
break;
|
|
22
|
+
case "stasera":
|
|
23
|
+
case "stanotte":
|
|
24
|
+
component = casualReferences.evening(context.reference);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
} else if (match[3]) {
|
|
28
|
+
switch (match[3].toLowerCase()) {
|
|
29
|
+
case "pomeriggio":
|
|
30
|
+
component = casualReferences.afternoon(context.reference);
|
|
31
|
+
break;
|
|
32
|
+
case "sera":
|
|
33
|
+
case "notte":
|
|
34
|
+
component = casualReferences.evening(context.reference);
|
|
35
|
+
break;
|
|
36
|
+
case "mezzanotte":
|
|
37
|
+
component = casualReferences.midnight(context.reference);
|
|
38
|
+
break;
|
|
39
|
+
case "mattina":
|
|
40
|
+
component = casualReferences.morning(context.reference);
|
|
41
|
+
break;
|
|
42
|
+
case "mezzogiorno":
|
|
43
|
+
component = casualReferences.noon(context.reference);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (component) {
|
|
48
|
+
component.addTag("parser/ITCasualTimeParser");
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
return component;
|
|
56
51
|
}
|
|
57
52
|
}
|
|
@@ -9,17 +9,17 @@ import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/
|
|
|
9
9
|
|
|
10
10
|
// prettier-ignore
|
|
11
11
|
const PATTERN = new RegExp(
|
|
12
|
-
`(?:
|
|
12
|
+
`(?:il\\s{0,3})?` +
|
|
13
13
|
`(${ORDINAL_NUMBER_PATTERN})` +
|
|
14
14
|
`(?:` +
|
|
15
|
-
`\\s{0,3}(?:al|\\-|\\–|fino
|
|
15
|
+
`\\s{0,3}(?:al|\\-|\\–|fino\\s*al?)?\\s{0,3}` +
|
|
16
16
|
`(${ORDINAL_NUMBER_PATTERN})` +
|
|
17
17
|
")?" +
|
|
18
|
-
`(?:-|/|\\s{0,3}(?:
|
|
18
|
+
`(?:-|/|\\s{0,3}(?:di)?\\s{0,3})` +
|
|
19
19
|
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
20
20
|
"(?:" +
|
|
21
21
|
`(?:-|/|,?\\s{0,3})` +
|
|
22
|
-
`(${YEAR_PATTERN}(
|
|
22
|
+
`(${YEAR_PATTERN}(?!\\w))` +
|
|
23
23
|
")?" +
|
|
24
24
|
"(?=\\W|$)",
|
|
25
25
|
"i"
|
|
@@ -30,7 +30,7 @@ const DATE_TO_GROUP = 2;
|
|
|
30
30
|
const MONTH_NAME_GROUP = 3;
|
|
31
31
|
const YEAR_GROUP = 4;
|
|
32
32
|
|
|
33
|
-
export default class
|
|
33
|
+
export default class ITMonthNameLittleEndianParser extends AbstractParserWithWordBoundaryChecking {
|
|
34
34
|
innerPattern(): RegExp {
|
|
35
35
|
return PATTERN;
|
|
36
36
|
}
|
|
@@ -41,7 +41,7 @@ export default class ENMonthNameLittleEndianParser extends AbstractParserWithWor
|
|
|
41
41
|
const month = MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
|
42
42
|
const day = parseOrdinalNumberPattern(match[DATE_GROUP]);
|
|
43
43
|
if (day > 31) {
|
|
44
|
-
// e.g. "[96
|
|
44
|
+
// e.g. "[96 Ago]" => "9[6 Ago]", we need to shift away from the next number
|
|
45
45
|
match.index = match.index + match[DATE_GROUP].length;
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
@@ -6,17 +6,18 @@ import { YEAR_PATTERN, parseYear } from "../constants";
|
|
|
6
6
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
7
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
8
8
|
|
|
9
|
+
// prettier-ignore
|
|
9
10
|
const PATTERN = new RegExp(
|
|
10
11
|
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
11
12
|
"(?:-|/|\\s*,?\\s*)" +
|
|
12
13
|
`(${ORDINAL_NUMBER_PATTERN})(?!\\s*(?:am|pm))\\s*` +
|
|
13
14
|
"(?:" +
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
"(?:al|\\-)\\s*" +
|
|
16
|
+
`(${ORDINAL_NUMBER_PATTERN})\\s*` +
|
|
16
17
|
")?" +
|
|
17
18
|
"(?:" +
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
`(?:-|/|\\s*,\\s*|\\s+)` +
|
|
20
|
+
`(${YEAR_PATTERN})` +
|
|
20
21
|
")?" +
|
|
21
22
|
"(?=\\W|$)(?!\\:\\d)",
|
|
22
23
|
"i"
|
|
@@ -28,16 +29,24 @@ const DATE_TO_GROUP = 3;
|
|
|
28
29
|
const YEAR_GROUP = 4;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
|
-
* The parser for parsing
|
|
32
|
-
* -
|
|
33
|
-
* -
|
|
34
|
-
* -
|
|
32
|
+
* The parser for parsing date format that begin with month's name.
|
|
33
|
+
* - Gennaio 13
|
|
34
|
+
* - Gennaio 13, 2012
|
|
35
|
+
* - Gennaio 13 - 15, 2012
|
|
35
36
|
* Note: Watch out for:
|
|
36
|
-
* -
|
|
37
|
-
* -
|
|
38
|
-
* -
|
|
37
|
+
* - Gennaio 12:00
|
|
38
|
+
* - Gennaio 12.44
|
|
39
|
+
* - Gennaio 1222344
|
|
40
|
+
* - Gennaio 21 (when shouldSkipYearLikeDate=true)
|
|
39
41
|
*/
|
|
40
|
-
export default class
|
|
42
|
+
export default class ITMonthNameMiddleEndianParser extends AbstractParserWithWordBoundaryChecking {
|
|
43
|
+
shouldSkipYearLikeDate: boolean;
|
|
44
|
+
|
|
45
|
+
constructor(shouldSkipYearLikeDate: boolean) {
|
|
46
|
+
super();
|
|
47
|
+
this.shouldSkipYearLikeDate = shouldSkipYearLikeDate;
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
innerPattern(): RegExp {
|
|
42
51
|
return PATTERN;
|
|
43
52
|
}
|
|
@@ -49,10 +58,18 @@ export default class ENMonthNameMiddleEndianParser extends AbstractParserWithWor
|
|
|
49
58
|
return null;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
// Skip the case where the day looks like a year (ex: Gennaio 21)
|
|
62
|
+
if (this.shouldSkipYearLikeDate) {
|
|
63
|
+
if (!match[DATE_TO_GROUP] && !match[YEAR_GROUP] && match[DATE_GROUP].match(/^2[0-5]$/)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const components = context
|
|
68
|
+
.createParsingComponents({
|
|
69
|
+
day: day,
|
|
70
|
+
month: month,
|
|
71
|
+
})
|
|
72
|
+
.addTag("parser/ITMonthNameMiddleEndianParser");
|
|
56
73
|
|
|
57
74
|
if (match[YEAR_GROUP]) {
|
|
58
75
|
const year = parseYear(match[YEAR_GROUP]);
|
|
@@ -66,7 +83,7 @@ export default class ENMonthNameMiddleEndianParser extends AbstractParserWithWor
|
|
|
66
83
|
return components;
|
|
67
84
|
}
|
|
68
85
|
|
|
69
|
-
// Text can be 'range' value. Such as '
|
|
86
|
+
// Text can be 'range' value. Such as 'Gennaio 12 - 13, 2012'
|
|
70
87
|
const endDate = parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
|
71
88
|
const result = context.createParsingResult(match.index, match[0]);
|
|
72
89
|
result.start = components;
|
|
@@ -6,11 +6,11 @@ import { YEAR_PATTERN, parseYear } from "../constants";
|
|
|
6
6
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
7
7
|
|
|
8
8
|
const PATTERN = new RegExp(
|
|
9
|
-
`((?:in)\\s*)?` +
|
|
9
|
+
`((?:a|in|di|del)\\s*)?` +
|
|
10
10
|
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
11
11
|
`\\s*` +
|
|
12
12
|
`(?:` +
|
|
13
|
-
`
|
|
13
|
+
`(?:,|-|del)?\\s*(${YEAR_PATTERN})?` +
|
|
14
14
|
")?" +
|
|
15
15
|
"(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)",
|
|
16
16
|
"i"
|
|
@@ -22,12 +22,12 @@ const YEAR_GROUP = 3;
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The parser for parsing month name and year.
|
|
25
|
-
* -
|
|
26
|
-
* -
|
|
27
|
-
* -
|
|
28
|
-
* (in)
|
|
25
|
+
* - Gennaio, 2012
|
|
26
|
+
* - Gennaio 2012
|
|
27
|
+
* - Gennaio
|
|
28
|
+
* (a/in/di/del) Gen
|
|
29
29
|
*/
|
|
30
|
-
export default class
|
|
30
|
+
export default class ITMonthNameParser extends AbstractParserWithWordBoundaryChecking {
|
|
31
31
|
innerPattern(): RegExp {
|
|
32
32
|
return PATTERN;
|
|
33
33
|
}
|
|
@@ -35,7 +35,7 @@ export default class ENMonthNameParser extends AbstractParserWithWordBoundaryChe
|
|
|
35
35
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
36
36
|
const monthName = match[MONTH_NAME_GROUP].toLowerCase();
|
|
37
37
|
|
|
38
|
-
// skip some unlikely words "
|
|
38
|
+
// skip some unlikely words "gen", "mar", ..
|
|
39
39
|
if (match[0].length <= 3 && !FULL_MONTH_NAME_DICTIONARY[monthName]) {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
@@ -45,6 +45,7 @@ export default class ENMonthNameParser extends AbstractParserWithWordBoundaryChe
|
|
|
45
45
|
match.index + match[0].length
|
|
46
46
|
);
|
|
47
47
|
result.start.imply("day", 1);
|
|
48
|
+
result.start.addTag("parser/ITMonthNameParser");
|
|
48
49
|
|
|
49
50
|
const month = MONTH_DICTIONARY[monthName];
|
|
50
51
|
result.start.assign("month", month);
|
|
@@ -4,15 +4,24 @@ import { ParsingComponents } from "../../../results";
|
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
6
6
|
|
|
7
|
+
// Italian uses "il mese prossimo" (article + noun + modifier) more commonly than "il prossimo mese"
|
|
7
8
|
const PATTERN = new RegExp(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
"(?:" +
|
|
10
|
+
// Pattern 1: "il prossimo mese" / "la prossima settimana" (modifier before noun)
|
|
11
|
+
`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo\\s*questo|dopo\\s*questa)\\s*(${matchAnyPattern(TIME_UNIT_DICTIONARY)})` +
|
|
12
|
+
"|" +
|
|
13
|
+
// Pattern 2: "il mese prossimo" / "la settimana scorsa" (modifier after noun)
|
|
14
|
+
`(?:il\\s*|la\\s*|l'\\s*)(${matchAnyPattern(TIME_UNIT_DICTIONARY)})\\s*(scorso|scorsa|prossimo|prossima)` +
|
|
15
|
+
")(?=\\W|$)",
|
|
11
16
|
"i"
|
|
12
17
|
);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
const
|
|
19
|
+
// Pattern 1 groups
|
|
20
|
+
const MODIFIER_WORD_GROUP_1 = 1;
|
|
21
|
+
const RELATIVE_WORD_GROUP_1 = 2;
|
|
22
|
+
// Pattern 2 groups
|
|
23
|
+
const RELATIVE_WORD_GROUP_2 = 3;
|
|
24
|
+
const MODIFIER_WORD_GROUP_2 = 4;
|
|
16
25
|
|
|
17
26
|
export default class ITRelativeDateFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
18
27
|
innerPattern(): RegExp {
|
|
@@ -20,17 +29,29 @@ export default class ITRelativeDateFormatParser extends AbstractParserWithWordBo
|
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
// Determine which pattern matched
|
|
33
|
+
let modifier: string;
|
|
34
|
+
let unitWord: string;
|
|
35
|
+
|
|
36
|
+
if (match[MODIFIER_WORD_GROUP_1]) {
|
|
37
|
+
// Pattern 1: "il prossimo mese"
|
|
38
|
+
modifier = match[MODIFIER_WORD_GROUP_1].toLowerCase();
|
|
39
|
+
unitWord = match[RELATIVE_WORD_GROUP_1].toLowerCase();
|
|
40
|
+
} else {
|
|
41
|
+
// Pattern 2: "il mese prossimo"
|
|
42
|
+
modifier = match[MODIFIER_WORD_GROUP_2].toLowerCase();
|
|
43
|
+
unitWord = match[RELATIVE_WORD_GROUP_2].toLowerCase();
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
const timeunit = TIME_UNIT_DICTIONARY[unitWord];
|
|
26
47
|
|
|
27
|
-
if (modifier == "prossimo" || modifier.startsWith("dopo")) {
|
|
48
|
+
if (modifier == "prossimo" || modifier == "prossima" || modifier.startsWith("dopo")) {
|
|
28
49
|
const timeUnits = {};
|
|
29
50
|
timeUnits[timeunit] = 1;
|
|
30
51
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
31
52
|
}
|
|
32
53
|
|
|
33
|
-
if (modifier == "
|
|
54
|
+
if (modifier == "scorso" || modifier == "scorsa") {
|
|
34
55
|
const timeUnits = {};
|
|
35
56
|
timeUnits[timeunit] = -1;
|
|
36
57
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
@@ -39,7 +60,7 @@ export default class ITRelativeDateFormatParser extends AbstractParserWithWordBo
|
|
|
39
60
|
const components = context.createParsingComponents();
|
|
40
61
|
let date = new Date(context.reference.instant.getTime());
|
|
41
62
|
|
|
42
|
-
//
|
|
63
|
+
// Questa settimana
|
|
43
64
|
if (unitWord.match(/settimana/i)) {
|
|
44
65
|
date.setDate(date.getDate() - date.getDay());
|
|
45
66
|
components.imply("day", date.getDate());
|
|
@@ -47,7 +68,7 @@ export default class ITRelativeDateFormatParser extends AbstractParserWithWordBo
|
|
|
47
68
|
components.imply("year", date.getFullYear());
|
|
48
69
|
}
|
|
49
70
|
|
|
50
|
-
//
|
|
71
|
+
// Questo mese
|
|
51
72
|
else if (unitWord.match(/mese/i)) {
|
|
52
73
|
date.setDate(1);
|
|
53
74
|
components.imply("day", date.getDate());
|
|
@@ -55,7 +76,7 @@ export default class ITRelativeDateFormatParser extends AbstractParserWithWordBo
|
|
|
55
76
|
components.assign("month", date.getMonth() + 1);
|
|
56
77
|
}
|
|
57
78
|
|
|
58
|
-
//
|
|
79
|
+
// Quest'anno
|
|
59
80
|
else if (unitWord.match(/anno/i)) {
|
|
60
81
|
date.setDate(1);
|
|
61
82
|
date.setMonth(0);
|
|
@@ -12,7 +12,7 @@ const YEAR_GROUP = 2;
|
|
|
12
12
|
* - 11/05
|
|
13
13
|
* - 06/2005
|
|
14
14
|
*/
|
|
15
|
-
export default class
|
|
15
|
+
export default class ITSlashMonthFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
16
16
|
innerPattern(): RegExp {
|
|
17
17
|
return PATTERN;
|
|
18
18
|
}
|
|
@@ -1,55 +1,69 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { ParsingComponents } from "../../../results";
|
|
3
|
-
import { Meridiem } from "../../../
|
|
2
|
+
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
+
import { Meridiem } from "../../../types";
|
|
4
4
|
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
5
5
|
|
|
6
|
-
export default class
|
|
6
|
+
export default class ITTimeExpressionParser extends AbstractTimeExpressionParser {
|
|
7
7
|
constructor(strictMode) {
|
|
8
8
|
super(strictMode);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
followingPhase(): string {
|
|
12
|
-
return "\\s*(?:\\-|\\–|\\~|\\〜|
|
|
12
|
+
return "\\s*(?:\\-|\\–|\\~|\\〜|a|fino\\s*a|alle?|\\?)\\s*";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
primaryPrefix(): string {
|
|
16
|
-
return "(?:(?:alle
|
|
16
|
+
return "(?:(?:alle?|dalle?)\\s*)??";
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
primarySuffix(): string {
|
|
20
|
-
return "(?:\\s*(?:
|
|
20
|
+
return "(?:\\s*(?:di\\s*(?:sera|notte|mattina|pomeriggio)))?(?!/)(?=\\W|$)";
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
extractPrimaryTimeComponents(context: ParsingContext, match: RegExpMatchArray): null | ParsingComponents {
|
|
24
24
|
const components = super.extractPrimaryTimeComponents(context, match);
|
|
25
|
-
if (components) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (hour >= 6 && hour < 12) {
|
|
29
|
-
components.assign("hour", components.get("hour") + 12);
|
|
30
|
-
components.assign("meridiem", Meridiem.PM);
|
|
31
|
-
} else if (hour < 6) {
|
|
32
|
-
components.assign("meridiem", Meridiem.AM);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
25
|
+
if (!components) {
|
|
26
|
+
return components;
|
|
27
|
+
}
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
if (match[0].match(/di\s*(?:sera|notte)/i)) {
|
|
30
|
+
const hour = components.get("hour");
|
|
31
|
+
if (hour >= 6 && hour < 12) {
|
|
32
|
+
components.assign("hour", components.get("hour") + 12);
|
|
37
33
|
components.assign("meridiem", Meridiem.PM);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
components.assign("hour", components.get("hour") + 12);
|
|
41
|
-
}
|
|
34
|
+
} else if (hour < 6) {
|
|
35
|
+
components.assign("meridiem", Meridiem.AM);
|
|
42
36
|
}
|
|
37
|
+
}
|
|
43
38
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
39
|
+
if (match[0].match(/di\s*pomeriggio/i)) {
|
|
40
|
+
components.assign("meridiem", Meridiem.PM);
|
|
41
|
+
const hour = components.get("hour");
|
|
42
|
+
if (hour >= 0 && hour <= 6) {
|
|
43
|
+
components.assign("hour", components.get("hour") + 12);
|
|
50
44
|
}
|
|
51
45
|
}
|
|
52
46
|
|
|
53
|
-
|
|
47
|
+
if (match[0].match(/di\s*mattina/i)) {
|
|
48
|
+
components.assign("meridiem", Meridiem.AM);
|
|
49
|
+
const hour = components.get("hour");
|
|
50
|
+
if (hour < 12) {
|
|
51
|
+
components.assign("hour", components.get("hour"));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return components.addTag("parser/ITTimeExpressionParser");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
extractFollowingTimeComponents(
|
|
59
|
+
context: ParsingContext,
|
|
60
|
+
match: RegExpMatchArray,
|
|
61
|
+
result: ParsingResult
|
|
62
|
+
): ParsingComponents | null {
|
|
63
|
+
const followingComponents = super.extractFollowingTimeComponents(context, match, result);
|
|
64
|
+
if (followingComponents) {
|
|
65
|
+
followingComponents.addTag("parser/ITTimeExpressionParser");
|
|
66
|
+
}
|
|
67
|
+
return followingComponents;
|
|
54
68
|
}
|
|
55
69
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { parseDuration, TIME_UNITS_PATTERN } from "../constants";
|
|
2
|
+
import { parseDuration, TIME_UNITS_NO_ABBR_PATTERN, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
|
-
const PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:fa|prima
|
|
8
|
-
const STRICT_PATTERN = new RegExp(`(${
|
|
7
|
+
const PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:fa|prima)(?=\\W|$)`, "i");
|
|
8
|
+
const STRICT_PATTERN = new RegExp(`(${TIME_UNITS_NO_ABBR_PATTERN})\\s{0,5}(?:fa|prima)(?=\\W|$)`, "i");
|
|
9
9
|
|
|
10
|
-
export default class
|
|
10
|
+
export default class ITTimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
11
11
|
constructor(private strictMode: boolean) {
|
|
12
12
|
super();
|
|
13
13
|
}
|
|
@@ -17,9 +17,10 @@ export default class ENTimeUnitAgoFormatParser extends AbstractParserWithWordBou
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const duration = parseDuration(match[1]);
|
|
21
|
+
if (!duration) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return ParsingComponents.createRelativeFromReference(context.reference, reverseDuration(duration));
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
|
|
1
|
+
import { TIME_UNITS_PATTERN, parseDuration, TIME_UNITS_NO_ABBR_PATTERN } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
import { reverseDuration } from "../../../calculation/duration";
|
|
6
6
|
|
|
7
7
|
const PATTERN = new RegExp(
|
|
8
|
-
`(questo|
|
|
8
|
+
`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
9
9
|
"i"
|
|
10
10
|
);
|
|
11
|
+
const PATTERN_NO_ABBR = new RegExp(
|
|
12
|
+
`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo|\\+|-)\\s*(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`,
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default class ITTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
17
|
+
constructor(private allowAbbreviations: boolean = true) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
11
20
|
|
|
12
|
-
export default class ENTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
13
21
|
innerPattern(): RegExp {
|
|
14
|
-
return PATTERN;
|
|
22
|
+
return this.allowAbbreviations ? PATTERN : PATTERN_NO_ABBR;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
innerExtract(context: ParsingContext, match: RegExpMatchArray)
|
|
25
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
18
26
|
const prefix = match[1].toLowerCase();
|
|
19
|
-
let
|
|
27
|
+
let duration = parseDuration(match[2]);
|
|
28
|
+
if (!duration) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
20
31
|
switch (prefix) {
|
|
21
|
-
case "
|
|
22
|
-
case "
|
|
32
|
+
case "scorso":
|
|
33
|
+
case "scorsa":
|
|
23
34
|
case "-":
|
|
24
|
-
|
|
35
|
+
duration = reverseDuration(duration);
|
|
25
36
|
break;
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
38
|
+
return ParsingComponents.createRelativeFromReference(context.reference, duration);
|
|
29
39
|
}
|
|
30
40
|
}
|