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
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
|
-
}
|
|
@@ -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
|
}
|