chrono-node 2.9.2 → 2.10.1
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/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/ENMonthNameMiddleEndianParser.js +1 -1
- package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -1
- 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/results.js +15 -9
- package/dist/cjs/results.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/ENMonthNameMiddleEndianParser.js +1 -1
- package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -1
- 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/results.js +14 -9
- package/dist/esm/results.js.map +1 -1
- package/package.json +5 -1
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/parsers/ENMonthNameMiddleEndianParser.ts +1 -1
- 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/results.ts +40 -9
- 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
- package/test/calculation_duration.test.ts +0 -165
- package/test/calculation_weekdays.test.ts +0 -133
- package/test/de/de_casual.test.ts +0 -336
- package/test/de/de_dash.test.ts +0 -32
- package/test/de/de_month_name_little_endian.test.ts +0 -273
- package/test/de/de_time_exp.test.ts +0 -223
- package/test/de/de_time_units_casual_relative.test.ts +0 -120
- package/test/de/de_time_units_within.test.ts +0 -119
- package/test/de/de_weekday.test.ts +0 -158
- package/test/de/de_year.test.ts +0 -147
- package/test/debugging.test.ts +0 -17
- package/test/en/en.test.ts +0 -191
- package/test/en/en_casual.test.ts +0 -425
- package/test/en/en_inter_std.test.ts +0 -118
- package/test/en/en_merging_relative_dates.test.ts +0 -50
- package/test/en/en_month.test.ts +0 -339
- package/test/en/en_month_name_little_endian.test.ts +0 -448
- package/test/en/en_month_name_middle_endian.test.ts +0 -386
- package/test/en/en_performance.test.ts +0 -26
- package/test/en/en_relative.test.ts +0 -393
- package/test/en/en_slash.test.ts +0 -284
- package/test/en/en_time_exp.test.ts +0 -535
- package/test/en/en_time_units_ago.test.ts +0 -357
- package/test/en/en_time_units_casual_relative.test.ts +0 -186
- package/test/en/en_time_units_later.test.ts +0 -361
- package/test/en/en_time_units_within.test.ts +0 -417
- package/test/en/en_timezone_exp.test.ts +0 -410
- package/test/en/en_weekday.test.ts +0 -573
- package/test/en/en_year.test.ts +0 -138
- package/test/en/en_year_month_day.test.ts +0 -101
- package/test/en/negative_cases.test.ts +0 -99
- package/test/es/es_casual.test.ts +0 -175
- package/test/es/es_month_name_little_endian.test.ts +0 -217
- package/test/es/es_slash.test.ts +0 -26
- package/test/es/es_time_exp.test.ts +0 -175
- package/test/es/es_time_units_within.test.ts +0 -119
- package/test/fi/fi_casual.test.ts +0 -99
- package/test/fi/fi_casual_time.test.ts +0 -56
- package/test/fi/fi_month_name_little_endian.test.ts +0 -50
- package/test/fi/fi_time_exp.test.ts +0 -39
- package/test/fi/fi_time_units_ago.test.ts +0 -93
- package/test/fi/fi_time_units_casual_relative.test.ts +0 -117
- package/test/fi/fi_time_units_within.test.ts +0 -74
- package/test/fi/fi_weekday.test.ts +0 -90
- package/test/fr/fr_casual.test.ts +0 -314
- package/test/fr/fr_little_endian.test.ts +0 -320
- package/test/fr/fr_slash.test.ts +0 -49
- package/test/fr/fr_time_exp.test.ts +0 -588
- package/test/fr/fr_time_units_ago.test.ts +0 -103
- package/test/fr/fr_time_units_casual_relative.test.ts +0 -114
- package/test/fr/fr_time_units_within.test.ts +0 -129
- package/test/fr/fr_weekday.test.ts +0 -130
- package/test/it/it_casual.test.ts +0 -81
- package/test/it/it_month_name_little_endian.test.ts +0 -28
- package/test/it/it_month_name_middle_endian.test.ts +0 -39
- package/test/it/it_time_exp.test.ts +0 -84
- package/test/it/it_weekday.test.ts +0 -37
- package/test/it/it_year_month_day.test.ts +0 -41
- package/test/ja/ja_casual.test.ts +0 -73
- package/test/ja/ja_slash_date_format.test.ts +0 -60
- package/test/ja/ja_standard.test.ts +0 -235
- package/test/ja/ja_time_exp.test.ts +0 -305
- package/test/ja/ja_weekday.test.ts +0 -183
- package/test/nl/nl_casual.test.ts +0 -408
- package/test/nl/nl_month.test.ts +0 -205
- package/test/nl/nl_month_name_little_endian.test.ts +0 -358
- package/test/nl/nl_relative.test.ts +0 -242
- package/test/nl/nl_slash.test.ts +0 -206
- package/test/nl/nl_time_exp.test.ts +0 -79
- package/test/nl/nl_time_units_ago.test.ts +0 -243
- package/test/nl/nl_time_units_casual_relative.test.ts +0 -130
- package/test/nl/nl_time_units_later.test.ts +0 -250
- package/test/nl/nl_time_units_within.test.ts +0 -225
- package/test/nl/nl_weekday.test.ts +0 -216
- package/test/pt/pt_casual.test.ts +0 -175
- package/test/pt/pt_month_name_little_endian.test.ts +0 -217
- package/test/pt/pt_slash.test.ts +0 -26
- package/test/pt/pt_time_exp.test.ts +0 -175
- package/test/result.test.ts +0 -283
- package/test/ru/ru_casual.test.ts +0 -159
- package/test/ru/ru_month.test.ts +0 -70
- package/test/ru/ru_month_name_little_endian.test.ts +0 -145
- package/test/ru/ru_relative.test.ts +0 -107
- package/test/ru/ru_time_exp.test.ts +0 -111
- package/test/ru/ru_time_units_ago.test.ts +0 -48
- package/test/ru/ru_time_units_casual_relative.test.ts +0 -190
- package/test/ru/ru_time_units_within.test.ts +0 -16
- package/test/ru/ru_weekday.test.ts +0 -52
- package/test/sv/sv_casual.test.ts +0 -87
- package/test/sv/sv_month_name_little_endian.test.ts +0 -48
- package/test/sv/sv_time_units_casual_relative.test.ts +0 -143
- package/test/sv/sv_weekday.test.ts +0 -68
- package/test/system.test.ts +0 -247
- package/test/system_timezone.test.ts +0 -284
- package/test/test_util.ts +0 -135
- package/test/uk/uk_casual.test.ts +0 -153
- package/test/uk/uk_month.test.ts +0 -70
- package/test/uk/uk_month_name_little_endian.test.ts +0 -148
- package/test/uk/uk_relative.test.ts +0 -107
- package/test/uk/uk_time_exp.test.ts +0 -111
- package/test/uk/uk_time_units_ago.test.ts +0 -48
- package/test/uk/uk_time_units_casual_relative.test.ts +0 -142
- package/test/uk/uk_time_units_within.test.ts +0 -23
- package/test/uk/uk_weekday.test.ts +0 -52
- package/test/vi/vi_casual.test.ts +0 -84
- package/test/vi/vi_casual_time.test.ts +0 -77
- package/test/vi/vi_date_range.test.ts +0 -61
- package/test/vi/vi_forward_date.test.ts +0 -45
- package/test/vi/vi_month_year.test.ts +0 -40
- package/test/vi/vi_negative_cases.test.ts +0 -60
- package/test/vi/vi_slash.test.ts +0 -36
- package/test/vi/vi_standard.test.ts +0 -86
- package/test/vi/vi_strict.test.ts +0 -67
- package/test/vi/vi_time_exp.test.ts +0 -99
- package/test/vi/vi_time_units_ago.test.ts +0 -56
- package/test/vi/vi_time_units_casual_relative.test.ts +0 -56
- package/test/vi/vi_time_units_later.test.ts +0 -43
- package/test/vi/vi_time_units_within.test.ts +0 -24
- package/test/vi/vi_weekday.test.ts +0 -77
- package/test/vi/vi_year.test.ts +0 -42
- package/test/zh/hans/zh_hans_ago.test.ts +0 -58
- package/test/zh/hans/zh_hans_casual.test.ts +0 -242
- package/test/zh/hans/zh_hans_date.test.ts +0 -116
- package/test/zh/hans/zh_hans_deadline.test.ts +0 -175
- package/test/zh/hans/zh_hans_time_exp.test.ts +0 -508
- package/test/zh/hans/zh_hans_weekday.test.ts +0 -219
- package/test/zh/hant/zh_hant_ago.test.ts +0 -58
- package/test/zh/hant/zh_hant_casual.test.ts +0 -260
- package/test/zh/hant/zh_hant_date.test.ts +0 -116
- package/test/zh/hant/zh_hant_deadline.test.ts +0 -136
- package/test/zh/hant/zh_hant_time_exp.test.ts +0 -226
- package/test/zh/hant/zh_hant_weekday.test.ts +0 -175
- package/test/zh/zh.test.ts +0 -36
- package/tsconfig.build.esm.json +0 -8
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -29
|
@@ -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
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
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
|
|
|
6
6
|
const PATTERN = new RegExp(
|
|
7
|
-
`(${TIME_UNITS_PATTERN})\\s{0,5}(?:dopo|
|
|
7
|
+
`(${TIME_UNITS_PATTERN})\\s{0,5}(?:dopo|più\\s*tardi|da\\s*adesso|da\\s*ora)` + "(?=(?:\\W|$))",
|
|
8
8
|
"i"
|
|
9
9
|
);
|
|
10
10
|
|
|
11
|
-
const STRICT_PATTERN = new RegExp(
|
|
11
|
+
const STRICT_PATTERN = new RegExp(
|
|
12
|
+
`(${TIME_UNITS_NO_ABBR_PATTERN})\\s{0,5}(dopo|più\\s*tardi|da\\s*adesso|da\\s*ora)(?=\\W|$)`,
|
|
13
|
+
"i"
|
|
14
|
+
);
|
|
12
15
|
const GROUP_NUM_TIMEUNITS = 1;
|
|
13
16
|
|
|
14
|
-
export default class
|
|
17
|
+
export default class ITTimeUnitLaterFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
15
18
|
constructor(private strictMode: boolean) {
|
|
16
19
|
super();
|
|
17
20
|
}
|
|
@@ -21,7 +24,10 @@ export default class ENTimeUnitLaterFormatParser extends AbstractParserWithWordB
|
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
24
|
-
const
|
|
25
|
-
|
|
27
|
+
const timeUnits = parseDuration(match[GROUP_NUM_TIMEUNITS]);
|
|
28
|
+
if (!timeUnits) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
26
32
|
}
|
|
27
33
|
}
|
|
@@ -1,26 +1,46 @@
|
|
|
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
|
|
|
6
|
+
const PATTERN_WITH_OPTIONAL_PREFIX = new RegExp(
|
|
7
|
+
`(?:(?:entro|tra|fra|in|per)\\s*)?` +
|
|
8
|
+
`(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
9
|
+
"i"
|
|
10
|
+
);
|
|
11
|
+
|
|
6
12
|
const PATTERN_WITH_PREFIX = new RegExp(
|
|
7
|
-
`(?:
|
|
8
|
-
`(?:(?:più o meno|intorno|approssimativamente|verso|verso le)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
13
|
+
`(?:entro|tra|fra|in|per)\\s*` + `(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`,
|
|
9
14
|
"i"
|
|
10
15
|
);
|
|
11
16
|
|
|
12
|
-
const
|
|
13
|
-
`(?:
|
|
17
|
+
const PATTERN_WITH_PREFIX_STRICT = new RegExp(
|
|
18
|
+
`(?:entro|tra|fra|in|per)\\s*` +
|
|
19
|
+
`(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`,
|
|
14
20
|
"i"
|
|
15
21
|
);
|
|
16
22
|
|
|
17
|
-
export default class
|
|
23
|
+
export default class ITTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
24
|
+
constructor(private strictMode: boolean) {
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
innerPattern(context: ParsingContext): RegExp {
|
|
19
|
-
|
|
29
|
+
if (this.strictMode) {
|
|
30
|
+
return PATTERN_WITH_PREFIX_STRICT;
|
|
31
|
+
}
|
|
32
|
+
return context.option.forwardDate ? PATTERN_WITH_OPTIONAL_PREFIX : PATTERN_WITH_PREFIX;
|
|
20
33
|
}
|
|
21
34
|
|
|
22
|
-
innerExtract(context: ParsingContext, match: RegExpMatchArray)
|
|
35
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
36
|
+
// Exclude "per il/la unit" phases, e.g. "per l'anno"
|
|
37
|
+
if (match[0].match(/^per\s*(il|la|l')\s*\w+/)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
23
40
|
const timeUnits = parseDuration(match[1]);
|
|
41
|
+
if (!timeUnits) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
24
44
|
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
25
45
|
}
|
|
26
46
|
}
|
|
@@ -4,14 +4,14 @@ import { WEEKDAY_DICTIONARY } from "../constants";
|
|
|
4
4
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
5
5
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
6
|
import { createParsingComponentsAtWeekday } from "../../../calculation/weekdays";
|
|
7
|
+
import { Weekday } from "../../../types";
|
|
7
8
|
|
|
8
9
|
const PATTERN = new RegExp(
|
|
9
10
|
"(?:(?:\\,|\\(|\\()\\s*)?" +
|
|
10
|
-
"(?:
|
|
11
|
-
|
|
12
|
-
`(${matchAnyPattern(WEEKDAY_DICTIONARY)})` +
|
|
11
|
+
"(?:(questo|questa|quest'|scorso|scorsa|prossimo|prossima)\\s*)?" +
|
|
12
|
+
`(${matchAnyPattern(WEEKDAY_DICTIONARY)}|weekend|fine\\s*settimana)` +
|
|
13
13
|
"(?:\\s*(?:\\,|\\)|\\)))?" +
|
|
14
|
-
"(?:\\s*(
|
|
14
|
+
"(?:\\s*(scorso|scorsa|prossimo|prossima)(?:\\s*settimana)?)?" +
|
|
15
15
|
"(?=\\W|$)",
|
|
16
16
|
"i"
|
|
17
17
|
);
|
|
@@ -25,9 +25,7 @@ export default class ITWeekdayParser extends AbstractParserWithWordBoundaryCheck
|
|
|
25
25
|
return PATTERN;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
29
|
-
const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
|
30
|
-
const weekday = WEEKDAY_DICTIONARY[dayOfWeek];
|
|
28
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | null {
|
|
31
29
|
const prefix = match[PREFIX_GROUP];
|
|
32
30
|
const postfix = match[POSTFIX_GROUP];
|
|
33
31
|
let modifierWord = prefix || postfix;
|
|
@@ -35,13 +33,25 @@ export default class ITWeekdayParser extends AbstractParserWithWordBoundaryCheck
|
|
|
35
33
|
modifierWord = modifierWord.toLowerCase();
|
|
36
34
|
|
|
37
35
|
let modifier = null;
|
|
38
|
-
if (modifierWord == "
|
|
39
|
-
modifier = "
|
|
40
|
-
} else if (modifierWord == "prossima") {
|
|
41
|
-
modifier = "
|
|
42
|
-
} else if (modifierWord == "questa") {
|
|
43
|
-
modifier = "
|
|
36
|
+
if (modifierWord == "scorso" || modifierWord == "scorsa") {
|
|
37
|
+
modifier = "last";
|
|
38
|
+
} else if (modifierWord == "prossimo" || modifierWord == "prossima") {
|
|
39
|
+
modifier = "next";
|
|
40
|
+
} else if (modifierWord == "questo" || modifierWord == "questa" || modifierWord == "quest'") {
|
|
41
|
+
modifier = "this";
|
|
44
42
|
}
|
|
43
|
+
|
|
44
|
+
const weekday_word = match[WEEKDAY_GROUP].toLowerCase();
|
|
45
|
+
let weekday;
|
|
46
|
+
if (WEEKDAY_DICTIONARY[weekday_word] !== undefined) {
|
|
47
|
+
weekday = WEEKDAY_DICTIONARY[weekday_word];
|
|
48
|
+
} else if (weekday_word == "weekend" || weekday_word.match(/fine\s*settimana/)) {
|
|
49
|
+
// 'Questo/prossimo weekend' means the coming Saturday, 'scorso weekend' means last Sunday.
|
|
50
|
+
weekday = modifier == "last" ? Weekday.SUNDAY : Weekday.SATURDAY;
|
|
51
|
+
} else {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
return createParsingComponentsAtWeekday(context.reference, weekday, modifier);
|
|
46
56
|
}
|
|
47
57
|
}
|
|
@@ -4,15 +4,15 @@ import { matchAnyPattern } from "../../../utils/pattern";
|
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
|
-
Date format with slash "/" between numbers like
|
|
7
|
+
Date format with slash "/" between numbers like ITSlashDateFormatParser,
|
|
8
8
|
but this parser expect year before month and date.
|
|
9
9
|
- YYYY/MM/DD
|
|
10
10
|
- YYYY-MM-DD
|
|
11
11
|
- YYYY.MM.DD
|
|
12
12
|
*/
|
|
13
13
|
const PATTERN = new RegExp(
|
|
14
|
-
`([0-9]{4})[
|
|
15
|
-
`(?:(${matchAnyPattern(MONTH_DICTIONARY)})|([0-9]{1,2}))[
|
|
14
|
+
`([0-9]{4})[-\\.\\/\\s]` +
|
|
15
|
+
`(?:(${matchAnyPattern(MONTH_DICTIONARY)})|([0-9]{1,2}))[-\\.\\/\\s]` +
|
|
16
16
|
`([0-9]{1,2})` +
|
|
17
17
|
"(?=\\W|$)",
|
|
18
18
|
"i"
|
|
@@ -23,23 +23,34 @@ const MONTH_NAME_GROUP = 2;
|
|
|
23
23
|
const MONTH_NUMBER_GROUP = 3;
|
|
24
24
|
const DATE_NUMBER_GROUP = 4;
|
|
25
25
|
|
|
26
|
-
export default class
|
|
26
|
+
export default class ITYearMonthDayParser extends AbstractParserWithWordBoundaryChecking {
|
|
27
|
+
constructor(private strictMonthDateOrder: boolean) {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
innerPattern(): RegExp {
|
|
28
32
|
return PATTERN;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
32
|
-
const
|
|
36
|
+
const year = parseInt(match[YEAR_NUMBER_GROUP]);
|
|
37
|
+
let day = parseInt(match[DATE_NUMBER_GROUP]);
|
|
38
|
+
let month = match[MONTH_NUMBER_GROUP]
|
|
33
39
|
? parseInt(match[MONTH_NUMBER_GROUP])
|
|
34
40
|
: MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
|
35
41
|
|
|
36
42
|
if (month < 1 || month > 12) {
|
|
43
|
+
if (this.strictMonthDateOrder) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (day >= 1 && day <= 12) {
|
|
47
|
+
[month, day] = [day, month];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (day < 1 || day > 31) {
|
|
37
51
|
return null;
|
|
38
52
|
}
|
|
39
53
|
|
|
40
|
-
const year = parseInt(match[YEAR_NUMBER_GROUP]);
|
|
41
|
-
const day = parseInt(match[DATE_NUMBER_GROUP]);
|
|
42
|
-
|
|
43
54
|
return {
|
|
44
55
|
day: day,
|
|
45
56
|
month: month,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ParsingContext, Refiner } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { YEAR_PATTERN, parseYear } from "../constants";
|
|
4
|
+
|
|
5
|
+
const YEAR_SUFFIX_PATTERN = new RegExp(`^\\s*(${YEAR_PATTERN})`, "i");
|
|
6
|
+
const YEAR_GROUP = 1;
|
|
7
|
+
export default class ITExtractYearSuffixRefiner implements Refiner {
|
|
8
|
+
refine(context: ParsingContext, results: ParsingResult[]): ParsingResult[] {
|
|
9
|
+
results.forEach(function (result) {
|
|
10
|
+
if (!result.start.isDateWithUnknownYear()) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const suffix = context.text.substring(result.index + result.text.length);
|
|
14
|
+
const match = YEAR_SUFFIX_PATTERN.exec(suffix);
|
|
15
|
+
if (!match) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// If the suffix match is just a short number, e.g. "14/4 90", don't assume it year.
|
|
19
|
+
if (match[0].trim().length <= 3) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
context.debug(() => {
|
|
23
|
+
console.log(`Extracting year: '${match[0]}' into : ${result}`);
|
|
24
|
+
});
|
|
25
|
+
const year = parseYear(match[YEAR_GROUP]);
|
|
26
|
+
if (result.end != null) {
|
|
27
|
+
result.end.assign("year", year);
|
|
28
|
+
}
|
|
29
|
+
result.start.assign("year", year);
|
|
30
|
+
result.text += match[0];
|
|
31
|
+
});
|
|
32
|
+
return results;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
import AbstractMergeDateRangeRefiner from "../../../common/refiners/AbstractMergeDateRangeRefiner";
|
|
6
2
|
|
|
7
3
|
/**
|
|
8
4
|
* Merging before and after results (see. AbstractMergeDateRangeRefiner)
|
|
9
|
-
* This implementation should provide
|
|
10
|
-
* - 2020-02-13 [
|
|
11
|
-
* -
|
|
5
|
+
* This implementation should provide Italian connecting phases
|
|
6
|
+
* - 2020-02-13 [a] 2020-02-13
|
|
7
|
+
* - Mercoledì [-] Venerdì
|
|
12
8
|
*/
|
|
13
|
-
export default class
|
|
9
|
+
export default class ITMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner {
|
|
14
10
|
patternBetween(): RegExp {
|
|
15
|
-
return /^\s*(
|
|
11
|
+
return /^\s*(a|al|-|–|fino\s*a|fino\s*al)\s*$/i;
|
|
16
12
|
}
|
|
17
13
|
}
|
|
@@ -2,12 +2,12 @@ import AbstractMergeDateTimeRefiner from "../../../common/refiners/AbstractMerge
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Merging date-only result and time-only result (see. AbstractMergeDateTimeRefiner).
|
|
5
|
-
* This implementation should provide
|
|
6
|
-
* - 2020-02-13 [
|
|
7
|
-
* -
|
|
5
|
+
* This implementation should provide Italian connecting phases
|
|
6
|
+
* - 2020-02-13 [alle] 18
|
|
7
|
+
* - Domani [dopo le] 7
|
|
8
8
|
*/
|
|
9
|
-
export default class
|
|
9
|
+
export default class ITMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner {
|
|
10
10
|
patternBetween(): RegExp {
|
|
11
|
-
return new RegExp("^\\s*(T|alle
|
|
11
|
+
return new RegExp("^\\s*(T|alle?|dopo\\s*le|prima\\s*delle?|,|-|\\.|∙|:)?\\s*$");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MergingRefiner } from "../../../common/abstractRefiners";
|
|
2
|
+
import { ParsingComponents, ParsingResult, ReferenceWithTimezone } from "../../../results";
|
|
3
|
+
import { parseDuration } from "../constants";
|
|
4
|
+
import { reverseDuration } from "../../../calculation/duration";
|
|
5
|
+
|
|
6
|
+
function IsPositiveFollowingReference(result: ParsingResult): boolean {
|
|
7
|
+
return result.text.match(/^[+-]/i) != null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function IsNegativeFollowingReference(result: ParsingResult): boolean {
|
|
11
|
+
return result.text.match(/^-/i) != null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Merges a relative data/time that comes after an absolute date.
|
|
16
|
+
* - [2020-02-13] [+2 settimane]
|
|
17
|
+
* - [martedì prossimo] [+10 giorni]
|
|
18
|
+
*/
|
|
19
|
+
export default class ITMergeRelativeAfterDateRefiner extends MergingRefiner {
|
|
20
|
+
shouldMergeResults(textBetween: string, currentResult: ParsingResult, nextResult: ParsingResult): boolean {
|
|
21
|
+
if (!textBetween.match(/^\s*$/i)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return IsPositiveFollowingReference(nextResult) || IsNegativeFollowingReference(nextResult);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
mergeResults(textBetween: string, currentResult: ParsingResult, nextResult: ParsingResult, context): ParsingResult {
|
|
29
|
+
let timeUnits = parseDuration(nextResult.text);
|
|
30
|
+
if (IsNegativeFollowingReference(nextResult)) {
|
|
31
|
+
timeUnits = reverseDuration(timeUnits);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const components = ParsingComponents.createRelativeFromReference(
|
|
35
|
+
ReferenceWithTimezone.fromDate(currentResult.start.date()),
|
|
36
|
+
timeUnits
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return new ParsingResult(
|
|
40
|
+
currentResult.reference,
|
|
41
|
+
currentResult.index,
|
|
42
|
+
`${currentResult.text}${textBetween}${nextResult.text}`,
|
|
43
|
+
components
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -4,19 +4,19 @@ import { parseDuration } from "../constants";
|
|
|
4
4
|
import { reverseDuration } from "../../../calculation/duration";
|
|
5
5
|
|
|
6
6
|
function hasImpliedEarlierReferenceDate(result: ParsingResult): boolean {
|
|
7
|
-
return result.text.match(/\s+(prima|
|
|
7
|
+
return result.text.match(/\s+(prima|da)$/i) != null;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
function hasImpliedLaterReferenceDate(result: ParsingResult): boolean {
|
|
11
|
-
return result.text.match(/\s+(dopo|dal
|
|
11
|
+
return result.text.match(/\s+(dopo|dal?)$/i) != null;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Merges
|
|
16
|
-
* - 2
|
|
17
|
-
* - 2
|
|
15
|
+
* Merges a relative data/time that follow by an absolute date.
|
|
16
|
+
* - [2 settimane prima] [2020-02-13]
|
|
17
|
+
* - [2 giorni dopo] [venerdì prossimo]
|
|
18
18
|
*/
|
|
19
|
-
export default class
|
|
19
|
+
export default class ITMergeRelativeFollowByDateRefiner extends MergingRefiner {
|
|
20
20
|
patternBetween(): RegExp {
|
|
21
21
|
return /^\s*$/i;
|
|
22
22
|
}
|
|
@@ -28,7 +28,7 @@ export default class ENMergeRelativeDateRefiner extends MergingRefiner {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Check if any relative tokens were swallowed by the first date.
|
|
31
|
-
// E.g. [<relative_date1>
|
|
31
|
+
// E.g. [<relative_date1> da] [<date2>]
|
|
32
32
|
if (!hasImpliedEarlierReferenceDate(currentResult) && !hasImpliedLaterReferenceDate(currentResult)) {
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
@@ -38,14 +38,14 @@ export default class ENMergeRelativeDateRefiner extends MergingRefiner {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
mergeResults(textBetween: string, currentResult: ParsingResult, nextResult: ParsingResult): ParsingResult {
|
|
41
|
-
let
|
|
41
|
+
let duration = parseDuration(currentResult.text);
|
|
42
42
|
if (hasImpliedEarlierReferenceDate(currentResult)) {
|
|
43
|
-
|
|
43
|
+
duration = reverseDuration(duration);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const components = ParsingComponents.createRelativeFromReference(
|
|
47
47
|
ReferenceWithTimezone.fromDate(nextResult.start.date()),
|
|
48
|
-
|
|
48
|
+
duration
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
return new ParsingResult(
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Filter } from "../../../common/abstractRefiners";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
|
|
4
|
+
export default class ITUnlikelyFormatFilter extends Filter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
isValid(context, result: ParsingResult): boolean {
|
|
10
|
+
const text = result.text.trim();
|
|
11
|
+
|
|
12
|
+
// If the result is consists of the whole text (e.g. "2024", "Maggio", etc),
|
|
13
|
+
// then it is unlikely to be a date.
|
|
14
|
+
if (text === context.text.trim()) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// In Italian, "secondo" could refer to the ordinal number or timeunit.
|
|
19
|
+
if (text.toLowerCase().endsWith("il secondo") || text.toLowerCase() === "secondo") {
|
|
20
|
+
const textAfter = context.text.substring(result.index + result.text.length).trim();
|
|
21
|
+
if (textAfter.length > 0) {
|
|
22
|
+
context.debug(() => {
|
|
23
|
+
console.log(`Removing unlikely result: ${result}`);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/results.ts
CHANGED
|
@@ -232,13 +232,26 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
isValidDate(): boolean {
|
|
235
|
-
|
|
235
|
+
// Check calendar validity in UTC. The local Date constructor would wrongly reject real
|
|
236
|
+
// times falling in the system timezone's DST gap, making validity depend on where it runs.
|
|
237
|
+
const date = new Date(
|
|
238
|
+
Date.UTC(
|
|
239
|
+
this.get("year"),
|
|
240
|
+
this.get("month") - 1,
|
|
241
|
+
this.get("day"),
|
|
242
|
+
this.get("hour"),
|
|
243
|
+
this.get("minute"),
|
|
244
|
+
this.get("second"),
|
|
245
|
+
this.get("millisecond")
|
|
246
|
+
)
|
|
247
|
+
);
|
|
248
|
+
date.setUTCFullYear(this.get("year"));
|
|
236
249
|
|
|
237
|
-
if (date.
|
|
238
|
-
if (date.
|
|
239
|
-
if (date.
|
|
240
|
-
if (this.get("hour") != null && date.
|
|
241
|
-
if (this.get("minute") != null && date.
|
|
250
|
+
if (date.getUTCFullYear() !== this.get("year")) return false;
|
|
251
|
+
if (date.getUTCMonth() !== this.get("month") - 1) return false;
|
|
252
|
+
if (date.getUTCDate() !== this.get("day")) return false;
|
|
253
|
+
if (this.get("hour") != null && date.getUTCHours() != this.get("hour")) return false;
|
|
254
|
+
if (this.get("minute") != null && date.getUTCMinutes() != this.get("minute")) return false;
|
|
242
255
|
|
|
243
256
|
return true;
|
|
244
257
|
}
|
|
@@ -252,9 +265,27 @@ export class ParsingComponents implements ParsedComponents {
|
|
|
252
265
|
}
|
|
253
266
|
|
|
254
267
|
date(): Date {
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
268
|
+
const timezoneOffset = this.get("timezoneOffset") ?? this.reference.timezoneOffset;
|
|
269
|
+
if (timezoneOffset === null || timezoneOffset === undefined) {
|
|
270
|
+
// No timezone known: interpret the components as system-local time.
|
|
271
|
+
return this.dateWithoutTimezoneAdjustment();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// The offset fully determines the instant, so build it from UTC. The local Date constructor
|
|
275
|
+
// would be ambiguous for wall-clock times in the system timezone's DST gap/overlap.
|
|
276
|
+
const date = new Date(
|
|
277
|
+
Date.UTC(
|
|
278
|
+
this.get("year"),
|
|
279
|
+
this.get("month") - 1,
|
|
280
|
+
this.get("day"),
|
|
281
|
+
this.get("hour"),
|
|
282
|
+
this.get("minute"),
|
|
283
|
+
this.get("second"),
|
|
284
|
+
this.get("millisecond")
|
|
285
|
+
)
|
|
286
|
+
);
|
|
287
|
+
date.setUTCFullYear(this.get("year"));
|
|
288
|
+
return new Date(date.getTime() - timezoneOffset * 60000);
|
|
258
289
|
}
|
|
259
290
|
|
|
260
291
|
addTag(tag: string): ParsingComponents {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ITCasualYearMonthDayParser.js","sourceRoot":"","sources":["../../../../../src/locales/it/parsers/ITCasualYearMonthDayParser.ts"],"names":[],"mappings":";;AACA,4CAAgD;AAChD,oDAAyD;AACzD,2GAAgH;AAShH,MAAM,OAAO,GAAG,IAAI,MAAM,CACtB,uBAAuB;IACnB,OAAO,IAAA,yBAAe,EAAC,4BAAgB,CAAC,4BAA4B;IACpE,cAAc;IACd,WAAW,EACf,GAAG,CACN,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,MAAqB,0BAA2B,SAAQ,uEAAsC;IAC1F,YAAY;QACR,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,Y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WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACjB,CAAC;QAID,IAAI,CAAC,8BAA8B,CAAC,aAAa,CAAC,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,EAAE,CAAC;YACjG,OAAO,KAAK,CAAC;QACjB,CAAC;QAGD,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9G,CAAC;IAED,YAAY,CAAC,WAAmB,EAAE,aAA4B,EAAE,UAAyB;QACrF,IAAI,SAAS,GAAG,IAAA,yBAAa,EAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,8BAA8B,CAAC,aAAa,CAAC,EAAE,CAAC;YAChD,SAAS,GAAG,IAAA,0BAAe,EAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,UAAU,GAAG,2BAAiB,CAAC,2BAA2B,CAC5D,+BAAqB,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EACvD,SAAS,CACZ,CAAC;QAEF,OAAO,IAAI,uBAAa,CACpB,UAAU,CAAC,SAAS,EACpB,aAAa,CAAC,KAAK,EACnB,GAAG,aAAa,CAAC,IAAI,GAAG,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,EACvD,UAAU,CACb,CAAC;IACN,CAAC;CACJ;AAvCD,6CAuCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ITCasualYearMonthDayParser.js","sourceRoot":"","sources":["../../../../../src/locales/it/parsers/ITCasualYearMonthDayParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc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