chrono-node 2.10.0 → 2.10.2

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