chrono-node 2.8.3 → 2.8.5

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 (503) hide show
  1. package/dist/cjs/calculation/duration.d.ts +5 -0
  2. package/dist/cjs/calculation/duration.js +6 -0
  3. package/dist/cjs/calculation/duration.js.map +1 -1
  4. package/dist/cjs/calculation/mergingCalculation.js +5 -4
  5. package/dist/cjs/calculation/mergingCalculation.js.map +1 -1
  6. package/dist/cjs/calculation/weekdays.js +1 -2
  7. package/dist/cjs/calculation/weekdays.js.map +1 -1
  8. package/dist/cjs/calculation/years.js +11 -16
  9. package/dist/cjs/calculation/years.js.map +1 -1
  10. package/dist/cjs/chrono.js +1 -1
  11. package/dist/cjs/chrono.js.map +1 -1
  12. package/dist/cjs/common/casualReferences.js +25 -27
  13. package/dist/cjs/common/casualReferences.js.map +1 -1
  14. package/dist/cjs/common/parsers/AbstractTimeExpressionParser.js +3 -0
  15. package/dist/cjs/common/parsers/AbstractTimeExpressionParser.js.map +1 -1
  16. package/dist/cjs/common/refiners/AbstractMergeDateRangeRefiner.js +20 -19
  17. package/dist/cjs/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -1
  18. package/dist/cjs/common/refiners/ForwardDateRefiner.js +16 -24
  19. package/dist/cjs/common/refiners/ForwardDateRefiner.js.map +1 -1
  20. package/dist/cjs/index.d.ts +3 -1
  21. package/dist/cjs/index.js +5 -1
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/locales/de/constants.d.ts +4 -4
  24. package/dist/cjs/locales/de/constants.js +5 -5
  25. package/dist/cjs/locales/de/constants.js.map +1 -1
  26. package/dist/cjs/locales/de/parsers/DECasualDateParser.js +18 -15
  27. package/dist/cjs/locales/de/parsers/DECasualDateParser.js.map +1 -1
  28. package/dist/cjs/locales/de/parsers/DECasualTimeParser.js +4 -9
  29. package/dist/cjs/locales/de/parsers/DECasualTimeParser.js.map +1 -1
  30. package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.js +2 -2
  31. package/dist/cjs/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -1
  32. package/dist/cjs/locales/de/parsers/DETimeUnitWithinFormatParser.js +1 -1
  33. package/dist/cjs/locales/de/parsers/DETimeUnitWithinFormatParser.js.map +1 -1
  34. package/dist/cjs/locales/en/constants.d.ts +5 -6
  35. package/dist/cjs/locales/en/constants.js +5 -5
  36. package/dist/cjs/locales/en/constants.js.map +1 -1
  37. package/dist/cjs/locales/en/parsers/ENCasualDateParser.js +7 -9
  38. package/dist/cjs/locales/en/parsers/ENCasualDateParser.js.map +1 -1
  39. package/dist/cjs/locales/en/parsers/ENRelativeDateFormatParser.js +14 -18
  40. package/dist/cjs/locales/en/parsers/ENRelativeDateFormatParser.js.map +1 -1
  41. package/dist/cjs/locales/en/parsers/ENTimeUnitAgoFormatParser.js +1 -1
  42. package/dist/cjs/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -1
  43. package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +1 -1
  44. package/dist/cjs/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -1
  45. package/dist/cjs/locales/en/parsers/ENTimeUnitLaterFormatParser.js +1 -1
  46. package/dist/cjs/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -1
  47. package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js +1 -5
  48. package/dist/cjs/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
  49. package/dist/cjs/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js +4 -4
  50. package/dist/cjs/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js.map +1 -1
  51. package/dist/cjs/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js +2 -2
  52. package/dist/cjs/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js.map +1 -1
  53. package/dist/cjs/locales/es/constants.d.ts +4 -5
  54. package/dist/cjs/locales/es/constants.js +4 -4
  55. package/dist/cjs/locales/es/constants.js.map +1 -1
  56. package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js +6 -7
  57. package/dist/cjs/locales/es/parsers/ESCasualTimeParser.js.map +1 -1
  58. package/dist/cjs/locales/es/parsers/ESTimeUnitWithinFormatParser.js +1 -1
  59. package/dist/cjs/locales/es/parsers/ESTimeUnitWithinFormatParser.js.map +1 -1
  60. package/dist/cjs/locales/fr/constants.d.ts +4 -5
  61. package/dist/cjs/locales/fr/constants.js +4 -4
  62. package/dist/cjs/locales/fr/constants.js.map +1 -1
  63. package/dist/cjs/locales/fr/parsers/FRCasualDateParser.js +6 -9
  64. package/dist/cjs/locales/fr/parsers/FRCasualDateParser.js.map +1 -1
  65. package/dist/cjs/locales/fr/parsers/FRTimeUnitAgoFormatParser.js +3 -3
  66. package/dist/cjs/locales/fr/parsers/FRTimeUnitAgoFormatParser.js.map +1 -1
  67. package/dist/cjs/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +2 -2
  68. package/dist/cjs/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -1
  69. package/dist/cjs/locales/fr/parsers/FRTimeUnitWithinFormatParser.js +1 -1
  70. package/dist/cjs/locales/fr/parsers/FRTimeUnitWithinFormatParser.js.map +1 -1
  71. package/dist/cjs/locales/it/constants.d.ts +4 -4
  72. package/dist/cjs/locales/it/constants.js +4 -4
  73. package/dist/cjs/locales/it/constants.js.map +1 -1
  74. package/dist/cjs/locales/it/parsers/ITCasualDateParser.d.ts +1 -1
  75. package/dist/cjs/locales/it/parsers/ITCasualDateParser.js +9 -11
  76. package/dist/cjs/locales/it/parsers/ITCasualDateParser.js.map +1 -1
  77. package/dist/cjs/locales/it/parsers/ITCasualTimeParser.d.ts +1 -1
  78. package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js +8 -9
  79. package/dist/cjs/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
  80. package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js +14 -18
  81. package/dist/cjs/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
  82. package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js +3 -3
  83. package/dist/cjs/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
  84. package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +3 -3
  85. package/dist/cjs/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
  86. package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js +1 -1
  87. package/dist/cjs/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
  88. package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js +1 -1
  89. package/dist/cjs/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
  90. package/dist/cjs/locales/it/refiners/ITMergeRelativeDateRefiner.js +4 -4
  91. package/dist/cjs/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +1 -1
  92. package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js +4 -8
  93. package/dist/cjs/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
  94. package/dist/cjs/locales/ja/parsers/JPStandardParser.js +1 -6
  95. package/dist/cjs/locales/ja/parsers/JPStandardParser.js.map +1 -1
  96. package/dist/cjs/locales/ja/parsers/JPTimeExpressionParser.d.ts +1 -1
  97. package/dist/cjs/locales/ja/parsers/JPTimeExpressionParser.js +77 -187
  98. package/dist/cjs/locales/ja/parsers/JPTimeExpressionParser.js.map +1 -1
  99. package/dist/cjs/locales/nl/constants.d.ts +4 -4
  100. package/dist/cjs/locales/nl/constants.js +4 -4
  101. package/dist/cjs/locales/nl/constants.js.map +1 -1
  102. package/dist/cjs/locales/nl/parsers/NLCasualDateTimeParser.js +10 -9
  103. package/dist/cjs/locales/nl/parsers/NLCasualDateTimeParser.js.map +1 -1
  104. package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js +6 -7
  105. package/dist/cjs/locales/nl/parsers/NLCasualTimeParser.js.map +1 -1
  106. package/dist/cjs/locales/nl/parsers/NLRelativeDateFormatParser.js +14 -18
  107. package/dist/cjs/locales/nl/parsers/NLRelativeDateFormatParser.js.map +1 -1
  108. package/dist/cjs/locales/nl/parsers/NLTimeUnitAgoFormatParser.js +3 -3
  109. package/dist/cjs/locales/nl/parsers/NLTimeUnitAgoFormatParser.js.map +1 -1
  110. package/dist/cjs/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js +3 -3
  111. package/dist/cjs/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js.map +1 -1
  112. package/dist/cjs/locales/nl/parsers/NLTimeUnitLaterFormatParser.js +1 -1
  113. package/dist/cjs/locales/nl/parsers/NLTimeUnitLaterFormatParser.js.map +1 -1
  114. package/dist/cjs/locales/nl/parsers/NLTimeUnitWithinFormatParser.js +1 -1
  115. package/dist/cjs/locales/nl/parsers/NLTimeUnitWithinFormatParser.js.map +1 -1
  116. package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js +6 -7
  117. package/dist/cjs/locales/pt/parsers/PTCasualTimeParser.js.map +1 -1
  118. package/dist/cjs/locales/ru/constants.d.ts +4 -4
  119. package/dist/cjs/locales/ru/constants.js +7 -7
  120. package/dist/cjs/locales/ru/constants.js.map +1 -1
  121. package/dist/cjs/locales/ru/parsers/RUCasualTimeParser.js +6 -9
  122. package/dist/cjs/locales/ru/parsers/RUCasualTimeParser.js.map +1 -1
  123. package/dist/cjs/locales/ru/parsers/RURelativeDateFormatParser.js +14 -18
  124. package/dist/cjs/locales/ru/parsers/RURelativeDateFormatParser.js.map +1 -1
  125. package/dist/cjs/locales/ru/parsers/RUTimeUnitAgoFormatParser.js +3 -3
  126. package/dist/cjs/locales/ru/parsers/RUTimeUnitAgoFormatParser.js.map +1 -1
  127. package/dist/cjs/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js +3 -3
  128. package/dist/cjs/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js.map +1 -1
  129. package/dist/cjs/locales/ru/parsers/RUTimeUnitWithinFormatParser.js +1 -1
  130. package/dist/cjs/locales/ru/parsers/RUTimeUnitWithinFormatParser.js.map +1 -1
  131. package/dist/cjs/locales/sv/constants.d.ts +29 -0
  132. package/dist/cjs/locales/sv/constants.js +224 -0
  133. package/dist/cjs/locales/sv/constants.js.map +1 -0
  134. package/dist/cjs/locales/sv/index.d.ts +11 -0
  135. package/dist/cjs/locales/sv/index.js +52 -0
  136. package/dist/cjs/locales/sv/index.js.map +1 -0
  137. package/dist/cjs/locales/sv/parsers/SVCasualDateParser.d.ts +7 -0
  138. package/dist/cjs/locales/sv/parsers/SVCasualDateParser.js +135 -0
  139. package/dist/cjs/locales/sv/parsers/SVCasualDateParser.js.map +1 -0
  140. package/dist/cjs/locales/sv/parsers/SVMonthNameLittleEndianParser.d.ts +7 -0
  141. package/dist/cjs/locales/sv/parsers/SVMonthNameLittleEndianParser.js +49 -0
  142. package/dist/cjs/locales/sv/parsers/SVMonthNameLittleEndianParser.js.map +1 -0
  143. package/dist/cjs/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.d.ts +9 -0
  144. package/dist/cjs/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js +34 -0
  145. package/dist/cjs/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js.map +1 -0
  146. package/dist/cjs/locales/sv/parsers/SVWeekdayParser.d.ts +7 -0
  147. package/dist/cjs/locales/sv/parsers/SVWeekdayParser.js +40 -0
  148. package/dist/cjs/locales/sv/parsers/SVWeekdayParser.js.map +1 -0
  149. package/dist/cjs/locales/uk/constants.d.ts +4 -4
  150. package/dist/cjs/locales/uk/constants.js +8 -8
  151. package/dist/cjs/locales/uk/constants.js.map +1 -1
  152. package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js +6 -9
  153. package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js.map +1 -1
  154. package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js +14 -18
  155. package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -1
  156. package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +3 -3
  157. package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -1
  158. package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +3 -3
  159. package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -1
  160. package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +1 -1
  161. package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
  162. package/dist/cjs/locales/zh/hans/parsers/ZHHansCasualDateParser.js +23 -27
  163. package/dist/cjs/locales/zh/hans/parsers/ZHHansCasualDateParser.js.map +1 -1
  164. package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.js +2 -7
  165. package/dist/cjs/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -1
  166. package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +20 -21
  167. package/dist/cjs/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -1
  168. package/dist/cjs/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js +17 -22
  169. package/dist/cjs/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js.map +1 -1
  170. package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +71 -76
  171. package/dist/cjs/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -1
  172. package/dist/cjs/locales/zh/hans/parsers/ZHHansWeekdayParser.js +14 -19
  173. package/dist/cjs/locales/zh/hans/parsers/ZHHansWeekdayParser.js.map +1 -1
  174. package/dist/cjs/locales/zh/hant/parsers/ZHHantCasualDateParser.js +23 -27
  175. package/dist/cjs/locales/zh/hant/parsers/ZHHantCasualDateParser.js.map +1 -1
  176. package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.js +2 -7
  177. package/dist/cjs/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -1
  178. package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +20 -21
  179. package/dist/cjs/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -1
  180. package/dist/cjs/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js +17 -22
  181. package/dist/cjs/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js.map +1 -1
  182. package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +73 -78
  183. package/dist/cjs/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -1
  184. package/dist/cjs/locales/zh/hant/parsers/ZHHantWeekdayParser.js +14 -19
  185. package/dist/cjs/locales/zh/hant/parsers/ZHHantWeekdayParser.js.map +1 -1
  186. package/dist/cjs/results.d.ts +7 -4
  187. package/dist/cjs/results.js +86 -59
  188. package/dist/cjs/results.js.map +1 -1
  189. package/dist/cjs/timezone.js +1 -6
  190. package/dist/cjs/timezone.js.map +1 -1
  191. package/dist/cjs/types.d.ts +1 -1
  192. package/dist/esm/calculation/duration.d.ts +5 -0
  193. package/dist/esm/calculation/duration.js +5 -0
  194. package/dist/esm/calculation/duration.js.map +1 -1
  195. package/dist/esm/calculation/mergingCalculation.js +5 -4
  196. package/dist/esm/calculation/mergingCalculation.js.map +1 -1
  197. package/dist/esm/calculation/weekdays.js +1 -2
  198. package/dist/esm/calculation/weekdays.js.map +1 -1
  199. package/dist/esm/calculation/years.js +11 -13
  200. package/dist/esm/calculation/years.js.map +1 -1
  201. package/dist/esm/chrono.js +1 -1
  202. package/dist/esm/chrono.js.map +1 -1
  203. package/dist/esm/common/casualReferences.js +18 -17
  204. package/dist/esm/common/casualReferences.js.map +1 -1
  205. package/dist/esm/common/parsers/AbstractTimeExpressionParser.js +3 -0
  206. package/dist/esm/common/parsers/AbstractTimeExpressionParser.js.map +1 -1
  207. package/dist/esm/common/refiners/AbstractMergeDateRangeRefiner.js +20 -19
  208. package/dist/esm/common/refiners/AbstractMergeDateRangeRefiner.js.map +1 -1
  209. package/dist/esm/common/refiners/ForwardDateRefiner.js +16 -21
  210. package/dist/esm/common/refiners/ForwardDateRefiner.js.map +1 -1
  211. package/dist/esm/index.d.ts +3 -1
  212. package/dist/esm/index.js +3 -1
  213. package/dist/esm/index.js.map +1 -1
  214. package/dist/esm/locales/de/constants.d.ts +4 -4
  215. package/dist/esm/locales/de/constants.js +4 -4
  216. package/dist/esm/locales/de/constants.js.map +1 -1
  217. package/dist/esm/locales/de/parsers/DECasualDateParser.js +13 -10
  218. package/dist/esm/locales/de/parsers/DECasualDateParser.js.map +1 -1
  219. package/dist/esm/locales/de/parsers/DECasualTimeParser.js +3 -5
  220. package/dist/esm/locales/de/parsers/DECasualTimeParser.js.map +1 -1
  221. package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.js +2 -2
  222. package/dist/esm/locales/de/parsers/DETimeUnitRelativeFormatParser.js.map +1 -1
  223. package/dist/esm/locales/de/parsers/DETimeUnitWithinFormatParser.js +2 -2
  224. package/dist/esm/locales/de/parsers/DETimeUnitWithinFormatParser.js.map +1 -1
  225. package/dist/esm/locales/en/constants.d.ts +5 -6
  226. package/dist/esm/locales/en/constants.js +7 -7
  227. package/dist/esm/locales/en/constants.js.map +1 -1
  228. package/dist/esm/locales/en/parsers/ENCasualDateParser.js +6 -5
  229. package/dist/esm/locales/en/parsers/ENCasualDateParser.js.map +1 -1
  230. package/dist/esm/locales/en/parsers/ENRelativeDateFormatParser.js +14 -15
  231. package/dist/esm/locales/en/parsers/ENRelativeDateFormatParser.js.map +1 -1
  232. package/dist/esm/locales/en/parsers/ENTimeUnitAgoFormatParser.js +2 -2
  233. package/dist/esm/locales/en/parsers/ENTimeUnitAgoFormatParser.js.map +1 -1
  234. package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +2 -2
  235. package/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js.map +1 -1
  236. package/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js +2 -2
  237. package/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js.map +1 -1
  238. package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js +2 -6
  239. package/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js.map +1 -1
  240. package/dist/esm/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js +5 -5
  241. package/dist/esm/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js.map +1 -1
  242. package/dist/esm/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js +3 -3
  243. package/dist/esm/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js.map +1 -1
  244. package/dist/esm/locales/es/constants.d.ts +4 -5
  245. package/dist/esm/locales/es/constants.js +3 -3
  246. package/dist/esm/locales/es/constants.js.map +1 -1
  247. package/dist/esm/locales/es/parsers/ESCasualTimeParser.js +6 -4
  248. package/dist/esm/locales/es/parsers/ESCasualTimeParser.js.map +1 -1
  249. package/dist/esm/locales/es/parsers/ESTimeUnitWithinFormatParser.js +2 -2
  250. package/dist/esm/locales/es/parsers/ESTimeUnitWithinFormatParser.js.map +1 -1
  251. package/dist/esm/locales/fr/constants.d.ts +4 -5
  252. package/dist/esm/locales/fr/constants.js +3 -3
  253. package/dist/esm/locales/fr/constants.js.map +1 -1
  254. package/dist/esm/locales/fr/parsers/FRCasualDateParser.js +5 -5
  255. package/dist/esm/locales/fr/parsers/FRCasualDateParser.js.map +1 -1
  256. package/dist/esm/locales/fr/parsers/FRTimeUnitAgoFormatParser.js +4 -4
  257. package/dist/esm/locales/fr/parsers/FRTimeUnitAgoFormatParser.js.map +1 -1
  258. package/dist/esm/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +2 -2
  259. package/dist/esm/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js.map +1 -1
  260. package/dist/esm/locales/fr/parsers/FRTimeUnitWithinFormatParser.js +2 -2
  261. package/dist/esm/locales/fr/parsers/FRTimeUnitWithinFormatParser.js.map +1 -1
  262. package/dist/esm/locales/it/constants.d.ts +4 -4
  263. package/dist/esm/locales/it/constants.js +3 -3
  264. package/dist/esm/locales/it/constants.js.map +1 -1
  265. package/dist/esm/locales/it/parsers/ITCasualDateParser.d.ts +1 -1
  266. package/dist/esm/locales/it/parsers/ITCasualDateParser.js +7 -6
  267. package/dist/esm/locales/it/parsers/ITCasualDateParser.js.map +1 -1
  268. package/dist/esm/locales/it/parsers/ITCasualTimeParser.d.ts +1 -1
  269. package/dist/esm/locales/it/parsers/ITCasualTimeParser.js +7 -5
  270. package/dist/esm/locales/it/parsers/ITCasualTimeParser.js.map +1 -1
  271. package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js +14 -15
  272. package/dist/esm/locales/it/parsers/ITRelativeDateFormatParser.js.map +1 -1
  273. package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js +4 -4
  274. package/dist/esm/locales/it/parsers/ITTimeUnitAgoFormatParser.js.map +1 -1
  275. package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js +4 -4
  276. package/dist/esm/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.js.map +1 -1
  277. package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js +2 -2
  278. package/dist/esm/locales/it/parsers/ITTimeUnitLaterFormatParser.js.map +1 -1
  279. package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js +2 -2
  280. package/dist/esm/locales/it/parsers/ITTimeUnitWithinFormatParser.js.map +1 -1
  281. package/dist/esm/locales/it/refiners/ITMergeRelativeDateRefiner.js +5 -5
  282. package/dist/esm/locales/it/refiners/ITMergeRelativeDateRefiner.js.map +1 -1
  283. package/dist/esm/locales/ja/parsers/JPCasualDateParser.js +4 -5
  284. package/dist/esm/locales/ja/parsers/JPCasualDateParser.js.map +1 -1
  285. package/dist/esm/locales/ja/parsers/JPStandardParser.js +1 -3
  286. package/dist/esm/locales/ja/parsers/JPStandardParser.js.map +1 -1
  287. package/dist/esm/locales/ja/parsers/JPTimeExpressionParser.d.ts +1 -1
  288. package/dist/esm/locales/ja/parsers/JPTimeExpressionParser.js +75 -186
  289. package/dist/esm/locales/ja/parsers/JPTimeExpressionParser.js.map +1 -1
  290. package/dist/esm/locales/nl/constants.d.ts +4 -4
  291. package/dist/esm/locales/nl/constants.js +3 -3
  292. package/dist/esm/locales/nl/constants.js.map +1 -1
  293. package/dist/esm/locales/nl/parsers/NLCasualDateTimeParser.js +9 -5
  294. package/dist/esm/locales/nl/parsers/NLCasualDateTimeParser.js.map +1 -1
  295. package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js +6 -4
  296. package/dist/esm/locales/nl/parsers/NLCasualTimeParser.js.map +1 -1
  297. package/dist/esm/locales/nl/parsers/NLRelativeDateFormatParser.js +14 -15
  298. package/dist/esm/locales/nl/parsers/NLRelativeDateFormatParser.js.map +1 -1
  299. package/dist/esm/locales/nl/parsers/NLTimeUnitAgoFormatParser.js +4 -4
  300. package/dist/esm/locales/nl/parsers/NLTimeUnitAgoFormatParser.js.map +1 -1
  301. package/dist/esm/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js +4 -4
  302. package/dist/esm/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js.map +1 -1
  303. package/dist/esm/locales/nl/parsers/NLTimeUnitLaterFormatParser.js +2 -2
  304. package/dist/esm/locales/nl/parsers/NLTimeUnitLaterFormatParser.js.map +1 -1
  305. package/dist/esm/locales/nl/parsers/NLTimeUnitWithinFormatParser.js +2 -2
  306. package/dist/esm/locales/nl/parsers/NLTimeUnitWithinFormatParser.js.map +1 -1
  307. package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js +6 -4
  308. package/dist/esm/locales/pt/parsers/PTCasualTimeParser.js.map +1 -1
  309. package/dist/esm/locales/ru/constants.d.ts +4 -4
  310. package/dist/esm/locales/ru/constants.js +6 -6
  311. package/dist/esm/locales/ru/constants.js.map +1 -1
  312. package/dist/esm/locales/ru/parsers/RUCasualTimeParser.js +6 -6
  313. package/dist/esm/locales/ru/parsers/RUCasualTimeParser.js.map +1 -1
  314. package/dist/esm/locales/ru/parsers/RURelativeDateFormatParser.js +14 -15
  315. package/dist/esm/locales/ru/parsers/RURelativeDateFormatParser.js.map +1 -1
  316. package/dist/esm/locales/ru/parsers/RUTimeUnitAgoFormatParser.js +4 -4
  317. package/dist/esm/locales/ru/parsers/RUTimeUnitAgoFormatParser.js.map +1 -1
  318. package/dist/esm/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js +4 -4
  319. package/dist/esm/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js.map +1 -1
  320. package/dist/esm/locales/ru/parsers/RUTimeUnitWithinFormatParser.js +2 -2
  321. package/dist/esm/locales/ru/parsers/RUTimeUnitWithinFormatParser.js.map +1 -1
  322. package/dist/esm/locales/sv/constants.d.ts +29 -0
  323. package/dist/esm/locales/sv/constants.js +217 -0
  324. package/dist/esm/locales/sv/constants.js.map +1 -0
  325. package/dist/esm/locales/sv/index.d.ts +11 -0
  326. package/dist/esm/locales/sv/index.js +38 -0
  327. package/dist/esm/locales/sv/index.js.map +1 -0
  328. package/dist/esm/locales/sv/parsers/SVCasualDateParser.d.ts +7 -0
  329. package/dist/esm/locales/sv/parsers/SVCasualDateParser.js +99 -0
  330. package/dist/esm/locales/sv/parsers/SVCasualDateParser.js.map +1 -0
  331. package/dist/esm/locales/sv/parsers/SVMonthNameLittleEndianParser.d.ts +7 -0
  332. package/dist/esm/locales/sv/parsers/SVMonthNameLittleEndianParser.js +46 -0
  333. package/dist/esm/locales/sv/parsers/SVMonthNameLittleEndianParser.js.map +1 -0
  334. package/dist/esm/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.d.ts +9 -0
  335. package/dist/esm/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js +32 -0
  336. package/dist/esm/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.js.map +1 -0
  337. package/dist/esm/locales/sv/parsers/SVWeekdayParser.d.ts +7 -0
  338. package/dist/esm/locales/sv/parsers/SVWeekdayParser.js +37 -0
  339. package/dist/esm/locales/sv/parsers/SVWeekdayParser.js.map +1 -0
  340. package/dist/esm/locales/uk/constants.d.ts +4 -4
  341. package/dist/esm/locales/uk/constants.js +7 -7
  342. package/dist/esm/locales/uk/constants.js.map +1 -1
  343. package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js +6 -6
  344. package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js.map +1 -1
  345. package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js +14 -15
  346. package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -1
  347. package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +4 -4
  348. package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -1
  349. package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +4 -4
  350. package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -1
  351. package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +2 -2
  352. package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
  353. package/dist/esm/locales/zh/hans/parsers/ZHHansCasualDateParser.js +23 -24
  354. package/dist/esm/locales/zh/hans/parsers/ZHHansCasualDateParser.js.map +1 -1
  355. package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.js +2 -4
  356. package/dist/esm/locales/zh/hans/parsers/ZHHansDateParser.js.map +1 -1
  357. package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +20 -18
  358. package/dist/esm/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js.map +1 -1
  359. package/dist/esm/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js +17 -19
  360. package/dist/esm/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js.map +1 -1
  361. package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +71 -73
  362. package/dist/esm/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js.map +1 -1
  363. package/dist/esm/locales/zh/hans/parsers/ZHHansWeekdayParser.js +14 -16
  364. package/dist/esm/locales/zh/hans/parsers/ZHHansWeekdayParser.js.map +1 -1
  365. package/dist/esm/locales/zh/hant/parsers/ZHHantCasualDateParser.js +23 -24
  366. package/dist/esm/locales/zh/hant/parsers/ZHHantCasualDateParser.js.map +1 -1
  367. package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.js +2 -4
  368. package/dist/esm/locales/zh/hant/parsers/ZHHantDateParser.js.map +1 -1
  369. package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +20 -18
  370. package/dist/esm/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js.map +1 -1
  371. package/dist/esm/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js +17 -19
  372. package/dist/esm/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js.map +1 -1
  373. package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +73 -75
  374. package/dist/esm/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js.map +1 -1
  375. package/dist/esm/locales/zh/hant/parsers/ZHHantWeekdayParser.js +14 -16
  376. package/dist/esm/locales/zh/hant/parsers/ZHHantWeekdayParser.js.map +1 -1
  377. package/dist/esm/results.d.ts +7 -4
  378. package/dist/esm/results.js +87 -60
  379. package/dist/esm/results.js.map +1 -1
  380. package/dist/esm/timezone.js +1 -3
  381. package/dist/esm/timezone.js.map +1 -1
  382. package/dist/esm/types.d.ts +1 -1
  383. package/package.json +1 -1
  384. package/src/calculation/duration.ts +10 -0
  385. package/src/calculation/mergingCalculation.ts +5 -4
  386. package/src/calculation/weekdays.ts +2 -2
  387. package/src/calculation/years.ts +11 -16
  388. package/src/chrono.ts +2 -2
  389. package/src/common/casualReferences.ts +19 -23
  390. package/src/common/parsers/AbstractTimeExpressionParser.ts +6 -0
  391. package/src/common/refiners/AbstractMergeDateRangeRefiner.ts +20 -21
  392. package/src/common/refiners/ForwardDateRefiner.ts +17 -22
  393. package/src/index.ts +3 -1
  394. package/src/locales/de/constants.ts +8 -8
  395. package/src/locales/de/parsers/DECasualDateParser.ts +13 -10
  396. package/src/locales/de/parsers/DECasualTimeParser.ts +3 -5
  397. package/src/locales/de/parsers/DETimeUnitRelativeFormatParser.ts +2 -2
  398. package/src/locales/de/parsers/DETimeUnitWithinFormatParser.ts +2 -2
  399. package/src/locales/en/constants.ts +12 -13
  400. package/src/locales/en/parsers/ENCasualDateParser.ts +6 -5
  401. package/src/locales/en/parsers/ENRelativeDateFormatParser.ts +14 -16
  402. package/src/locales/en/parsers/ENTimeUnitAgoFormatParser.ts +2 -2
  403. package/src/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.ts +2 -2
  404. package/src/locales/en/parsers/ENTimeUnitLaterFormatParser.ts +2 -2
  405. package/src/locales/en/parsers/ENTimeUnitWithinFormatParser.ts +2 -7
  406. package/src/locales/en/refiners/ENMergeRelativeAfterDateRefiner.ts +5 -5
  407. package/src/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.ts +3 -3
  408. package/src/locales/es/constants.ts +7 -6
  409. package/src/locales/es/parsers/ESCasualTimeParser.ts +6 -4
  410. package/src/locales/es/parsers/ESTimeUnitWithinFormatParser.ts +2 -2
  411. package/src/locales/fr/constants.ts +7 -6
  412. package/src/locales/fr/parsers/FRCasualDateParser.ts +5 -5
  413. package/src/locales/fr/parsers/FRTimeUnitAgoFormatParser.ts +4 -4
  414. package/src/locales/fr/parsers/FRTimeUnitRelativeFormatParser.ts +2 -2
  415. package/src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts +2 -2
  416. package/src/locales/it/constants.ts +7 -7
  417. package/src/locales/it/parsers/ITCasualDateParser.ts +7 -6
  418. package/src/locales/it/parsers/ITCasualTimeParser.ts +7 -5
  419. package/src/locales/it/parsers/ITRelativeDateFormatParser.ts +14 -16
  420. package/src/locales/it/parsers/ITTimeUnitAgoFormatParser.ts +4 -4
  421. package/src/locales/it/parsers/ITTimeUnitCasualRelativeFormatParser.ts +4 -4
  422. package/src/locales/it/parsers/ITTimeUnitLaterFormatParser.ts +2 -2
  423. package/src/locales/it/parsers/ITTimeUnitWithinFormatParser.ts +2 -2
  424. package/src/locales/it/refiners/ITMergeRelativeDateRefiner.ts +5 -5
  425. package/src/locales/ja/parsers/JPCasualDateParser.ts +4 -5
  426. package/src/locales/ja/parsers/JPStandardParser.ts +1 -4
  427. package/src/locales/ja/parsers/JPTimeExpressionParser.ts +91 -190
  428. package/src/locales/nl/constants.ts +7 -7
  429. package/src/locales/nl/parsers/NLCasualDateTimeParser.ts +9 -5
  430. package/src/locales/nl/parsers/NLCasualTimeParser.ts +6 -4
  431. package/src/locales/nl/parsers/NLRelativeDateFormatParser.ts +14 -16
  432. package/src/locales/nl/parsers/NLTimeUnitAgoFormatParser.ts +4 -4
  433. package/src/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.ts +4 -4
  434. package/src/locales/nl/parsers/NLTimeUnitLaterFormatParser.ts +2 -2
  435. package/src/locales/nl/parsers/NLTimeUnitWithinFormatParser.ts +2 -2
  436. package/src/locales/pt/parsers/PTCasualTimeParser.ts +6 -4
  437. package/src/locales/ru/constants.ts +10 -10
  438. package/src/locales/ru/parsers/RUCasualTimeParser.ts +6 -6
  439. package/src/locales/ru/parsers/RURelativeDateFormatParser.ts +15 -18
  440. package/src/locales/ru/parsers/RUTimeUnitAgoFormatParser.ts +4 -4
  441. package/src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts +4 -4
  442. package/src/locales/ru/parsers/RUTimeUnitWithinFormatParser.ts +2 -2
  443. package/src/locales/sv/constants.ts +237 -0
  444. package/src/locales/sv/index.ts +47 -0
  445. package/src/locales/sv/parsers/SVCasualDateParser.ts +118 -0
  446. package/src/locales/sv/parsers/SVMonthNameLittleEndianParser.ts +59 -0
  447. package/src/locales/sv/parsers/SVTimeUnitCasualRelativeFormatParser.ts +42 -0
  448. package/src/locales/sv/parsers/SVWeekdayParser.ts +47 -0
  449. package/src/locales/uk/constants.ts +11 -11
  450. package/src/locales/uk/parsers/UKCasualTimeParser.ts +6 -6
  451. package/src/locales/uk/parsers/UKRelativeDateFormatParser.ts +14 -16
  452. package/src/locales/uk/parsers/UKTimeUnitAgoFormatParser.ts +4 -4
  453. package/src/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.ts +4 -4
  454. package/src/locales/uk/parsers/UKTimeUnitWithinFormatParser.ts +2 -2
  455. package/src/locales/zh/hans/parsers/ZHHansCasualDateParser.ts +23 -24
  456. package/src/locales/zh/hans/parsers/ZHHansDateParser.ts +2 -4
  457. package/src/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.ts +20 -18
  458. package/src/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.ts +18 -18
  459. package/src/locales/zh/hans/parsers/ZHHansTimeExpressionParser.ts +71 -73
  460. package/src/locales/zh/hans/parsers/ZHHansWeekdayParser.ts +16 -15
  461. package/src/locales/zh/hant/parsers/ZHHantCasualDateParser.ts +23 -24
  462. package/src/locales/zh/hant/parsers/ZHHantDateParser.ts +2 -4
  463. package/src/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.ts +20 -18
  464. package/src/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.ts +18 -18
  465. package/src/locales/zh/hant/parsers/ZHHantTimeExpressionParser.ts +73 -75
  466. package/src/locales/zh/hant/parsers/ZHHantWeekdayParser.ts +16 -15
  467. package/src/results.ts +97 -59
  468. package/src/timezone.ts +1 -5
  469. package/src/types.ts +1 -1
  470. package/test/calculation_weekdays.test.ts +17 -0
  471. package/test/en/en_time_exp.test.ts +2 -0
  472. package/test/it/it_casual.test.ts +44 -0
  473. package/test/it/it_month_name_little_endian.test.ts +28 -0
  474. package/test/it/it_weekday.test.ts +37 -0
  475. package/test/ja/ja_time_exp.test.ts +82 -21
  476. package/test/result.test.ts +78 -4
  477. package/test/sv/sv_casual.test.ts +87 -0
  478. package/test/sv/sv_month_name_little_endian.test.ts +48 -0
  479. package/test/sv/sv_time_units_casual_relative.test.ts +143 -0
  480. package/test/sv/sv_weekday.test.ts +68 -0
  481. package/test/system_timezone.test.ts +36 -0
  482. package/test/zh/hans/zh_hans_casual.test.ts +14 -0
  483. package/test/zh/hans/zh_hans_date.test.ts +14 -0
  484. package/test/zh/hans/zh_hans_deadline.test.ts +39 -0
  485. package/test/zh/hans/zh_hans_time_exp.test.ts +51 -0
  486. package/test/zh/hans/zh_hans_weekday.test.ts +87 -0
  487. package/test/zh/hant/zh_hant_casual.test.ts +14 -0
  488. package/test/zh/hant/zh_hant_date.test.ts +14 -0
  489. package/test/zh/hant/zh_hant_weekday.test.ts +43 -0
  490. package/dist/cjs/utils/dayjs.d.ts +0 -8
  491. package/dist/cjs/utils/dayjs.js +0 -48
  492. package/dist/cjs/utils/dayjs.js.map +0 -1
  493. package/dist/cjs/utils/timeunits.d.ts +0 -7
  494. package/dist/cjs/utils/timeunits.js +0 -30
  495. package/dist/cjs/utils/timeunits.js.map +0 -1
  496. package/dist/esm/utils/dayjs.d.ts +0 -8
  497. package/dist/esm/utils/dayjs.js +0 -40
  498. package/dist/esm/utils/dayjs.js.map +0 -1
  499. package/dist/esm/utils/timeunits.d.ts +0 -7
  500. package/dist/esm/utils/timeunits.js +0 -26
  501. package/dist/esm/utils/timeunits.js.map +0 -1
  502. package/src/utils/dayjs.ts +0 -52
  503. package/src/utils/timeunits.ts +0 -47
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { ParsingResult } from "../../results";
6
6
  import { MergingRefiner } from "../abstractRefiners";
