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.
Files changed (319) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/locales/en/constants.d.ts +1 -1
  3. package/dist/cjs/locales/en/constants.js +1 -1
  4. package/dist/cjs/locales/en/constants.js.map +1 -1
  5. package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.js +1 -1
  6. package/dist/cjs/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -1
  7. package/dist/cjs/locales/fr/constants.js +13 -0
  8. package/dist/cjs/locales/fr/constants.js.map +1 -1
  9. package/dist/cjs/locales/it/configuration.d.ts +5 -0
  10. package/dist/cjs/locales/it/configuration.js +66 -0
  11. package/dist/cjs/locales/it/configuration.js.map +1 -0
  12. package/dist/cjs/locales/it/constants.d.ts +8 -4
  13. package/dist/cjs/locales/it/constants.js +216 -90
  14. package/dist/cjs/locales/it/constants.js.map +1 -1
  15. package/dist/cjs/locales/it/index.d.ts +9 -7
  16. package/dist/cjs/locales/it/index.js +13 -51
  17. package/dist/cjs/locales/it/index.js.map +1 -1
  18. package/dist/cjs/locales/it/parsers/ITCasualDateParser.js +19 -10
  19. package/dist/cjs/locales/it/parsers/ITCasualDateParser.js.map +1 -1
  20. package/dist/cjs/locales/it/parsers/ITCasualTimeParser.d.ts +1 -1
  21. package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js +70 -37
  22. package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
  23. package/dist/cjs/locales/it/parsers/ITMonthNameLittleEndianParser.d.ts +1 -1
  24. package/dist/cjs/locales/it/parsers/ITMonthNameLittleEndianParser.js +6 -6
  25. package/dist/cjs/locales/it/parsers/ITMonthNameLittleEndianParser.js.map +1 -1
  26. package/dist/cjs/locales/it/parsers/ITMonthNameMiddleEndianParser.d.ts +4 -2
  27. package/dist/cjs/locales/it/parsers/ITMonthNameMiddleEndianParser.js +17 -6
  28. package/dist/cjs/locales/it/parsers/ITMonthNameMiddleEndianParser.js.map +1 -1
  29. package/dist/cjs/locales/it/parsers/ITMonthNameParser.d.ts +2 -2
  30. package/dist/cjs/locales/it/parsers/ITMonthNameParser.js +5 -4
  31. package/dist/cjs/locales/it/parsers/ITMonthNameParser.js.map +1 -1
  32. package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js +21 -7
  33. package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
  34. package/dist/cjs/locales/it/parsers/ITSlashMonthFormatParser.d.ts +1 -1
  35. package/dist/cjs/locales/it/parsers/ITSlashMonthFormatParser.js +2 -2
  36. package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.d.ts +3 -2
  37. package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.js +37 -29
  38. package/dist/cjs/locales/it/parsers/ITTimeExpressionParser.js.map +1 -1
  39. package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.d.ts +1 -1
  40. package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js +9 -7
  41. package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
  42. package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.d.ts +3 -1
  43. package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +17 -9
  44. package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
  45. package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.d.ts +1 -1
  46. package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js +9 -6
  47. package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
  48. package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.d.ts +3 -1
  49. package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js +21 -6
  50. package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
  51. package/dist/cjs/locales/it/parsers/ITWeekdayParser.d.ts +1 -1
  52. package/dist/cjs/locales/it/parsers/ITWeekdayParser.js +21 -12
  53. package/dist/cjs/locales/it/parsers/ITWeekdayParser.js.map +1 -1
  54. package/dist/cjs/locales/it/parsers/{ITCasualYearMonthDayParser.d.ts → ITYearMonthDayParser.d.ts} +3 -1
  55. package/dist/cjs/locales/it/parsers/{ITCasualYearMonthDayParser.js → ITYearMonthDayParser.js} +20 -8
  56. package/dist/cjs/locales/it/parsers/ITYearMonthDayParser.js.map +1 -0
  57. package/dist/cjs/locales/it/refiners/ITExtractYearSuffixRefiner.d.ts +5 -0
  58. package/dist/cjs/locales/it/refiners/ITExtractYearSuffixRefiner.js +34 -0
  59. package/dist/cjs/locales/it/refiners/ITExtractYearSuffixRefiner.js.map +1 -0
  60. package/dist/cjs/locales/it/refiners/ITMergeDateRangeRefiner.d.ts +1 -1
  61. package/dist/cjs/locales/it/refiners/ITMergeDateRangeRefiner.js +3 -3
  62. package/dist/cjs/locales/it/refiners/ITMergeDateRangeRefiner.js.map +1 -1
  63. package/dist/cjs/locales/it/refiners/ITMergeDateTimeRefiner.d.ts +1 -1
  64. package/dist/cjs/locales/it/refiners/ITMergeDateTimeRefiner.js +3 -3
  65. package/dist/cjs/locales/it/refiners/ITMergeDateTimeRefiner.js.map +1 -1
  66. package/dist/cjs/locales/it/refiners/ITMergeRelativeAfterDateRefiner.d.ts +6 -0
  67. package/dist/cjs/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js +30 -0
  68. package/dist/cjs/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js.map +1 -0
  69. package/dist/cjs/locales/it/refiners/{ITMergeRelativeDateRefiner.d.ts → ITMergeRelativeFollowByDateRefiner.d.ts} +1 -1
  70. package/dist/cjs/locales/it/refiners/{ITMergeRelativeDateRefiner.js → ITMergeRelativeFollowByDateRefiner.js} +8 -8
  71. package/dist/cjs/locales/it/refiners/ITMergeRelativeFollowByDateRefiner.js.map +1 -0
  72. package/dist/cjs/locales/it/refiners/ITUnlikelyFormatFilter.d.ts +6 -0
  73. package/dist/cjs/locales/it/refiners/ITUnlikelyFormatFilter.js +26 -0
  74. package/dist/cjs/locales/it/refiners/ITUnlikelyFormatFilter.js.map +1 -0
  75. package/dist/cjs/results.js +15 -9
  76. package/dist/cjs/results.js.map +1 -1
  77. package/dist/esm/locales/en/constants.d.ts +1 -1
  78. package/dist/esm/locales/en/constants.js +1 -1
  79. package/dist/esm/locales/en/constants.js.map +1 -1
  80. package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.js +1 -1
  81. package/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.js.map +1 -1
  82. package/dist/esm/locales/fr/constants.js +13 -0
  83. package/dist/esm/locales/fr/constants.js.map +1 -1
  84. package/dist/esm/locales/it/configuration.d.ts +5 -0
  85. package/dist/esm/locales/it/configuration.js +60 -0
  86. package/dist/esm/locales/it/configuration.js.map +1 -0
  87. package/dist/esm/locales/it/constants.d.ts +8 -4
  88. package/dist/esm/locales/it/constants.js +256 -117
  89. package/dist/esm/locales/it/constants.js.map +1 -1
  90. package/dist/esm/locales/it/index.d.ts +9 -7
  91. package/dist/esm/locales/it/index.js +8 -48
  92. package/dist/esm/locales/it/index.js.map +1 -1
  93. package/dist/esm/locales/it/parsers/ITCasualDateParser.js +19 -10
  94. package/dist/esm/locales/it/parsers/ITCasualDateParser.js.map +1 -1
  95. package/dist/esm/locales/it/parsers/ITCasualTimeParser.d.ts +1 -1
  96. package/dist/esm/locales/it/parsers/ITCasualTimeParser.js +37 -37
  97. package/dist/esm/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
  98. package/dist/esm/locales/it/parsers/ITMonthNameLittleEndianParser.d.ts +1 -1
  99. package/dist/esm/locales/it/parsers/ITMonthNameLittleEndianParser.js +5 -5
  100. package/dist/esm/locales/it/parsers/ITMonthNameLittleEndianParser.js.map +1 -1
  101. package/dist/esm/locales/it/parsers/ITMonthNameMiddleEndianParser.d.ts +4 -2
  102. package/dist/esm/locales/it/parsers/ITMonthNameMiddleEndianParser.js +17 -5
  103. package/dist/esm/locales/it/parsers/ITMonthNameMiddleEndianParser.js.map +1 -1
  104. package/dist/esm/locales/it/parsers/ITMonthNameParser.d.ts +2 -2
  105. package/dist/esm/locales/it/parsers/ITMonthNameParser.js +4 -3
  106. package/dist/esm/locales/it/parsers/ITMonthNameParser.js.map +1 -1
  107. package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js +21 -7
  108. package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
  109. package/dist/esm/locales/it/parsers/ITSlashMonthFormatParser.d.ts +1 -1
  110. package/dist/esm/locales/it/parsers/ITSlashMonthFormatParser.js +1 -1
  111. package/dist/esm/locales/it/parsers/ITTimeExpressionParser.d.ts +3 -2
  112. package/dist/esm/locales/it/parsers/ITTimeExpressionParser.js +35 -27
  113. package/dist/esm/locales/it/parsers/ITTimeExpressionParser.js.map +1 -1
  114. package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.d.ts +1 -1
  115. package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js +9 -7
  116. package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
  117. package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.d.ts +3 -1
  118. package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +18 -9
  119. package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
  120. package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.d.ts +1 -1
  121. package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js +9 -6
  122. package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
  123. package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.d.ts +3 -1
  124. package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js +22 -6
  125. package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
  126. package/dist/esm/locales/it/parsers/ITWeekdayParser.d.ts +1 -1
  127. package/dist/esm/locales/it/parsers/ITWeekdayParser.js +21 -12
  128. package/dist/esm/locales/it/parsers/ITWeekdayParser.js.map +1 -1
  129. package/dist/esm/locales/it/parsers/{ITCasualYearMonthDayParser.d.ts → ITYearMonthDayParser.d.ts} +3 -1
  130. package/dist/esm/locales/it/parsers/{ITCasualYearMonthDayParser.js → ITYearMonthDayParser.js} +20 -7
  131. package/dist/esm/locales/it/parsers/ITYearMonthDayParser.js.map +1 -0
  132. package/dist/esm/locales/it/refiners/ITExtractYearSuffixRefiner.d.ts +5 -0
  133. package/dist/esm/locales/it/refiners/ITExtractYearSuffixRefiner.js +31 -0
  134. package/dist/esm/locales/it/refiners/ITExtractYearSuffixRefiner.js.map +1 -0
  135. package/dist/esm/locales/it/refiners/ITMergeDateRangeRefiner.d.ts +1 -1
  136. package/dist/esm/locales/it/refiners/ITMergeDateRangeRefiner.js +2 -2
  137. package/dist/esm/locales/it/refiners/ITMergeDateRangeRefiner.js.map +1 -1
  138. package/dist/esm/locales/it/refiners/ITMergeDateTimeRefiner.d.ts +1 -1
  139. package/dist/esm/locales/it/refiners/ITMergeDateTimeRefiner.js +2 -2
  140. package/dist/esm/locales/it/refiners/ITMergeDateTimeRefiner.js.map +1 -1
  141. package/dist/esm/locales/it/refiners/ITMergeRelativeAfterDateRefiner.d.ts +6 -0
  142. package/dist/esm/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js +27 -0
  143. package/dist/esm/locales/it/refiners/ITMergeRelativeAfterDateRefiner.js.map +1 -0
  144. package/dist/esm/locales/it/refiners/{ITMergeRelativeDateRefiner.d.ts → ITMergeRelativeFollowByDateRefiner.d.ts} +1 -1
  145. package/dist/esm/locales/it/refiners/{ITMergeRelativeDateRefiner.js → ITMergeRelativeFollowByDateRefiner.js} +7 -7
  146. package/dist/esm/locales/it/refiners/ITMergeRelativeFollowByDateRefiner.js.map +1 -0
  147. package/dist/esm/locales/it/refiners/ITUnlikelyFormatFilter.d.ts +6 -0
  148. package/dist/esm/locales/it/refiners/ITUnlikelyFormatFilter.js +23 -0
  149. package/dist/esm/locales/it/refiners/ITUnlikelyFormatFilter.js.map +1 -0
  150. package/dist/esm/results.js +14 -9
  151. package/dist/esm/results.js.map +1 -1
  152. package/package.json +5 -1
  153. package/src/locales/en/constants.ts +1 -1
  154. package/src/locales/en/parsers/ENMonthNameMiddleEndianParser.ts +1 -1
  155. package/src/locales/fr/constants.ts +13 -0
  156. package/src/locales/it/configuration.ts +85 -0
  157. package/src/locales/it/constants.ts +273 -123
  158. package/src/locales/it/index.ts +14 -73
  159. package/src/locales/it/parsers/ITCasualDateParser.ts +20 -12
  160. package/src/locales/it/parsers/ITCasualTimeParser.ts +39 -44
  161. package/src/locales/it/parsers/ITMonthNameLittleEndianParser.ts +6 -6
  162. package/src/locales/it/parsers/ITMonthNameMiddleEndianParser.ts +34 -17
  163. package/src/locales/it/parsers/ITMonthNameParser.ts +9 -8
  164. package/src/locales/it/parsers/ITRelativeDateFormatParser.ts +33 -12
  165. package/src/locales/it/parsers/ITSlashMonthFormatParser.ts +1 -1
  166. package/src/locales/it/parsers/ITTimeExpressionParser.ts +42 -28
  167. package/src/locales/it/parsers/ITTimeUnitAgoFormatParser.ts +9 -8
  168. package/src/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.ts +21 -11
  169. package/src/locales/it/parsers/ITTimeUnitLaterFormatParser.ts +12 -6
  170. package/src/locales/it/parsers/ITTimeUnitWithinFormatParser.ts +28 -8
  171. package/src/locales/it/parsers/ITWeekdayParser.ts +23 -13
  172. package/src/locales/it/parsers/{ITCasualYearMonthDayParser.ts → ITYearMonthDayParser.ts} +19 -8
  173. package/src/locales/it/refiners/ITExtractYearSuffixRefiner.ts +34 -0
  174. package/src/locales/it/refiners/ITMergeDateRangeRefiner.ts +5 -9
  175. package/src/locales/it/refiners/ITMergeDateTimeRefiner.ts +5 -5
  176. package/src/locales/it/refiners/ITMergeRelativeAfterDateRefiner.ts +46 -0
  177. package/src/locales/it/refiners/{ITMergeRelativeDateRefiner.ts → ITMergeRelativeFollowByDateRefiner.ts} +10 -10
  178. package/src/locales/it/refiners/ITUnlikelyFormatFilter.ts +31 -0
  179. package/src/results.ts +40 -9
  180. package/dist/cjs/locales/it/parsers/ITCasualYearMonthDayParser.js.map +0 -1
  181. package/dist/cjs/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +0 -1
  182. package/dist/esm/locales/it/parsers/ITCasualYearMonthDayParser.js.map +0 -1
  183. package/dist/esm/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +0 -1
  184. package/test/calculation_duration.test.ts +0 -165
  185. package/test/calculation_weekdays.test.ts +0 -133
  186. package/test/de/de_casual.test.ts +0 -336
  187. package/test/de/de_dash.test.ts +0 -32
  188. package/test/de/de_month_name_little_endian.test.ts +0 -273
  189. package/test/de/de_time_exp.test.ts +0 -223
  190. package/test/de/de_time_units_casual_relative.test.ts +0 -120
  191. package/test/de/de_time_units_within.test.ts +0 -119
  192. package/test/de/de_weekday.test.ts +0 -158
  193. package/test/de/de_year.test.ts +0 -147
  194. package/test/debugging.test.ts +0 -17
  195. package/test/en/en.test.ts +0 -191
  196. package/test/en/en_casual.test.ts +0 -425
  197. package/test/en/en_inter_std.test.ts +0 -118
  198. package/test/en/en_merging_relative_dates.test.ts +0 -50
  199. package/test/en/en_month.test.ts +0 -339
  200. package/test/en/en_month_name_little_endian.test.ts +0 -448
  201. package/test/en/en_month_name_middle_endian.test.ts +0 -386
  202. package/test/en/en_performance.test.ts +0 -26
  203. package/test/en/en_relative.test.ts +0 -393
  204. package/test/en/en_slash.test.ts +0 -284
  205. package/test/en/en_time_exp.test.ts +0 -535
  206. package/test/en/en_time_units_ago.test.ts +0 -357
  207. package/test/en/en_time_units_casual_relative.test.ts +0 -186
  208. package/test/en/en_time_units_later.test.ts +0 -361
  209. package/test/en/en_time_units_within.test.ts +0 -417
  210. package/test/en/en_timezone_exp.test.ts +0 -410
  211. package/test/en/en_weekday.test.ts +0 -573
  212. package/test/en/en_year.test.ts +0 -138
  213. package/test/en/en_year_month_day.test.ts +0 -101
  214. package/test/en/negative_cases.test.ts +0 -99
  215. package/test/es/es_casual.test.ts +0 -175
  216. package/test/es/es_month_name_little_endian.test.ts +0 -217
  217. package/test/es/es_slash.test.ts +0 -26
  218. package/test/es/es_time_exp.test.ts +0 -175
  219. package/test/es/es_time_units_within.test.ts +0 -119
  220. package/test/fi/fi_casual.test.ts +0 -99
  221. package/test/fi/fi_casual_time.test.ts +0 -56
  222. package/test/fi/fi_month_name_little_endian.test.ts +0 -50
  223. package/test/fi/fi_time_exp.test.ts +0 -39
  224. package/test/fi/fi_time_units_ago.test.ts +0 -93
  225. package/test/fi/fi_time_units_casual_relative.test.ts +0 -117
  226. package/test/fi/fi_time_units_within.test.ts +0 -74
  227. package/test/fi/fi_weekday.test.ts +0 -90
  228. package/test/fr/fr_casual.test.ts +0 -314
  229. package/test/fr/fr_little_endian.test.ts +0 -320
  230. package/test/fr/fr_slash.test.ts +0 -49
  231. package/test/fr/fr_time_exp.test.ts +0 -588
  232. package/test/fr/fr_time_units_ago.test.ts +0 -103
  233. package/test/fr/fr_time_units_casual_relative.test.ts +0 -114
  234. package/test/fr/fr_time_units_within.test.ts +0 -129
  235. package/test/fr/fr_weekday.test.ts +0 -130
  236. package/test/it/it_casual.test.ts +0 -81
  237. package/test/it/it_month_name_little_endian.test.ts +0 -28
  238. package/test/it/it_month_name_middle_endian.test.ts +0 -39
  239. package/test/it/it_time_exp.test.ts +0 -84
  240. package/test/it/it_weekday.test.ts +0 -37
  241. package/test/it/it_year_month_day.test.ts +0 -41
  242. package/test/ja/ja_casual.test.ts +0 -73
  243. package/test/ja/ja_slash_date_format.test.ts +0 -60
  244. package/test/ja/ja_standard.test.ts +0 -235
  245. package/test/ja/ja_time_exp.test.ts +0 -305
  246. package/test/ja/ja_weekday.test.ts +0 -183
  247. package/test/nl/nl_casual.test.ts +0 -408
  248. package/test/nl/nl_month.test.ts +0 -205
  249. package/test/nl/nl_month_name_little_endian.test.ts +0 -358
  250. package/test/nl/nl_relative.test.ts +0 -242
  251. package/test/nl/nl_slash.test.ts +0 -206
  252. package/test/nl/nl_time_exp.test.ts +0 -79
  253. package/test/nl/nl_time_units_ago.test.ts +0 -243
  254. package/test/nl/nl_time_units_casual_relative.test.ts +0 -130
  255. package/test/nl/nl_time_units_later.test.ts +0 -250
  256. package/test/nl/nl_time_units_within.test.ts +0 -225
  257. package/test/nl/nl_weekday.test.ts +0 -216
  258. package/test/pt/pt_casual.test.ts +0 -175
  259. package/test/pt/pt_month_name_little_endian.test.ts +0 -217
  260. package/test/pt/pt_slash.test.ts +0 -26
  261. package/test/pt/pt_time_exp.test.ts +0 -175
  262. package/test/result.test.ts +0 -283
  263. package/test/ru/ru_casual.test.ts +0 -159
  264. package/test/ru/ru_month.test.ts +0 -70
  265. package/test/ru/ru_month_name_little_endian.test.ts +0 -145
  266. package/test/ru/ru_relative.test.ts +0 -107
  267. package/test/ru/ru_time_exp.test.ts +0 -111
  268. package/test/ru/ru_time_units_ago.test.ts +0 -48
  269. package/test/ru/ru_time_units_casual_relative.test.ts +0 -190
  270. package/test/ru/ru_time_units_within.test.ts +0 -16
  271. package/test/ru/ru_weekday.test.ts +0 -52
  272. package/test/sv/sv_casual.test.ts +0 -87
  273. package/test/sv/sv_month_name_little_endian.test.ts +0 -48
  274. package/test/sv/sv_time_units_casual_relative.test.ts +0 -143
  275. package/test/sv/sv_weekday.test.ts +0 -68
  276. package/test/system.test.ts +0 -247
  277. package/test/system_timezone.test.ts +0 -284
  278. package/test/test_util.ts +0 -135
  279. package/test/uk/uk_casual.test.ts +0 -153
  280. package/test/uk/uk_month.test.ts +0 -70
  281. package/test/uk/uk_month_name_little_endian.test.ts +0 -148
  282. package/test/uk/uk_relative.test.ts +0 -107
  283. package/test/uk/uk_time_exp.test.ts +0 -111
  284. package/test/uk/uk_time_units_ago.test.ts +0 -48
  285. package/test/uk/uk_time_units_casual_relative.test.ts +0 -142
  286. package/test/uk/uk_time_units_within.test.ts +0 -23
  287. package/test/uk/uk_weekday.test.ts +0 -52
  288. package/test/vi/vi_casual.test.ts +0 -84
  289. package/test/vi/vi_casual_time.test.ts +0 -77
  290. package/test/vi/vi_date_range.test.ts +0 -61
  291. package/test/vi/vi_forward_date.test.ts +0 -45
  292. package/test/vi/vi_month_year.test.ts +0 -40
  293. package/test/vi/vi_negative_cases.test.ts +0 -60
  294. package/test/vi/vi_slash.test.ts +0 -36
  295. package/test/vi/vi_standard.test.ts +0 -86
  296. package/test/vi/vi_strict.test.ts +0 -67
  297. package/test/vi/vi_time_exp.test.ts +0 -99
  298. package/test/vi/vi_time_units_ago.test.ts +0 -56
  299. package/test/vi/vi_time_units_casual_relative.test.ts +0 -56
  300. package/test/vi/vi_time_units_later.test.ts +0 -43
  301. package/test/vi/vi_time_units_within.test.ts +0 -24
  302. package/test/vi/vi_weekday.test.ts +0 -77
  303. package/test/vi/vi_year.test.ts +0 -42
  304. package/test/zh/hans/zh_hans_ago.test.ts +0 -58
  305. package/test/zh/hans/zh_hans_casual.test.ts +0 -242
  306. package/test/zh/hans/zh_hans_date.test.ts +0 -116
  307. package/test/zh/hans/zh_hans_deadline.test.ts +0 -175
  308. package/test/zh/hans/zh_hans_time_exp.test.ts +0 -508
  309. package/test/zh/hans/zh_hans_weekday.test.ts +0 -219
  310. package/test/zh/hant/zh_hant_ago.test.ts +0 -58
  311. package/test/zh/hant/zh_hant_casual.test.ts +0 -260
  312. package/test/zh/hant/zh_hant_date.test.ts +0 -116
  313. package/test/zh/hant/zh_hant_deadline.test.ts +0 -136
  314. package/test/zh/hant/zh_hant_time_exp.test.ts +0 -226
  315. package/test/zh/hant/zh_hant_weekday.test.ts +0 -175
  316. package/test/zh/zh.test.ts +0 -36
  317. package/tsconfig.build.esm.json +0 -8
  318. package/tsconfig.build.json +0 -10
  319. 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|precedente)(?=(?:\\W|$))`, "i");
8
- const STRICT_PATTERN = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}fa(?=(?:\\W|$))`, "i");
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 ENTimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
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 timeUnits = parseDuration(match[1]);
21
- const outputTimeUnits = reverseDuration(timeUnits);
22
-
23
- return ParsingComponents.createRelativeFromReference(context.reference, outputTimeUnits);
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|ultimo|passato|prossimo|dopo|questa|ultima|passata|prossima|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
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): ParsingComponents {
25
+ innerExtract(context: ParsingContext, match: RegExpMatchArray) {
18
26
  const prefix = match[1].toLowerCase();
19
- let timeUnits = parseDuration(match[2]);
27
+ let duration = parseDuration(match[2]);
28
+ if (!duration) {
29
+ return null;
30
+ }
20
31
  switch (prefix) {
21
- case "last":
22
- case "past":
32
+ case "scorso":
33
+ case "scorsa":
23
34
  case "-":
24
- timeUnits = reverseDuration(timeUnits);
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|più tardi|da adesso|avanti|oltre|a seguire)` + "(?=(?:\\W|$))",
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("" + "(" + TIME_UNITS_PATTERN + ")" + "(dopo|più tardi)" + "(?=(?:\\W|$))", "i");
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 ENTimeUnitLaterFormatParser extends AbstractParserWithWordBoundaryChecking {
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 fragments = parseDuration(match[GROUP_NUM_TIMEUNITS]);
25
- return ParsingComponents.createRelativeFromReference(context.reference, fragments);
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
- `(?:within|in|for)\\s*` +
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 PATTERN_WITHOUT_PREFIX = new RegExp(
13
- `(?:(?:più o meno|intorno|approssimativamente|verso|verso le)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`,
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 ENTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
23
+ export default class ITTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
24
+ constructor(private strictMode: boolean) {
25
+ super();
26
+ }
27
+
18
28
  innerPattern(context: ParsingContext): RegExp {
19
- return context.option.forwardDate ? PATTERN_WITHOUT_PREFIX : PATTERN_WITH_PREFIX;
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): ParsingComponents {
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
- "(?:il\\s*?)?" +
11
- "(?:(questa|l'ultima|scorsa|prossima)\\s*)?" +
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*(questa|l'ultima|scorsa|prossima)\\s*settimana)?" +
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 == "ultima" || modifierWord == "scorsa") {
39
- modifier = "ultima";
40
- } else if (modifierWord == "prossima") {
41
- modifier = "prossima";
42
- } else if (modifierWord == "questa") {
43
- modifier = "questa";
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 ENSlashDateFormatParser,
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})[\\.\\/\\s]` +
15
- `(?:(${matchAnyPattern(MONTH_DICTIONARY)})|([0-9]{1,2}))[\\.\\/\\s]` +
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 ENCasualYearMonthDayParser extends AbstractParserWithWordBoundaryChecking {
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 month = match[MONTH_NUMBER_GROUP]
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 English connecting phases
10
- * - 2020-02-13 [to] 2020-02-13
11
- * - Wednesday [-] Friday
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 ENMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner {
9
+ export default class ITMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner {
14
10
  patternBetween(): RegExp {
15
- return /^\s*(to|-)\s*$/i;
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 English connecting phases
6
- * - 2020-02-13 [at] 6pm
7
- * - Tomorrow [after] 7am
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 ENMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner {
9
+ export default class ITMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner {
10
10
  patternBetween(): RegExp {
11
- return new RegExp("^\\s*(T|alle|dopo|prima|il|di|del|delle|,|-)?\\s*$");
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|dal)$/i) != null;
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|fino)$/i) != null;
11
+ return result.text.match(/\s+(dopo|dal?)$/i) != null;
12
12
  }
13
13
 
14
14
  /**
15
- * Merges an absolute date with a relative date.
16
- * - 2 weeks before 2020-02-13
17
- * - 2 days after next Friday
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 ENMergeRelativeDateRefiner extends MergingRefiner {
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> from] [<date2>]
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 timeUnits = parseDuration(currentResult.text);
41
+ let duration = parseDuration(currentResult.text);
42
42
  if (hasImpliedEarlierReferenceDate(currentResult)) {
43
- timeUnits = reverseDuration(timeUnits);
43
+ duration = reverseDuration(duration);
44
44
  }
45
45
 
46
46
  const components = ParsingComponents.createRelativeFromReference(
47
47
  ReferenceWithTimezone.fromDate(nextResult.start.date()),
48
- timeUnits
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
- const date = this.dateWithoutTimezoneAdjustment();
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.getFullYear() !== this.get("year")) return false;
238
- if (date.getMonth() !== this.get("month") - 1) return false;
239
- if (date.getDate() !== this.get("day")) return false;
240
- if (this.get("hour") != null && date.getHours() != this.get("hour")) return false;
241
- if (this.get("minute") != null && date.getMinutes() != this.get("minute")) return false;
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 date = this.dateWithoutTimezoneAdjustment();
256
- const timezoneAdjustment = this.reference.getSystemTimezoneAdjustmentMinute(date, this.get("timezoneOffset"));
257
- return new Date(date.getTime() + timezoneAdjustment * 60000);
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,YAAY,CAAC,OAAuB,EAAE,KAAuB;QACzD,MAAM,KAAK,GAAG,KAAK,CAAC,kBAAkB,CAAC;YACnC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACrC,CAAC,CAAC,4BAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAE9D,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAE/C,OAAO;YACH,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ;AAvBD,6CAuBC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ITMergeRelativeDateRefiner.js","sourceRoot":"","sources":["../../../../../src/locales/it/refiners/ITMergeRelativeDateRefiner.ts"],"names":[],"mappings":";;AAAA,uEAAkE;AAClE,8CAA2F;AAC3F,4CAA6C;AAC7C,4DAAgE;AAEhE,SAAS,8BAA8B,CAAC,MAAqB;IACzD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC;AACzD,CAAC;AAED,SAAS,4BAA4B,CAAC,MAAqB;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,IAAI,CAAC;AAC7D,CAAC;AAOD,MAAqB,0BAA2B,SAAQ,iCAAc;IAClE,cAAc;QACV,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,kBAAkB,CAAC,WAAmB,EAAE,aAA4B,EAAE,UAAyB;QAE3F,IAAI,CAAC,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,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sCAAsC,EAAE,MAAM,wDAAwD,CAAC;AAShH,MAAM,OAAO,GAAG,IAAI,MAAM,CACtB,uBAAuB;IACnB,OAAO,eAAe,CAAC,gBAAgB,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,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,sCAAsC;IAC1F,YAAY;QACR,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,YAAY,CAAC,OAAuB,EAAE,KAAuB;QACzD,MAAM,KAAK,GAAG,KAAK,CAAC,kBAAkB,CAAC;YACnC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACrC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAE9D,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAE/C,OAAO;YACH,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ITMergeRelativeDateRefiner.js","sourceRoot":"","sources":["../../../../../src/locales/it/refiners/ITMergeRelativeDateRefiner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,SAAS,8BAA8B,CAAC,MAAqB;IACzD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC;AACzD,CAAC;AAED,SAAS,4BAA4B,CAAC,MAAqB;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,IAAI,CAAC;AAC7D,CAAC;AAOD,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,cAAc;IAClE,cAAc;QACV,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,kBAAkB,CAAC,WAAmB,EAAE,aAA4B,EAAE,UAAyB;QAE3F,IAAI,CAAC,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,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,8BAA8B,CAAC,aAAa,CAAC,EAAE,CAAC;YAChD,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,2BAA2B,CAC5D,qBAAqB,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EACvD,SAAS,CACZ,CAAC;QAEF,OAAO,IAAI,aAAa,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"}