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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Configuration } from "../../chrono";
|
|
2
|
+
|
|
3
|
+
import ITTimeUnitWithinFormatParser from "./parsers/ITTimeUnitWithinFormatParser";
|
|
4
|
+
import ITMonthNameLittleEndianParser from "./parsers/ITMonthNameLittleEndianParser";
|
|
5
|
+
import ITMonthNameMiddleEndianParser from "./parsers/ITMonthNameMiddleEndianParser";
|
|
6
|
+
import ITMonthNameParser from "./parsers/ITMonthNameParser";
|
|
7
|
+
import ITYearMonthDayParser from "./parsers/ITYearMonthDayParser";
|
|
8
|
+
import ITSlashMonthFormatParser from "./parsers/ITSlashMonthFormatParser";
|
|
9
|
+
import ITTimeExpressionParser from "./parsers/ITTimeExpressionParser";
|
|
10
|
+
import ITTimeUnitAgoFormatParser from "./parsers/ITTimeUnitAgoFormatParser";
|
|
11
|
+
import ITTimeUnitLaterFormatParser from "./parsers/ITTimeUnitLaterFormatParser";
|
|
12
|
+
import ITMergeDateRangeRefiner from "./refiners/ITMergeDateRangeRefiner";
|
|
13
|
+
import ITMergeDateTimeRefiner from "./refiners/ITMergeDateTimeRefiner";
|
|
14
|
+
|
|
15
|
+
import { includeCommonConfiguration } from "../../configurations";
|
|
16
|
+
import ITCasualDateParser from "./parsers/ITCasualDateParser";
|
|
17
|
+
import ITCasualTimeParser from "./parsers/ITCasualTimeParser";
|
|
18
|
+
import ITWeekdayParser from "./parsers/ITWeekdayParser";
|
|
19
|
+
import ITRelativeDateFormatParser from "./parsers/ITRelativeDateFormatParser";
|
|
20
|
+
|
|
21
|
+
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
22
|
+
import ITTimeUnitCasualRelativeFormatParser from "./parsers/ITTimeUnitCasualRelativeFormatParser";
|
|
23
|
+
import ITMergeRelativeAfterDateRefiner from "./refiners/ITMergeRelativeAfterDateRefiner";
|
|
24
|
+
import ITMergeRelativeFollowByDateRefiner from "./refiners/ITMergeRelativeFollowByDateRefiner";
|
|
25
|
+
import OverlapRemovalRefiner from "../../common/refiners/OverlapRemovalRefiner";
|
|
26
|
+
import ITExtractYearSuffixRefiner from "./refiners/ITExtractYearSuffixRefiner";
|
|
27
|
+
import ITUnlikelyFormatFilter from "./refiners/ITUnlikelyFormatFilter";
|
|
28
|
+
|
|
29
|
+
export default class ITDefaultConfiguration {
|
|
30
|
+
/**
|
|
31
|
+
* Create a default *casual* {@link Configuration} for Italian chrono.
|
|
32
|
+
* It calls {@link createConfiguration} and includes additional parsers.
|
|
33
|
+
*/
|
|
34
|
+
createCasualConfiguration(): Configuration {
|
|
35
|
+
const option = this.createConfiguration(false);
|
|
36
|
+
option.parsers.push(new ITCasualDateParser());
|
|
37
|
+
option.parsers.push(new ITCasualTimeParser());
|
|
38
|
+
option.parsers.push(new ITMonthNameParser());
|
|
39
|
+
option.parsers.push(new ITRelativeDateFormatParser());
|
|
40
|
+
option.parsers.push(new ITTimeUnitCasualRelativeFormatParser());
|
|
41
|
+
option.refiners.push(new ITUnlikelyFormatFilter());
|
|
42
|
+
return option;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a default {@link Configuration} for Italian chrono
|
|
47
|
+
*
|
|
48
|
+
* @param strictMode If the timeunit mentioning should be strict, not casual
|
|
49
|
+
*/
|
|
50
|
+
createConfiguration(strictMode = true): Configuration {
|
|
51
|
+
const options = includeCommonConfiguration(
|
|
52
|
+
{
|
|
53
|
+
parsers: [
|
|
54
|
+
new SlashDateFormatParser(true), // Italian uses day/month/year format (littleEndian)
|
|
55
|
+
new ITTimeUnitWithinFormatParser(strictMode),
|
|
56
|
+
new ITMonthNameLittleEndianParser(),
|
|
57
|
+
new ITMonthNameMiddleEndianParser(/*shouldSkipYearLikeDate=*/ true),
|
|
58
|
+
new ITWeekdayParser(),
|
|
59
|
+
new ITSlashMonthFormatParser(),
|
|
60
|
+
new ITTimeExpressionParser(strictMode),
|
|
61
|
+
new ITTimeUnitAgoFormatParser(strictMode),
|
|
62
|
+
new ITTimeUnitLaterFormatParser(strictMode),
|
|
63
|
+
],
|
|
64
|
+
refiners: [new ITMergeDateTimeRefiner()],
|
|
65
|
+
},
|
|
66
|
+
strictMode
|
|
67
|
+
);
|
|
68
|
+
options.parsers.unshift(new ITYearMonthDayParser(/*strictMonthDateOrder=*/ strictMode));
|
|
69
|
+
|
|
70
|
+
// These relative-dates consideration should be done before other common refiners.
|
|
71
|
+
options.refiners.unshift(new ITMergeRelativeFollowByDateRefiner());
|
|
72
|
+
options.refiners.unshift(new ITMergeRelativeAfterDateRefiner());
|
|
73
|
+
options.refiners.unshift(new OverlapRemovalRefiner());
|
|
74
|
+
|
|
75
|
+
// Re-apply the date time refiner again after the timezone refinement and exclusion in common refiners.
|
|
76
|
+
options.refiners.push(new ITMergeDateTimeRefiner());
|
|
77
|
+
|
|
78
|
+
// Extract year after merging date and time
|
|
79
|
+
options.refiners.push(new ITExtractYearSuffixRefiner());
|
|
80
|
+
|
|
81
|
+
// Keep the date range refiner at the end (after all other refinements).
|
|
82
|
+
options.refiners.push(new ITMergeDateRangeRefiner());
|
|
83
|
+
return options;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -1,162 +1,293 @@
|
|
|
1
1
|
import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
|
|
2
2
|
import { findMostLikelyADYear } from "../../calculation/years";
|
|
3
3
|
import { Duration } from "../../calculation/duration";
|
|
4
|
-
import { Timeunit } from "../../types";
|
|
5
|
-
|
|
6
|
-
export const WEEKDAY_DICTIONARY: { [word: string]:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
import { Timeunit, Weekday } from "../../types";
|
|
5
|
+
|
|
6
|
+
export const WEEKDAY_DICTIONARY: { [word: string]: Weekday } = {
|
|
7
|
+
domenica: 0,
|
|
8
|
+
dom: 0,
|
|
9
|
+
"dom.": 0,
|
|
10
|
+
lunedì: 1,
|
|
11
|
+
lunedi: 1,
|
|
12
|
+
lun: 1,
|
|
13
|
+
"lun.": 1,
|
|
14
|
+
martedì: 2,
|
|
15
|
+
martedi: 2,
|
|
16
|
+
mar: 2,
|
|
17
|
+
"mar.": 2,
|
|
18
|
+
mercoledì: 3,
|
|
19
|
+
mercoledi: 3,
|
|
20
|
+
mer: 3,
|
|
21
|
+
"mer.": 3,
|
|
22
|
+
giovedì: 4,
|
|
23
|
+
giovedi: 4,
|
|
24
|
+
gio: 4,
|
|
25
|
+
"gio.": 4,
|
|
26
|
+
venerdì: 5,
|
|
27
|
+
venerdi: 5,
|
|
28
|
+
ven: 5,
|
|
29
|
+
"ven.": 5,
|
|
30
|
+
sabato: 6,
|
|
31
|
+
sab: 6,
|
|
32
|
+
"sab.": 6,
|
|
21
33
|
};
|
|
22
34
|
|
|
23
|
-
export const FULL_MONTH_NAME_DICTIONARY: { [word: string]: number } = {
|
|
35
|
+
export const FULL_MONTH_NAME_DICTIONARY: { [word: string]: number } = {
|
|
36
|
+
gennaio: 1,
|
|
37
|
+
febbraio: 2,
|
|
38
|
+
marzo: 3,
|
|
39
|
+
aprile: 4,
|
|
40
|
+
maggio: 5,
|
|
41
|
+
giugno: 6,
|
|
42
|
+
luglio: 7,
|
|
43
|
+
agosto: 8,
|
|
44
|
+
settembre: 9,
|
|
45
|
+
ottobre: 10,
|
|
46
|
+
novembre: 11,
|
|
47
|
+
dicembre: 12,
|
|
48
|
+
};
|
|
24
49
|
|
|
25
50
|
export const MONTH_DICTIONARY: { [word: string]: number } = {
|
|
26
51
|
...FULL_MONTH_NAME_DICTIONARY,
|
|
27
|
-
|
|
28
|
-
"gen": 1,
|
|
52
|
+
gen: 1,
|
|
29
53
|
"gen.": 1,
|
|
30
|
-
|
|
31
|
-
"feb": 2,
|
|
54
|
+
feb: 2,
|
|
32
55
|
"feb.": 2,
|
|
33
|
-
|
|
34
|
-
"febb": 2,
|
|
35
|
-
"febb.": 2,
|
|
36
|
-
"marzo": 3,
|
|
37
|
-
"mar": 3,
|
|
56
|
+
mar: 3,
|
|
38
57
|
"mar.": 3,
|
|
39
|
-
|
|
40
|
-
"apr": 4,
|
|
58
|
+
apr: 4,
|
|
41
59
|
"apr.": 4,
|
|
42
|
-
|
|
43
|
-
"mag": 5,
|
|
44
|
-
|
|
45
|
-
"giu": 6,
|
|
46
|
-
|
|
47
|
-
"lug": 7,
|
|
48
|
-
"lugl": 7,
|
|
60
|
+
mag: 5,
|
|
61
|
+
"mag.": 5,
|
|
62
|
+
giu: 6,
|
|
63
|
+
"giu.": 6,
|
|
64
|
+
lug: 7,
|
|
49
65
|
"lug.": 7,
|
|
50
|
-
|
|
51
|
-
"ago": 8,
|
|
52
|
-
|
|
53
|
-
"set": 9,
|
|
66
|
+
ago: 8,
|
|
67
|
+
"ago.": 8,
|
|
68
|
+
set: 9,
|
|
54
69
|
"set.": 9,
|
|
55
|
-
|
|
70
|
+
sett: 9,
|
|
56
71
|
"sett.": 9,
|
|
57
|
-
|
|
58
|
-
"ott": 10,
|
|
72
|
+
ott: 10,
|
|
59
73
|
"ott.": 10,
|
|
60
|
-
|
|
61
|
-
"nov": 11,
|
|
74
|
+
nov: 11,
|
|
62
75
|
"nov.": 11,
|
|
63
|
-
|
|
64
|
-
"dic": 12,
|
|
65
|
-
"dice": 12,
|
|
76
|
+
dic: 12,
|
|
66
77
|
"dic.": 12,
|
|
67
78
|
};
|
|
68
79
|
|
|
69
80
|
export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
uno: 1,
|
|
82
|
+
una: 1,
|
|
83
|
+
un: 1,
|
|
84
|
+
due: 2,
|
|
85
|
+
tre: 3,
|
|
86
|
+
quattro: 4,
|
|
87
|
+
cinque: 5,
|
|
88
|
+
sei: 6,
|
|
89
|
+
sette: 7,
|
|
90
|
+
otto: 8,
|
|
91
|
+
nove: 9,
|
|
92
|
+
dieci: 10,
|
|
93
|
+
undici: 11,
|
|
94
|
+
dodici: 12,
|
|
82
95
|
};
|
|
83
96
|
|
|
84
97
|
export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
98
|
+
primo: 1,
|
|
99
|
+
prima: 1,
|
|
100
|
+
"1°": 1,
|
|
101
|
+
"1ª": 1,
|
|
102
|
+
secondo: 2,
|
|
103
|
+
seconda: 2,
|
|
104
|
+
"2°": 2,
|
|
105
|
+
"2ª": 2,
|
|
106
|
+
terzo: 3,
|
|
107
|
+
terza: 3,
|
|
108
|
+
"3°": 3,
|
|
109
|
+
"3ª": 3,
|
|
110
|
+
quarto: 4,
|
|
111
|
+
quarta: 4,
|
|
112
|
+
"4°": 4,
|
|
113
|
+
"4ª": 4,
|
|
114
|
+
quinto: 5,
|
|
115
|
+
quinta: 5,
|
|
116
|
+
"5°": 5,
|
|
117
|
+
"5ª": 5,
|
|
118
|
+
sesto: 6,
|
|
119
|
+
sesta: 6,
|
|
120
|
+
"6°": 6,
|
|
121
|
+
"6ª": 6,
|
|
122
|
+
settimo: 7,
|
|
123
|
+
settima: 7,
|
|
124
|
+
"7°": 7,
|
|
125
|
+
"7ª": 7,
|
|
126
|
+
ottavo: 8,
|
|
127
|
+
ottava: 8,
|
|
128
|
+
"8°": 8,
|
|
129
|
+
"8ª": 8,
|
|
130
|
+
nono: 9,
|
|
131
|
+
nona: 9,
|
|
132
|
+
"9°": 9,
|
|
133
|
+
"9ª": 9,
|
|
134
|
+
decimo: 10,
|
|
135
|
+
decima: 10,
|
|
136
|
+
"10°": 10,
|
|
137
|
+
"10ª": 10,
|
|
138
|
+
undicesimo: 11,
|
|
139
|
+
undicesima: 11,
|
|
140
|
+
"11°": 11,
|
|
141
|
+
"11ª": 11,
|
|
142
|
+
dodicesimo: 12,
|
|
143
|
+
dodicesima: 12,
|
|
144
|
+
"12°": 12,
|
|
145
|
+
"12ª": 12,
|
|
146
|
+
tredicesimo: 13,
|
|
147
|
+
tredicesima: 13,
|
|
148
|
+
"13°": 13,
|
|
149
|
+
"13ª": 13,
|
|
150
|
+
quattordicesimo: 14,
|
|
151
|
+
quattordicesima: 14,
|
|
152
|
+
"14°": 14,
|
|
153
|
+
"14ª": 14,
|
|
154
|
+
quindicesimo: 15,
|
|
155
|
+
quindicesima: 15,
|
|
156
|
+
"15°": 15,
|
|
157
|
+
"15ª": 15,
|
|
158
|
+
sedicesimo: 16,
|
|
159
|
+
sedicesima: 16,
|
|
160
|
+
"16°": 16,
|
|
161
|
+
"16ª": 16,
|
|
162
|
+
diciassettesimo: 17,
|
|
163
|
+
diciassettesima: 17,
|
|
164
|
+
"17°": 17,
|
|
165
|
+
"17ª": 17,
|
|
166
|
+
diciottesimo: 18,
|
|
167
|
+
diciottesima: 18,
|
|
168
|
+
"18°": 18,
|
|
169
|
+
"18ª": 18,
|
|
170
|
+
diciannovesimo: 19,
|
|
171
|
+
diciannovesima: 19,
|
|
172
|
+
"19°": 19,
|
|
173
|
+
"19ª": 19,
|
|
174
|
+
ventesimo: 20,
|
|
175
|
+
ventesima: 20,
|
|
176
|
+
"20°": 20,
|
|
177
|
+
"20ª": 20,
|
|
178
|
+
ventunesimo: 21,
|
|
179
|
+
ventunesima: 21,
|
|
180
|
+
"21°": 21,
|
|
181
|
+
"21ª": 21,
|
|
182
|
+
ventiduesimo: 22,
|
|
183
|
+
ventiduesima: 22,
|
|
184
|
+
"22°": 22,
|
|
185
|
+
"22ª": 22,
|
|
186
|
+
ventitreesimo: 23,
|
|
187
|
+
ventitreesima: 23,
|
|
188
|
+
"23°": 23,
|
|
189
|
+
"23ª": 23,
|
|
190
|
+
ventiquattresimo: 24,
|
|
191
|
+
ventiquattresima: 24,
|
|
192
|
+
"24°": 24,
|
|
193
|
+
"24ª": 24,
|
|
194
|
+
venticinquesimo: 25,
|
|
195
|
+
venticinquesima: 25,
|
|
196
|
+
"25°": 25,
|
|
197
|
+
"25ª": 25,
|
|
198
|
+
ventiseiesimo: 26,
|
|
199
|
+
ventiseiesima: 26,
|
|
200
|
+
"26°": 26,
|
|
201
|
+
"26ª": 26,
|
|
202
|
+
ventisettesimo: 27,
|
|
203
|
+
ventisettesima: 27,
|
|
204
|
+
"27°": 27,
|
|
205
|
+
"27ª": 27,
|
|
206
|
+
ventottesimo: 28,
|
|
207
|
+
ventottesima: 28,
|
|
208
|
+
"28°": 28,
|
|
209
|
+
"28ª": 28,
|
|
210
|
+
ventinovesimo: 29,
|
|
211
|
+
ventinovesima: 29,
|
|
212
|
+
"29°": 29,
|
|
213
|
+
"29ª": 29,
|
|
214
|
+
trentesimo: 30,
|
|
215
|
+
trentesima: 30,
|
|
216
|
+
"30°": 30,
|
|
217
|
+
"30ª": 30,
|
|
218
|
+
trentunesimo: 31,
|
|
219
|
+
trentunesima: 31,
|
|
220
|
+
"31°": 31,
|
|
221
|
+
"31ª": 31,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export const TIME_UNIT_DICTIONARY_NO_ABBR: { [word: string]: Timeunit } = {
|
|
225
|
+
secondo: "second",
|
|
226
|
+
secondi: "second",
|
|
227
|
+
minuto: "minute",
|
|
228
|
+
minuti: "minute",
|
|
229
|
+
ora: "hour",
|
|
230
|
+
ore: "hour",
|
|
231
|
+
giorno: "day",
|
|
232
|
+
giorni: "day",
|
|
233
|
+
settimana: "week",
|
|
234
|
+
settimane: "week",
|
|
235
|
+
mese: "month",
|
|
236
|
+
mesi: "month",
|
|
237
|
+
trimestre: "quarter",
|
|
238
|
+
trimestri: "quarter",
|
|
239
|
+
anno: "year",
|
|
240
|
+
anni: "year",
|
|
116
241
|
};
|
|
117
242
|
|
|
118
243
|
export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
244
|
+
s: "second",
|
|
245
|
+
sec: "second",
|
|
246
|
+
secondo: "second",
|
|
247
|
+
secondi: "second",
|
|
248
|
+
m: "minute",
|
|
249
|
+
min: "minute",
|
|
250
|
+
minuto: "minute",
|
|
251
|
+
minuti: "minute",
|
|
252
|
+
h: "hour",
|
|
253
|
+
ora: "hour",
|
|
254
|
+
ore: "hour",
|
|
255
|
+
g: "day",
|
|
256
|
+
gg: "day",
|
|
257
|
+
giorno: "day",
|
|
258
|
+
giorni: "day",
|
|
259
|
+
sett: "week",
|
|
260
|
+
settimana: "week",
|
|
261
|
+
settimane: "week",
|
|
262
|
+
mese: "month",
|
|
263
|
+
mesi: "month",
|
|
264
|
+
trim: "quarter",
|
|
265
|
+
trimestre: "quarter",
|
|
266
|
+
trimestri: "quarter",
|
|
267
|
+
anno: "year",
|
|
268
|
+
anni: "year",
|
|
269
|
+
...TIME_UNIT_DICTIONARY_NO_ABBR,
|
|
139
270
|
};
|
|
140
271
|
|
|
141
272
|
//-----------------------------
|
|
142
273
|
|
|
143
274
|
export const NUMBER_PATTERN = `(?:${matchAnyPattern(
|
|
144
275
|
INTEGER_WORD_DICTIONARY
|
|
145
|
-
)}|[0-9]+|[0-9]+\\.[0-9]+|
|
|
276
|
+
)}|[0-9]+|[0-9]+\\.[0-9]+|mezz[oa]?(?:\\s{0,2})?|un(?:'|\\s{0,2})?|qualche|alcuni|paio\\s{0,2}(?:di)?)`;
|
|
146
277
|
|
|
147
278
|
export function parseNumberPattern(match: string): number {
|
|
148
279
|
const num = match.toLowerCase();
|
|
149
280
|
if (INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
|
150
281
|
return INTEGER_WORD_DICTIONARY[num];
|
|
151
|
-
} else if (num === "un" || num === "una") {
|
|
282
|
+
} else if (num === "un" || num === "un'" || num === "una" || num === "uno") {
|
|
152
283
|
return 1;
|
|
153
|
-
} else if (num.match(/
|
|
284
|
+
} else if (num.match(/qualche/)) {
|
|
154
285
|
return 3;
|
|
155
|
-
} else if (num.match(/
|
|
286
|
+
} else if (num.match(/mezz/)) {
|
|
156
287
|
return 0.5;
|
|
157
288
|
} else if (num.match(/paio/)) {
|
|
158
289
|
return 2;
|
|
159
|
-
} else if (num.match(/
|
|
290
|
+
} else if (num.match(/alcuni/)) {
|
|
160
291
|
return 7;
|
|
161
292
|
}
|
|
162
293
|
|
|
@@ -165,22 +296,20 @@ export function parseNumberPattern(match: string): number {
|
|
|
165
296
|
|
|
166
297
|
//-----------------------------
|
|
167
298
|
|
|
168
|
-
export const ORDINAL_NUMBER_PATTERN = `(?:${matchAnyPattern(
|
|
169
|
-
ORDINAL_WORD_DICTIONARY
|
|
170
|
-
)}|[0-9]{1,2}(?:mo|ndo|rzo|simo|esimo)?)`;
|
|
299
|
+
export const ORDINAL_NUMBER_PATTERN = `(?:${matchAnyPattern(ORDINAL_WORD_DICTIONARY)}|[0-9]{1,2}(?:°|ª|º)?)`;
|
|
171
300
|
export function parseOrdinalNumberPattern(match: string): number {
|
|
172
301
|
let num = match.toLowerCase();
|
|
173
302
|
if (ORDINAL_WORD_DICTIONARY[num] !== undefined) {
|
|
174
303
|
return ORDINAL_WORD_DICTIONARY[num];
|
|
175
304
|
}
|
|
176
305
|
|
|
177
|
-
num = num.replace(/(
|
|
306
|
+
num = num.replace(/(?:°|ª|º)$/i, "");
|
|
178
307
|
return parseInt(num);
|
|
179
308
|
}
|
|
180
309
|
|
|
181
310
|
//-----------------------------
|
|
182
311
|
|
|
183
|
-
export const YEAR_PATTERN = `(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-2][0-9]{3}|[5-9][0-9])`;
|
|
312
|
+
export const YEAR_PATTERN = `(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-2][0-9]{3}|[5-9][0-9]|2[0-5])`;
|
|
184
313
|
export function parseYear(match: string): number {
|
|
185
314
|
if (/BE/i.test(match)) {
|
|
186
315
|
// Buddhist Era
|
|
@@ -209,9 +338,24 @@ export function parseYear(match: string): number {
|
|
|
209
338
|
const SINGLE_TIME_UNIT_PATTERN = `(${NUMBER_PATTERN})\\s{0,3}(${matchAnyPattern(TIME_UNIT_DICTIONARY)})`;
|
|
210
339
|
const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
211
340
|
|
|
212
|
-
|
|
341
|
+
const SINGLE_TIME_UNIT_NO_ABBR_PATTERN = `(${NUMBER_PATTERN})\\s{0,3}(${matchAnyPattern(
|
|
342
|
+
TIME_UNIT_DICTIONARY_NO_ABBR
|
|
343
|
+
)})`;
|
|
344
|
+
|
|
345
|
+
const TIME_UNIT_CONNECTOR_PATTERN = `\\s{0,5},?(?:\\s*e)?\\s{0,5}`;
|
|
346
|
+
|
|
347
|
+
export const TIME_UNITS_PATTERN = repeatedTimeunitPattern(
|
|
348
|
+
`(?:(?:circa|approssimativamente)\\s{0,3})?`,
|
|
349
|
+
SINGLE_TIME_UNIT_PATTERN,
|
|
350
|
+
TIME_UNIT_CONNECTOR_PATTERN
|
|
351
|
+
);
|
|
352
|
+
export const TIME_UNITS_NO_ABBR_PATTERN = repeatedTimeunitPattern(
|
|
353
|
+
`(?:(?:circa|approssimativamente)\\s{0,3})?`,
|
|
354
|
+
SINGLE_TIME_UNIT_NO_ABBR_PATTERN,
|
|
355
|
+
TIME_UNIT_CONNECTOR_PATTERN
|
|
356
|
+
);
|
|
213
357
|
|
|
214
|
-
export function parseDuration(timeunitText): Duration {
|
|
358
|
+
export function parseDuration(timeunitText): null | Duration {
|
|
215
359
|
const fragments = {};
|
|
216
360
|
let remainingText = timeunitText;
|
|
217
361
|
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
@@ -220,10 +364,16 @@ export function parseDuration(timeunitText): Duration {
|
|
|
220
364
|
remainingText = remainingText.substring(match[0].length).trim();
|
|
221
365
|
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
222
366
|
}
|
|
367
|
+
if (Object.keys(fragments).length == 0) {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
223
370
|
return fragments as Duration;
|
|
224
371
|
}
|
|
225
372
|
|
|
226
373
|
function collectDateTimeFragment(fragments, match) {
|
|
374
|
+
if (match[0].match(/^[a-zA-Z]+$/)) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
227
377
|
const num = parseNumberPattern(match[1]);
|
|
228
378
|
const unit = TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
|
229
379
|
fragments[unit] = num;
|
package/src/locales/it/index.ts
CHANGED
|
@@ -4,96 +4,37 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import ENMonthNameParser from "./parsers/ITMonthNameParser";
|
|
11
|
-
import ENCasualYearMonthDayParser from "./parsers/ITCasualYearMonthDayParser";
|
|
12
|
-
import ENSlashMonthFormatParser from "./parsers/ITSlashMonthFormatParser";
|
|
13
|
-
import ENTimeExpressionParser from "./parsers/ITTimeExpressionParser";
|
|
14
|
-
import ENTimeUnitAgoFormatParser from "./parsers/ITTimeUnitAgoFormatParser";
|
|
15
|
-
import ENTimeUnitLaterFormatParser from "./parsers/ITTimeUnitLaterFormatParser";
|
|
16
|
-
import ENMergeDateRangeRefiner from "./refiners/ITMergeDateRangeRefiner";
|
|
17
|
-
import ENMergeDateTimeRefiner from "./refiners/ITMergeDateTimeRefiner";
|
|
7
|
+
import { Chrono, Parser, Refiner } from "../../chrono";
|
|
8
|
+
import { ParsingResult, ParsingComponents, ReferenceWithTimezone } from "../../results";
|
|
9
|
+
import { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday } from "../../types";
|
|
18
10
|
|
|
19
|
-
import
|
|
20
|
-
import ENCasualDateParser from "./parsers/ITCasualDateParser";
|
|
21
|
-
import ENCasualTimeParser from "./parsers/ITCasualTimeParser";
|
|
22
|
-
import ENWeekdayParser from "./parsers/ITWeekdayParser";
|
|
23
|
-
import ITRelativeDateFormatParser from "./parsers/ITRelativeDateFormatParser";
|
|
11
|
+
import ITDefaultConfiguration from "./configuration";
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import ENMergeRelativeDateRefiner from "./refiners/ITMergeRelativeDateRefiner";
|
|
13
|
+
export { Chrono, Parser, Refiner, ParsingResult, ParsingComponents, ReferenceWithTimezone };
|
|
14
|
+
export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Weekday };
|
|
15
|
+
|
|
16
|
+
export const configuration = new ITDefaultConfiguration();
|
|
30
17
|
|
|
31
18
|
/**
|
|
32
19
|
* Chrono object configured for parsing *casual* Italian
|
|
33
20
|
*/
|
|
34
|
-
export const casual = new Chrono(createCasualConfiguration(
|
|
21
|
+
export const casual = new Chrono(configuration.createCasualConfiguration());
|
|
35
22
|
|
|
36
23
|
/**
|
|
37
24
|
* Chrono object configured for parsing *strict* Italian
|
|
38
25
|
*/
|
|
39
|
-
export const strict = new Chrono(createConfiguration(true
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Chrono object configured for parsing Italian
|
|
43
|
-
*/
|
|
44
|
-
export const GB = new Chrono(createConfiguration(false, true));
|
|
26
|
+
export const strict = new Chrono(configuration.createConfiguration(true));
|
|
45
27
|
|
|
46
28
|
/**
|
|
47
|
-
* A shortcut for
|
|
29
|
+
* A shortcut for it.casual.parse()
|
|
48
30
|
*/
|
|
49
|
-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
|
|
31
|
+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
|
|
50
32
|
return casual.parse(text, ref, option);
|
|
51
33
|
}
|
|
52
34
|
|
|
53
35
|
/**
|
|
54
|
-
* A shortcut for
|
|
36
|
+
* A shortcut for it.casual.parseDate()
|
|
55
37
|
*/
|
|
56
|
-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
|
|
38
|
+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
|
|
57
39
|
return casual.parseDate(text, ref, option);
|
|
58
40
|
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Create a default *casual* {@Link Configuration} for Italian chrono.
|
|
62
|
-
* It calls {@Link createConfiguration} and includes additional parsers.
|
|
63
|
-
*/
|
|
64
|
-
export function createCasualConfiguration(littleEndian = false): Configuration {
|
|
65
|
-
const option = createConfiguration(false, littleEndian);
|
|
66
|
-
option.parsers.unshift(new ENCasualDateParser());
|
|
67
|
-
option.parsers.unshift(new ENCasualTimeParser());
|
|
68
|
-
option.parsers.unshift(new ENMonthNameParser());
|
|
69
|
-
option.parsers.unshift(new ITRelativeDateFormatParser());
|
|
70
|
-
option.parsers.unshift(new ENTimeUnitCasualRelativeFormatParser());
|
|
71
|
-
return option;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create a default {@Link Configuration} for Italian chrono
|
|
76
|
-
*
|
|
77
|
-
* @param strictMode If the timeunit mentioning should be strict, not casual
|
|
78
|
-
* @param littleEndian If format should be date-first/littleEndian (e.g. en_UK), not month-first/middleEndian (e.g. en_US)
|
|
79
|
-
*/
|
|
80
|
-
export function createConfiguration(strictMode = true, littleEndian = false): Configuration {
|
|
81
|
-
return includeCommonConfiguration(
|
|
82
|
-
{
|
|
83
|
-
parsers: [
|
|
84
|
-
new SlashDateFormatParser(littleEndian),
|
|
85
|
-
new ENTimeUnitWithinFormatParser(),
|
|
86
|
-
new ENMonthNameLittleEndianParser(),
|
|
87
|
-
new ENMonthNameMiddleEndianParser(),
|
|
88
|
-
new ENWeekdayParser(),
|
|
89
|
-
new ENCasualYearMonthDayParser(),
|
|
90
|
-
new ENSlashMonthFormatParser(),
|
|
91
|
-
new ENTimeExpressionParser(strictMode),
|
|
92
|
-
new ENTimeUnitAgoFormatParser(strictMode),
|
|
93
|
-
new ENTimeUnitLaterFormatParser(strictMode),
|
|
94
|
-
],
|
|
95
|
-
refiners: [new ENMergeRelativeDateRefiner(), new ENMergeDateTimeRefiner(), new ENMergeDateRangeRefiner()],
|
|
96
|
-
},
|
|
97
|
-
strictMode
|
|
98
|
-
);
|
|
99
|
-
}
|