7
+ import { addDuration } from "../../calculation/duration";
7
8
 
8
9
  export default abstract class AbstractMergeDateRangeRefiner extends MergingRefiner {
9
10
  abstract patternBetween(): RegExp;
@@ -26,31 +27,30 @@ export default abstract class AbstractMergeDateRangeRefiner extends MergingRefin
26
27
  }
27
28
  });
28
29
  }
30
+ if (fromResult.start.date() > toResult.start.date()) {
31
+ let fromDate = fromResult.start.date();
32
+ let toDate = toResult.start.date();
29
33
 
30
- if (fromResult.start.date().getTime() > toResult.start.date().getTime()) {
31
- let fromMoment = fromResult.start.dayjs();
32
- let toMoment = toResult.start.dayjs();
33
- if (toResult.start.isOnlyWeekdayComponent() && toMoment.add(7, "days").isAfter(fromMoment)) {
34
- toMoment = toMoment.add(7, "days");
35
- toResult.start.imply("day", toMoment.date());
36
- toResult.start.imply("month", toMoment.month() + 1);
37
- toResult.start.imply("year", toMoment.year());
38
- } else if (fromResult.start.isOnlyWeekdayComponent() && fromMoment.add(-7, "days").isBefore(toMoment)) {
39
- fromMoment = fromMoment.add(-7, "days");
40
- fromResult.start.imply("day", fromMoment.date());
41
- fromResult.start.imply("month", fromMoment.month() + 1);
42
- fromResult.start.imply("year", fromMoment.year());
43
- } else if (toResult.start.isDateWithUnknownYear() && toMoment.add(1, "years").isAfter(fromMoment)) {
44
- toMoment = toMoment.add(1, "years");
45
- toResult.start.imply("year", toMoment.year());
46
- } else if (fromResult.start.isDateWithUnknownYear() && fromMoment.add(-1, "years").isBefore(toMoment)) {
47
- fromMoment = fromMoment.add(-1, "years");
48
- fromResult.start.imply("year", fromMoment.year());
34
+ if (toResult.start.isOnlyWeekdayComponent() && addDuration(toDate, { day: 7 }) > fromDate) {
35
+ toDate = addDuration(toDate, { day: 7 });
36
+ toResult.start.imply("day", toDate.getDate());
37
+ toResult.start.imply("month", toDate.getMonth() + 1);
38
+ toResult.start.imply("year", toDate.getFullYear());
39
+ } else if (fromResult.start.isOnlyWeekdayComponent() && addDuration(fromDate, { day: -7 }) < toDate) {
40
+ fromDate = addDuration(fromDate, { day: -7 });
41
+ fromResult.start.imply("day", fromDate.getDate());
42
+ fromResult.start.imply("month", fromDate.getMonth() + 1);
43
+ fromResult.start.imply("year", fromDate.getFullYear());
44
+ } else if (toResult.start.isDateWithUnknownYear() && addDuration(toDate, { year: 1 }) > fromDate) {
45
+ toDate = addDuration(toDate, { year: 1 });
46
+ toResult.start.imply("year", toDate.getFullYear());
47
+ } else if (fromResult.start.isDateWithUnknownYear() && addDuration(fromDate, { year: -1 }) < toDate) {
48
+ fromDate = addDuration(fromDate, { year: -1 });
49
+ fromResult.start.imply("year", fromDate.getFullYear());
49
50
  } else {
50
51
  [toResult, fromResult] = [fromResult, toResult];
51
52
  }
52
53
  }
53
-
54
54
  const result = fromResult.clone();
55
55
  result.start = fromResult.start;
56
56
  result.end = toResult.start;
@@ -60,7 +60,6 @@ export default abstract class AbstractMergeDateRangeRefiner extends MergingRefin
60
60
  } else {
61
61
  result.text = toResult.text + textBetween + fromResult.text;
62
62
  }
63
-
64
63
  return result;
65
64
  }
66
65
  }
@@ -6,8 +6,9 @@
6
6
 
7
7
  import { ParsingContext, Refiner } from "../../chrono";
8
8
  import { ParsingResult } from "../../results";
9
- import dayjs from "dayjs";
10
9
  import * as dates from "../../utils/dates";
10
+ import { implySimilarDate } from "../../utils/dates";
11
+ import { addDuration } from "../../calculation/duration";
11
12
 
12
13
  export default class ForwardDateRefiner implements Refiner {
13
14
  refine(context: ParsingContext, results: ParsingResult[]): ParsingResult[] {
@@ -16,7 +17,7 @@ export default class ForwardDateRefiner implements Refiner {
16
17
  }
17
18
 
18
19
  results.forEach((result) => {
19
- let refMoment = dayjs(context.reference.getDateWithAdjustedTimezone());
20
+ let refDate = context.reference.getDateWithAdjustedTimezone();
20
21
 
21
22
  if (result.start.isOnlyTime() && context.reference.instant > result.start.date()) {
22
23
  const refDate = context.reference.getDateWithAdjustedTimezone();
@@ -38,31 +39,25 @@ export default class ForwardDateRefiner implements Refiner {
38
39
  }
39
40
  }
40
41
 
41
- if (result.start.isOnlyWeekdayComponent() && refMoment.isAfter(result.start.dayjs())) {
42
- if (refMoment.day() >= result.start.get("weekday")) {
43
- refMoment = refMoment.day(result.start.get("weekday") + 7);
44
- } else {
45
- refMoment = refMoment.day(<number>result.start.get("weekday"));
42
+ if (result.start.isOnlyWeekdayComponent() && refDate > result.start.date()) {
43
+ let daysToAdd = result.start.get("weekday") - refDate.getDay();
44
+ if (daysToAdd <= 0) {
45
+ daysToAdd += 7;
46
46
  }
47
-
48
- result.start.imply("day", refMoment.date());
49
- result.start.imply("month", refMoment.month() + 1);
50
- result.start.imply("year", refMoment.year());
47
+ refDate = addDuration(refDate, { day: daysToAdd });
48
+ implySimilarDate(result.start, refDate);
51
49
  context.debug(() => {
52
50
  console.log(`${this.constructor.name} adjusted ${result} weekday (${result.start})`);
53
51
  });
54
52
 
55
53
  if (result.end && result.end.isOnlyWeekdayComponent()) {
56
54
  // Adjust date to the coming week
57
- if (refMoment.day() > result.end.get("weekday")) {
58
- refMoment = refMoment.day(result.end.get("weekday") + 7);
59
- } else {
60
- refMoment = refMoment.day(<number>result.end.get("weekday"));
55
+ let daysToAdd = result.end.get("weekday") - refDate.getDay();
56
+ if (daysToAdd <= 0) {
57
+ daysToAdd += 7;
61
58
  }
62
-
63
- result.end.imply("day", refMoment.date());
64
- result.end.imply("month", refMoment.month() + 1);
65
- result.end.imply("year", refMoment.year());
59
+ refDate = addDuration(refDate, { day: daysToAdd });
60
+ implySimilarDate(result.end, refDate);
66
61
  context.debug(() => {
67
62
  console.log(`${this.constructor.name} adjusted ${result} weekday (${result.end})`);
68
63
  });
@@ -70,9 +65,9 @@ export default class ForwardDateRefiner implements Refiner {
70
65
  }
71
66
 
72
67
  // In case where we know the month, but not which year (e.g. "in December", "25th December"),
73
- // try move to another year
74
- if (result.start.isDateWithUnknownYear() && refMoment.isAfter(result.start.dayjs())) {
75
- for (let i = 0; i < 3 && refMoment.isAfter(result.start.dayjs()); i++) {
68
+ // try move to another year (up-to 3 times)
69
+ if (result.start.isDateWithUnknownYear() && refDate > result.start.date()) {
70
+ for (let i = 0; i < 3 && refDate > result.start.date(); i++) {
76
71
  result.start.imply("year", result.start.get("year") + 1);
77
72
  context.debug(() => {
78
73
  console.log(`${this.constructor.name} adjusted ${result} year (${result.start})`);
package/src/index.ts CHANGED
@@ -16,8 +16,10 @@ import * as zh from "./locales/zh";
16
16
  import * as ru from "./locales/ru";
17
17
  import * as es from "./locales/es";
18
18
  import * as uk from "./locales/uk";
19
+ import * as it from "./locales/it";
20
+ import * as sv from "./locales/sv";
19
21
 
20
- export { de, fr, ja, pt, nl, zh, ru, es, uk };
22
+ export { de, fr, ja, pt, nl, zh, ru, es, uk, it, sv };
21
23
 
22
24
  /**
23
25
  * A shortcut for {@link en | chrono.en.strict}
@@ -1,7 +1,7 @@
1
- import { OpUnitType, QUnitType } from "dayjs";
2
1
  import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
3
2
  import { findMostLikelyADYear } from "../../calculation/years";
4
- import { TimeUnits } from "../../utils/timeunits";
3
+ import { Duration } from "../../calculation/duration";
4
+ import { Timeunit } from "../../types";
5
5
 
6
6
  export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
7
7
  "sonntag": 0,
@@ -86,7 +86,7 @@ export const INTEGER_WORD_DICTIONARY: { [word: string]: number } = {
86
86
  "zwoelf": 12,
87
87
  };
88
88
 
89
- export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } = {
89
+ export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
90
90
  sek: "second",
91
91
  sekunde: "second",
92
92
  sekunden: "second",
@@ -97,9 +97,9 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
97
97
  std: "hour",
98
98
  stunde: "hour",
99
99
  stunden: "hour",
100
- tag: "d",
101
- tage: "d",
102
- tagen: "d",
100
+ tag: "day",
101
+ tage: "day",
102
+ tagen: "day",
103
103
  woche: "week",
104
104
  wochen: "week",
105
105
  monat: "month",
@@ -174,7 +174,7 @@ const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
174
174
 
175
175
  export const TIME_UNITS_PATTERN = repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
176
176
 
177
- export function parseTimeUnits(timeunitText): TimeUnits {
177
+ export function parseDuration(timeunitText): Duration {
178
178
  const fragments = {};
179
179
  let remainingText = timeunitText;
180
180
  let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
@@ -183,7 +183,7 @@ export function parseTimeUnits(timeunitText): TimeUnits {
183
183
  remainingText = remainingText.substring(match[0].length);
184
184
  match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
185
185
  }
186
- return fragments;
186
+ return fragments as Duration;
187
187
  }
188
188
 
189
189
  function collectDateTimeFragment(fragments, match) {
@@ -1,10 +1,10 @@
1
1
  import { ParsingContext } from "../../../chrono";
2
2
  import { ParsingComponents, ParsingResult } from "../../../results";
3
- import dayjs from "dayjs";
4
3
  import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
5
- import { assignSimilarDate, assignTheNextDay, implySimilarTime } from "../../../utils/dayjs";
4
+ import { assignSimilarDate, implySimilarTime } from "../../../utils/dates";
6
5
  import DECasualTimeParser from "./DECasualTimeParser";
7
6
  import * as references from "../../../common/casualReferences";
7
+ import { addDuration } from "../../../calculation/duration";
8
8
 
9
9
  const PATTERN = new RegExp(
10
10
  `(jetzt|heute|morgen|übermorgen|uebermorgen|gestern|vorgestern|letzte\\s*nacht)` +
@@ -22,7 +22,7 @@ export default class DECasualDateParser extends AbstractParserWithWordBoundaryCh
22
22
  }
23
23
 
24
24
  innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
25
- let targetDate = dayjs(context.refDate);
25
+ let targetDate = context.reference.getDateWithAdjustedTimezone();
26
26
  const dateKeyword = (match[DATE_GROUP] || "").toLowerCase();
27
27
  const timeKeyword = (match[TIME_GROUP] || "").toLowerCase();
28
28
 
@@ -37,31 +37,34 @@ export default class DECasualDateParser extends AbstractParserWithWordBoundaryCh
37
37
  break;
38
38
 
39
39
  case "morgen":
40
- assignTheNextDay(component, targetDate);
40
+ targetDate = addDuration(targetDate, { day: 1 });
41
+ assignSimilarDate(component, targetDate);
42
+ implySimilarTime(component, targetDate);
41
43
  break;
42
44
 
43
45
  case "übermorgen":
44
46
  case "uebermorgen":
45
- targetDate = targetDate.add(1, "day");
46
- assignTheNextDay(component, targetDate);
47
+ targetDate = addDuration(targetDate, { day: 2 });
48
+ assignSimilarDate(component, targetDate);
49
+ implySimilarTime(component, targetDate);
47
50
  break;
48
51
 
49
52
  case "gestern":
50
- targetDate = targetDate.add(-1, "day");
53
+ targetDate = addDuration(targetDate, { day: -1 });
51
54
  assignSimilarDate(component, targetDate);
52
55
  implySimilarTime(component, targetDate);
53
56
  break;
54
57
 
55
58
  case "vorgestern":
56
- targetDate = targetDate.add(-2, "day");
59
+ targetDate = addDuration(targetDate, { day: -2 });
57
60
  assignSimilarDate(component, targetDate);
58
61
  implySimilarTime(component, targetDate);
59
62
  break;
60
63
 
61
64
  default:
62
65
  if (dateKeyword.match(/letzte\s*nacht/)) {
63
- if (targetDate.hour() > 6) {
64
- targetDate = targetDate.add(-1, "day");
66
+ if (targetDate.getHours() > 6) {
67
+ targetDate = addDuration(targetDate, { day: -1 });
65
68
  }
66
69
 
67
70
  assignSimilarDate(component, targetDate);
@@ -1,10 +1,8 @@
1
1
  import { ParsingContext } from "../../../chrono";
2
2
  import { ParsingComponents, ParsingResult } from "../../../results";
3
- import dayjs from "dayjs";
4
3
  import { Meridiem } from "../../../types";
5
4
  import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
6
- import { implySimilarTime } from "../../../utils/dayjs";
7
- import { addImpliedTimeUnits } from "../../../utils/timeunits";
5
+ import { implySimilarTime } from "../../../utils/dates";
8
6
 
9
7
  export default class DECasualTimeParser extends AbstractParserWithWordBoundaryChecking {
10
8
  innerPattern(context: ParsingContext): RegExp {
@@ -12,7 +10,7 @@ export default class DECasualTimeParser extends AbstractParserWithWordBoundaryCh
12
10
  }
13
11
 
14
12
  innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
15
- const targetDate = dayjs(context.refDate);
13
+ const targetDate = context.refDate;
16
14
  const timeKeywordPattern = match[2].toLowerCase();
17
15
  const component = context.createParsingComponents();
18
16
  implySimilarTime(component, targetDate);
@@ -66,7 +64,7 @@ export default class DECasualTimeParser extends AbstractParserWithWordBoundaryCh
66
64
 
67
65
  case "mitternacht":
68
66
  if (component.get("hour") > 1) {
69
- component = addImpliedTimeUnits(component, { "day": 1 });
67
+ component.addDurationAsImplied({ "day": 1 });
70
68
  }
71
69
 
72
70
  component.imply("hour", 0);
@@ -2,8 +2,8 @@ import { ParsingContext } from "../../../chrono";
2
2
  import { NUMBER_PATTERN, parseNumberPattern, TIME_UNIT_DICTIONARY } from "../constants";
3
3
  import { ParsingComponents } from "../../../results";
4
4
  import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
5
- import { reverseTimeUnits } from "../../../utils/timeunits";
6
5
  import { matchAnyPattern } from "../../../utils/pattern";
6
+ import { reverseDuration } from "../../../calculation/duration";
7
7
 
8
8
  export default class DETimeUnitAgoFormatParser extends AbstractParserWithWordBoundaryChecking {
9
9
  constructor() {
@@ -34,7 +34,7 @@ export default class DETimeUnitAgoFormatParser extends AbstractParserWithWordBou
34
34
  }
35
35
 
36
36
  if (/vor/.test(modifier) || /letzte/.test(modifier) || /vergangen/.test(modifier)) {
37
- timeUnits = reverseTimeUnits(timeUnits);
37
+ timeUnits = reverseDuration(timeUnits);
38
38
  }
39
39
 
40
40
  return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
@@ -1,4 +1,4 @@
1
- import { TIME_UNITS_PATTERN, parseTimeUnits } from "../constants";
1
+ import { TIME_UNITS_PATTERN, parseDuration } from "../constants";
2
2
  import { ParsingContext } from "../../../chrono";
3
3
  import { ParsingComponents } from "../../../results";
4
4
  import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
@@ -9,7 +9,7 @@ export default class DETimeUnitWithinFormatParser extends AbstractParserWithWord
9
9
  }
10
10
 
11
11
  innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
12
- const timeUnits = parseTimeUnits(match[1]);
12
+ const timeUnits = parseDuration(match[1]);
13
13
  return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
14
14
  }
15
15
  }
@@ -1,8 +1,7 @@
1
- import { OpUnitType, QUnitType } from "dayjs";
2
1
  import { matchAnyPattern, repeatedTimeunitPattern } from "../../utils/pattern";
3
2
  import { findMostLikelyADYear } from "../../calculation/years";
4
- import { TimeUnits } from "../../utils/timeunits";
5
- import { Weekday } from "../../types";
3
+ import { Duration } from "../../calculation/duration";
4
+ import { Timeunit, Weekday } from "../../types";
6
5
 
7
6
  export const WEEKDAY_DICTIONARY: { [word: string]: Weekday } = {
8
7
  sunday: 0,
@@ -134,15 +133,15 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
134
133
  "thirty-first": 31,
135
134
  };
136
135
 
137
- export const TIME_UNIT_DICTIONARY_NO_ABBR: { [word: string]: OpUnitType | QUnitType } = {
136
+ export const TIME_UNIT_DICTIONARY_NO_ABBR: { [word: string]: Timeunit } = {
138
137
  second: "second",
139
138
  seconds: "second",
140
139
  minute: "minute",
141
140
  minutes: "minute",
142
141
  hour: "hour",
143
142
  hours: "hour",
144
- day: "d",
145
- days: "d",
143
+ day: "day",
144
+ days: "day",
146
145
  week: "week",
147
146
  weeks: "week",
148
147
  month: "month",
@@ -153,7 +152,7 @@ export const TIME_UNIT_DICTIONARY_NO_ABBR: { [word: string]: OpUnitType | QUnitT
153
152
  years: "year",
154
153
  };
155
154
 
156
- export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } = {
155
+ export const TIME_UNIT_DICTIONARY: { [word: string]: Timeunit } = {
157
156
  s: "second",
158
157
  sec: "second",
159
158
  second: "second",
@@ -168,10 +167,10 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
168
167
  hrs: "hour",
169
168
  hour: "hour",
170
169
  hours: "hour",
171
- d: "d",
172
- day: "d",
173
- days: "d",
174
- w: "w",
170
+ d: "day",
171
+ day: "day",
172
+ days: "day",
173
+ w: "week",
175
174
  week: "week",
176
175
  weeks: "week",
177
176
  mo: "month",
@@ -277,7 +276,7 @@ export const TIME_UNITS_NO_ABBR_PATTERN = repeatedTimeunitPattern(
277
276
  TIME_UNIT_CONNECTOR_PATTERN
278
277
  );
279
278
 
280
- export function parseTimeUnits(timeunitText): null | TimeUnits {
279
+ export function parseDuration(timeunitText): null | Duration {
281
280
  const fragments = {};
282
281
  let remainingText = timeunitText;
283
282
  let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
@@ -289,7 +288,7 @@ export function parseTimeUnits(timeunitText): null | TimeUnits {
289
288
  if (Object.keys(fragments).length == 0) {
290
289
  return null;
291
290
  }
292
- return fragments;
291
+ return fragments as Duration;
293
292
  }
294
293
 
295
294
  function collectDateTimeFragment(fragments, match) {
@@ -1,8 +1,7 @@
1
1
  import { ParsingContext } from "../../../chrono";
2
2
  import { ParsingComponents, ParsingResult } from "../../../results";
3
- import dayjs from "dayjs";
4
3
  import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
5
- import { assignSimilarDate } from "../../../utils/dayjs";
4
+ import { assignSimilarDate } from "../../../utils/dates";
6
5
  import * as references from "../../../common/casualReferences";
7
6
 
8
7
  const PATTERN = /(now|today|tonight|tomorrow|overmorrow|tmr|tmrw|yesterday|last\s*night)(?=\W|$)/i;
@@ -13,7 +12,7 @@ export default class ENCasualDateParser extends AbstractParserWithWordBoundaryCh
13
12
  }
14
13
 
15
14
  innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
16
- let targetDate = dayjs(context.refDate);
15
+ let targetDate = context.refDate;
17
16
  const lowerText = match[0].toLowerCase();
18
17
  let component = context.createParsingComponents();
19
18
 
@@ -46,8 +45,10 @@ export default class ENCasualDateParser extends AbstractParserWithWordBoundaryCh
46
45
 
47
46
  default:
48
47
  if (lowerText.match(/last\s*night/)) {
49
- if (targetDate.hour() > 6) {
50
- targetDate = targetDate.add(-1, "day");
48
+ if (targetDate.getHours() > 6) {
49
+ const previousDay = new Date(targetDate.getTime());
50
+ previousDay.setDate(previousDay.getDate() - 1);
51
+ targetDate = previousDay;
51
52
  }
52
53
 
53
54
  assignSimilarDate(component, targetDate);
@@ -1,7 +1,6 @@
1
1
  import { TIME_UNIT_DICTIONARY } from "../constants";
2
2
  import { ParsingContext } from "../../../chrono";
3
3
  import { ParsingComponents } from "../../../results";
4
- import dayjs from "dayjs";
5
4
  import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
6
5
  import { matchAnyPattern } from "../../../utils/pattern";
7
6
 
@@ -36,32 +35,31 @@ export default class ENRelativeDateFormatParser extends AbstractParserWithWordBo
36
35
  }
37
36
 
38
37
  const components = context.createParsingComponents();
39
- let date = dayjs(context.reference.instant);
38
+ let date = new Date(context.reference.instant.getTime());
40
39
 
41
40
  // This week
42
41
  if (unitWord.match(/week/i)) {
43
- date = date.add(-date.get("d"), "d");
44
- components.imply("day", date.date());
45
- components.imply("month", date.month() + 1);
46
- components.imply("year", date.year());
42
+ date.setDate(date.getDate() - date.getDay());
43
+ components.imply("day", date.getDate());
44
+ components.imply("month", date.getMonth() + 1);
45
+ components.imply("year", date.getFullYear());
47
46
  }
48
47
 
49
48
  // This month
50
49
  else if (unitWord.match(/month/i)) {
51
- date = date.add(-date.date() + 1, "d");
52
- components.imply("day", date.date());
53
- components.assign("year", date.year());
54
- components.assign("month", date.month() + 1);
50
+ date.setDate(1);
51
+ components.imply("day", date.getDate());
52
+ components.assign("year", date.getFullYear());
53
+ components.assign("month", date.getMonth() + 1);
55
54
  }
56
55
 
57
56
  // This year
58
57
  else if (unitWord.match(/year/i)) {
59
- date = date.add(-date.date() + 1, "d");
60
- date = date.add(-date.month(), "month");
61
-
62
- components.imply("day", date.date());
63
- components.imply("month", date.month() + 1);
64
- components.assign("year", date.year());
58
+ date.setDate(1);
59
+ date.setMonth(0);
60
+ components.imply("day", date.getDate());
61
+ components.imply("month", date.getMonth() + 1);
62
+ components.assign("year", date.getFullYear());
65
63
  }
66
64
 
67
65
  return components;
@@ -1,5 +1,5 @@
1
1
  import { ParsingContext } from "../../../chrono";
2
- import { parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN, 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";
@@ -17,7 +17,7 @@ export default class ENTimeUnitAgoFormatParser extends AbstractParserWithWordBou
17
17
  }
18
18
 
19
19
  innerExtract(context: ParsingContext, match: RegExpMatchArray) {
20
- const duration = parseTimeUnits(match[1]);
20
+ const duration = parseDuration(match[1]);
21
21
  if (!duration) {
22
22
  return null;
23
23
  }
@@ -1,4 +1,4 @@
1
- import { TIME_UNITS_PATTERN, parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN } 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";
@@ -21,7 +21,7 @@ export default class ENTimeUnitCasualRelativeFormatParser extends AbstractParser
21
21
 
22
22
  innerExtract(context: ParsingContext, match: RegExpMatchArray) {
23
23
  const prefix = match[1].toLowerCase();
24
- let duration = parseTimeUnits(match[2]);
24
+ let duration = parseDuration(match[2]);
25
25
  if (!duration) {
26
26
  return null;
27
27
  }
@@ -1,5 +1,5 @@
1
1
  import { ParsingContext } from "../../../chrono";
2
- import { parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN, 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
 
@@ -21,7 +21,7 @@ export default class ENTimeUnitLaterFormatParser extends AbstractParserWithWordB
21
21
  }
22
22
 
23
23
  innerExtract(context: ParsingContext, match: RegExpMatchArray) {
24
- const timeUnits = parseTimeUnits(match[GROUP_NUM_TIMEUNITS]);
24
+ const timeUnits = parseDuration(match[GROUP_NUM_TIMEUNITS]);
25
25
  if (!timeUnits) {
26
26
  return null;
27
27
  }
@@ -1,4 +1,4 @@
1
- import { TIME_UNITS_PATTERN, parseTimeUnits, TIME_UNITS_NO_ABBR_PATTERN } 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";
@@ -38,15 +38,10 @@ export default class ENTimeUnitWithinFormatParser extends AbstractParserWithWord
38
38
  if (match[0].match(/^for\s*the\s*\w+/)) {
39
39
  return null;
40
40
  }
41
- const timeUnits = parseTimeUnits(match[1]);
41
+ const timeUnits = parseDuration(match[1]);
42
42
  if (!timeUnits) {
43
43
  return null;
44
44
  }
45
- context.debug(() => {
46
- console.log(timeUnits);
47
- console.log(ParsingComponents.createRelativeFromReference(context.reference, timeUnits));
48
- });
49
-
50
45
  return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
51
46
  }
52
47
  }
@@ -1,7 +1,7 @@
1
1
  import { MergingRefiner } from "../../../common/abstractRefiners";
2
2
  import { ParsingComponents, ParsingResult, ReferenceWithTimezone } from "../../../results";
3
- import { parseTimeUnits } from "../constants";
4
- import { reverseTimeUnits } from "../../../utils/timeunits";
3
+ import { parseDuration } from "../constants";
4
+ import { reverseDuration } from "../../../calculation/duration";
5
5
 
6
6
  function IsPositiveFollowingReference(result: ParsingResult): boolean {
7
7
  return result.text.match(/^[+-]/i) != null;
@@ -26,13 +26,13 @@ export default class ENMergeRelativeAfterDateRefiner extends MergingRefiner {
26
26
  }
27
27
 
28
28
  mergeResults(textBetween: string, currentResult: ParsingResult, nextResult: ParsingResult, context): ParsingResult {
29
- let timeUnits = parseTimeUnits(nextResult.text);
29
+ let timeUnits = parseDuration(nextResult.text);
30
30
  if (IsNegativeFollowingReference(nextResult)) {
31
- timeUnits = reverseTimeUnits(timeUnits);
31
+ timeUnits = reverseDuration(timeUnits);
32
32
  }
33
33
 
34
34
  const components = ParsingComponents.createRelativeFromReference(
35
- new ReferenceWithTimezone(currentResult.start.date()),
35
+ ReferenceWithTimezone.fromDate(currentResult.start.date()),
36
36
  timeUnits
37
37
  );
38
38
 
@@ -1,6 +1,6 @@
1
1
  import { MergingRefiner } from "../../../common/abstractRefiners";
2
2
  import { ParsingComponents, ParsingResult, ReferenceWithTimezone } from "../../../results";
3
- import { parseTimeUnits } from "../constants";
3
+ import { parseDuration } from "../constants";
4
4
  import { reverseDuration } from "../../../calculation/duration";
5
5
 
6
6
  function hasImpliedEarlierReferenceDate(result: ParsingResult): boolean {
@@ -38,13 +38,13 @@ export default class ENMergeRelativeFollowByDateRefiner extends MergingRefiner {
38
38
  }
39
39
 
40
40
  mergeResults(textBetween: string, currentResult: ParsingResult, nextResult: ParsingResult): ParsingResult {
41
- let duration = parseTimeUnits(currentResult.text);
41
+ let duration = parseDuration(currentResult.text);
42
42
  if (hasImpliedEarlierReferenceDate(currentResult)) {
43
43
  duration = reverseDuration(duration);
44
44
  }
45
45
 
46
46
  const components = ParsingComponents.createRelativeFromReference(
47
- new ReferenceWithTimezone(nextResult.start.date()),
47
+ ReferenceWithTimezone.fromDate(nextResult.start.date()),
48
48
  duration
49
49
  );
50
50