@mui/x-date-pickers 6.15.0 → 6.16.0

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 (428) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/DateCalendar/DateCalendar.js +6 -2
  3. package/DateCalendar/DateCalendar.types.d.ts +1 -1
  4. package/DateCalendar/DayCalendar.d.ts +6 -5
  5. package/DateCalendar/DayCalendar.js +18 -6
  6. package/DateCalendar/dayCalendarClasses.d.ts +2 -0
  7. package/DateCalendar/dayCalendarClasses.js +1 -1
  8. package/DateField/DateField.js +32 -4
  9. package/DateField/DateField.types.d.ts +3 -2
  10. package/DatePicker/DatePicker.js +6 -2
  11. package/DateTimeField/DateTimeField.js +32 -4
  12. package/DateTimeField/DateTimeField.types.d.ts +3 -2
  13. package/DateTimePicker/DateTimePicker.js +6 -2
  14. package/DateTimePicker/DateTimePickerToolbar.js +1 -0
  15. package/DesktopDatePicker/DesktopDatePicker.js +6 -2
  16. package/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  17. package/MobileDatePicker/MobileDatePicker.js +6 -2
  18. package/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  19. package/StaticDatePicker/StaticDatePicker.js +6 -2
  20. package/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  21. package/TimeField/TimeField.js +29 -4
  22. package/TimeField/TimeField.types.d.ts +3 -2
  23. package/TimePicker/TimePickerToolbar.js +1 -0
  24. package/hooks/index.d.ts +1 -0
  25. package/hooks/index.js +1 -0
  26. package/hooks/package.json +6 -0
  27. package/hooks/useClearableField.d.ts +25 -0
  28. package/hooks/useClearableField.js +79 -0
  29. package/icons/index.d.ts +6 -0
  30. package/icons/index.js +8 -1
  31. package/index.d.ts +1 -0
  32. package/index.js +3 -2
  33. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  34. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -2
  35. package/internals/hooks/useField/index.d.ts +1 -1
  36. package/internals/hooks/useField/useField.js +24 -6
  37. package/internals/hooks/useField/useField.types.d.ts +31 -1
  38. package/internals/index.d.ts +1 -1
  39. package/internals/models/props/toolbar.d.ts +3 -0
  40. package/internals/models/validation.d.ts +3 -0
  41. package/internals/utils/date-utils.d.ts +1 -0
  42. package/internals/utils/date-utils.js +4 -0
  43. package/legacy/DateCalendar/DateCalendar.js +6 -2
  44. package/legacy/DateCalendar/DayCalendar.js +22 -9
  45. package/legacy/DateCalendar/dayCalendarClasses.js +1 -1
  46. package/legacy/DateField/DateField.js +30 -3
  47. package/legacy/DatePicker/DatePicker.js +6 -2
  48. package/legacy/DateTimeField/DateTimeField.js +30 -3
  49. package/legacy/DateTimePicker/DateTimePicker.js +6 -2
  50. package/legacy/DateTimePicker/DateTimePickerToolbar.js +1 -0
  51. package/legacy/DesktopDatePicker/DesktopDatePicker.js +6 -2
  52. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  53. package/legacy/MobileDatePicker/MobileDatePicker.js +6 -2
  54. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  55. package/legacy/StaticDatePicker/StaticDatePicker.js +6 -2
  56. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  57. package/legacy/TimeField/TimeField.js +27 -3
  58. package/legacy/TimePicker/TimePickerToolbar.js +1 -0
  59. package/legacy/hooks/index.js +1 -0
  60. package/legacy/hooks/useClearableField.js +80 -0
  61. package/legacy/icons/index.js +8 -1
  62. package/legacy/index.js +3 -2
  63. package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  64. package/legacy/internals/hooks/useField/useField.js +28 -7
  65. package/legacy/internals/utils/date-utils.js +6 -0
  66. package/legacy/locales/beBY.js +2 -0
  67. package/legacy/locales/caES.js +2 -0
  68. package/legacy/locales/csCZ.js +2 -0
  69. package/legacy/locales/daDK.js +2 -0
  70. package/legacy/locales/deDE.js +2 -0
  71. package/legacy/locales/elGR.js +2 -0
  72. package/legacy/locales/enUS.js +1 -0
  73. package/legacy/locales/esES.js +2 -0
  74. package/legacy/locales/faIR.js +2 -0
  75. package/legacy/locales/fiFI.js +2 -0
  76. package/legacy/locales/frFR.js +2 -0
  77. package/legacy/locales/heIL.js +2 -0
  78. package/legacy/locales/huHU.js +1 -0
  79. package/legacy/locales/isIS.js +2 -0
  80. package/legacy/locales/itIT.js +2 -0
  81. package/legacy/locales/jaJP.js +2 -0
  82. package/legacy/locales/koKR.js +2 -0
  83. package/legacy/locales/kzKZ.js +2 -0
  84. package/legacy/locales/nbNO.js +2 -0
  85. package/legacy/locales/nlNL.js +2 -0
  86. package/legacy/locales/plPL.js +2 -0
  87. package/legacy/locales/ptBR.js +2 -0
  88. package/legacy/locales/roRO.js +1 -0
  89. package/legacy/locales/ruRU.js +2 -0
  90. package/legacy/locales/skSK.js +2 -0
  91. package/legacy/locales/svSE.js +2 -0
  92. package/legacy/locales/trTR.js +2 -0
  93. package/legacy/locales/ukUA.js +2 -0
  94. package/legacy/locales/urPK.js +2 -0
  95. package/legacy/locales/viVN.js +2 -0
  96. package/legacy/locales/zhCN.js +2 -0
  97. package/legacy/locales/zhHK.js +2 -0
  98. package/locales/beBY.d.ts +1 -0
  99. package/locales/beBY.js +2 -0
  100. package/locales/caES.d.ts +1 -0
  101. package/locales/caES.js +2 -0
  102. package/locales/csCZ.d.ts +1 -0
  103. package/locales/csCZ.js +2 -0
  104. package/locales/daDK.d.ts +1 -0
  105. package/locales/daDK.js +2 -0
  106. package/locales/deDE.d.ts +1 -0
  107. package/locales/deDE.js +2 -0
  108. package/locales/elGR.d.ts +1 -0
  109. package/locales/elGR.js +2 -0
  110. package/locales/enUS.d.ts +1 -0
  111. package/locales/enUS.js +1 -0
  112. package/locales/esES.d.ts +1 -0
  113. package/locales/esES.js +2 -0
  114. package/locales/faIR.d.ts +1 -0
  115. package/locales/faIR.js +2 -0
  116. package/locales/fiFI.d.ts +1 -0
  117. package/locales/fiFI.js +2 -0
  118. package/locales/frFR.d.ts +1 -0
  119. package/locales/frFR.js +2 -0
  120. package/locales/heIL.d.ts +1 -0
  121. package/locales/heIL.js +2 -0
  122. package/locales/huHU.d.ts +1 -0
  123. package/locales/huHU.js +1 -0
  124. package/locales/isIS.d.ts +1 -0
  125. package/locales/isIS.js +2 -0
  126. package/locales/itIT.d.ts +1 -0
  127. package/locales/itIT.js +2 -0
  128. package/locales/jaJP.d.ts +1 -0
  129. package/locales/jaJP.js +2 -0
  130. package/locales/koKR.d.ts +1 -0
  131. package/locales/koKR.js +2 -0
  132. package/locales/kzKZ.d.ts +1 -0
  133. package/locales/kzKZ.js +2 -0
  134. package/locales/nbNO.d.ts +1 -0
  135. package/locales/nbNO.js +2 -0
  136. package/locales/nlNL.d.ts +1 -0
  137. package/locales/nlNL.js +2 -0
  138. package/locales/plPL.d.ts +1 -0
  139. package/locales/plPL.js +2 -0
  140. package/locales/ptBR.d.ts +1 -0
  141. package/locales/ptBR.js +2 -0
  142. package/locales/roRO.d.ts +1 -0
  143. package/locales/roRO.js +1 -0
  144. package/locales/ruRU.d.ts +1 -0
  145. package/locales/ruRU.js +2 -0
  146. package/locales/skSK.d.ts +1 -0
  147. package/locales/skSK.js +2 -0
  148. package/locales/svSE.d.ts +1 -0
  149. package/locales/svSE.js +2 -0
  150. package/locales/trTR.d.ts +1 -0
  151. package/locales/trTR.js +2 -0
  152. package/locales/ukUA.d.ts +1 -0
  153. package/locales/ukUA.js +2 -0
  154. package/locales/urPK.d.ts +1 -0
  155. package/locales/urPK.js +2 -0
  156. package/locales/utils/getPickersLocalization.d.ts +1 -0
  157. package/locales/utils/pickersLocaleTextApi.d.ts +1 -0
  158. package/locales/viVN.d.ts +1 -0
  159. package/locales/viVN.js +2 -0
  160. package/locales/zhCN.d.ts +1 -0
  161. package/locales/zhCN.js +2 -0
  162. package/locales/zhHK.d.ts +1 -0
  163. package/locales/zhHK.js +2 -0
  164. package/models/adapters.d.ts +1 -0
  165. package/models/fields.d.ts +2 -0
  166. package/modern/DateCalendar/DateCalendar.js +6 -2
  167. package/modern/DateCalendar/DayCalendar.js +25 -11
  168. package/modern/DateCalendar/dayCalendarClasses.js +1 -1
  169. package/modern/DateField/DateField.js +32 -4
  170. package/modern/DatePicker/DatePicker.js +6 -2
  171. package/modern/DateTimeField/DateTimeField.js +32 -4
  172. package/modern/DateTimePicker/DateTimePicker.js +6 -2
  173. package/modern/DateTimePicker/DateTimePickerToolbar.js +1 -0
  174. package/modern/DesktopDatePicker/DesktopDatePicker.js +6 -2
  175. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  176. package/modern/MobileDatePicker/MobileDatePicker.js +6 -2
  177. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  178. package/modern/StaticDatePicker/StaticDatePicker.js +6 -2
  179. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  180. package/modern/TimeField/TimeField.js +29 -4
  181. package/modern/TimePicker/TimePickerToolbar.js +1 -0
  182. package/modern/hooks/index.js +1 -0
  183. package/modern/hooks/useClearableField.js +78 -0
  184. package/modern/icons/index.js +8 -1
  185. package/modern/index.js +3 -2
  186. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  187. package/modern/internals/hooks/useField/useField.js +23 -6
  188. package/modern/internals/utils/date-utils.js +4 -0
  189. package/modern/locales/beBY.js +2 -0
  190. package/modern/locales/caES.js +2 -0
  191. package/modern/locales/csCZ.js +2 -0
  192. package/modern/locales/daDK.js +2 -0
  193. package/modern/locales/deDE.js +2 -0
  194. package/modern/locales/elGR.js +2 -0
  195. package/modern/locales/enUS.js +1 -0
  196. package/modern/locales/esES.js +2 -0
  197. package/modern/locales/faIR.js +2 -0
  198. package/modern/locales/fiFI.js +2 -0
  199. package/modern/locales/frFR.js +2 -0
  200. package/modern/locales/heIL.js +2 -0
  201. package/modern/locales/huHU.js +1 -0
  202. package/modern/locales/isIS.js +2 -0
  203. package/modern/locales/itIT.js +2 -0
  204. package/modern/locales/jaJP.js +2 -0
  205. package/modern/locales/koKR.js +2 -0
  206. package/modern/locales/kzKZ.js +2 -0
  207. package/modern/locales/nbNO.js +2 -0
  208. package/modern/locales/nlNL.js +2 -0
  209. package/modern/locales/plPL.js +2 -0
  210. package/modern/locales/ptBR.js +2 -0
  211. package/modern/locales/roRO.js +1 -0
  212. package/modern/locales/ruRU.js +2 -0
  213. package/modern/locales/skSK.js +2 -0
  214. package/modern/locales/svSE.js +2 -0
  215. package/modern/locales/trTR.js +2 -0
  216. package/modern/locales/ukUA.js +2 -0
  217. package/modern/locales/urPK.js +2 -0
  218. package/modern/locales/viVN.js +2 -0
  219. package/modern/locales/zhCN.js +2 -0
  220. package/modern/locales/zhHK.js +2 -0
  221. package/node/DateCalendar/DateCalendar.js +6 -2
  222. package/node/DateCalendar/DayCalendar.js +24 -10
  223. package/node/DateCalendar/dayCalendarClasses.js +1 -1
  224. package/node/DateField/DateField.js +32 -4
  225. package/node/DatePicker/DatePicker.js +6 -2
  226. package/node/DateTimeField/DateTimeField.js +32 -4
  227. package/node/DateTimePicker/DateTimePicker.js +6 -2
  228. package/node/DateTimePicker/DateTimePickerToolbar.js +1 -0
  229. package/node/DesktopDatePicker/DesktopDatePicker.js +6 -2
  230. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  231. package/node/MobileDatePicker/MobileDatePicker.js +6 -2
  232. package/node/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  233. package/node/StaticDatePicker/StaticDatePicker.js +6 -2
  234. package/node/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  235. package/node/TimeField/TimeField.js +29 -4
  236. package/node/TimePicker/TimePickerToolbar.js +1 -0
  237. package/node/hooks/index.js +12 -0
  238. package/node/hooks/useClearableField.js +87 -0
  239. package/node/icons/index.js +10 -2
  240. package/node/index.js +13 -1
  241. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  242. package/node/internals/hooks/useField/useField.js +23 -6
  243. package/node/internals/utils/date-utils.js +7 -2
  244. package/node/locales/beBY.js +2 -0
  245. package/node/locales/caES.js +2 -0
  246. package/node/locales/csCZ.js +2 -0
  247. package/node/locales/daDK.js +2 -0
  248. package/node/locales/deDE.js +2 -0
  249. package/node/locales/elGR.js +2 -0
  250. package/node/locales/enUS.js +1 -0
  251. package/node/locales/esES.js +2 -0
  252. package/node/locales/faIR.js +2 -0
  253. package/node/locales/fiFI.js +2 -0
  254. package/node/locales/frFR.js +2 -0
  255. package/node/locales/heIL.js +2 -0
  256. package/node/locales/huHU.js +1 -0
  257. package/node/locales/isIS.js +2 -0
  258. package/node/locales/itIT.js +2 -0
  259. package/node/locales/jaJP.js +2 -0
  260. package/node/locales/koKR.js +2 -0
  261. package/node/locales/kzKZ.js +2 -0
  262. package/node/locales/nbNO.js +2 -0
  263. package/node/locales/nlNL.js +2 -0
  264. package/node/locales/plPL.js +2 -0
  265. package/node/locales/ptBR.js +2 -0
  266. package/node/locales/roRO.js +1 -0
  267. package/node/locales/ruRU.js +2 -0
  268. package/node/locales/skSK.js +2 -0
  269. package/node/locales/svSE.js +2 -0
  270. package/node/locales/trTR.js +2 -0
  271. package/node/locales/ukUA.js +2 -0
  272. package/node/locales/urPK.js +2 -0
  273. package/node/locales/viVN.js +2 -0
  274. package/node/locales/zhCN.js +2 -0
  275. package/node/locales/zhHK.js +2 -0
  276. package/package.json +1 -1
  277. package/legacy/tests/describe.types.js +0 -1
  278. package/legacy/tests/describeAdapters/describeAdapters.js +0 -29
  279. package/legacy/tests/describeAdapters/index.js +0 -1
  280. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -32
  281. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -1
  282. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -2
  283. package/legacy/tests/describeGregorianAdapter/index.js +0 -2
  284. package/legacy/tests/describeGregorianAdapter/testCalculations.js +0 -707
  285. package/legacy/tests/describeGregorianAdapter/testFormat.js +0 -26
  286. package/legacy/tests/describeGregorianAdapter/testLocalization.js +0 -49
  287. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +0 -21
  288. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -1
  289. package/legacy/tests/describeHijriAdapter/index.js +0 -1
  290. package/legacy/tests/describeHijriAdapter/testCalculations.js +0 -167
  291. package/legacy/tests/describeHijriAdapter/testLocalization.js +0 -20
  292. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -21
  293. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -1
  294. package/legacy/tests/describeJalaliAdapter/index.js +0 -1
  295. package/legacy/tests/describeJalaliAdapter/testCalculations.js +0 -236
  296. package/legacy/tests/describeJalaliAdapter/testLocalization.js +0 -20
  297. package/legacy/tests/describePicker/describePicker.js +0 -159
  298. package/legacy/tests/describePicker/describePicker.types.js +0 -1
  299. package/legacy/tests/describePicker/index.js +0 -1
  300. package/legacy/tests/describeValidation/describeValidation.js +0 -31
  301. package/legacy/tests/describeValidation/describeValidation.types.js +0 -1
  302. package/legacy/tests/describeValidation/index.js +0 -1
  303. package/legacy/tests/describeValidation/testDayViewValidation.js +0 -281
  304. package/legacy/tests/describeValidation/testMinutesViewValidation.js +0 -194
  305. package/legacy/tests/describeValidation/testMonthViewValidation.js +0 -136
  306. package/legacy/tests/describeValidation/testTextFieldValidation.js +0 -463
  307. package/legacy/tests/describeValidation/testYearViewValidation.js +0 -95
  308. package/legacy/tests/describeValue/describeValue.js +0 -57
  309. package/legacy/tests/describeValue/describeValue.types.js +0 -1
  310. package/legacy/tests/describeValue/index.js +0 -1
  311. package/legacy/tests/describeValue/testControlledUnControlled.js +0 -237
  312. package/legacy/tests/describeValue/testPickerActionBar.js +0 -250
  313. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -362
  314. package/legacy/tests/describeValue/testShortcuts.js +0 -119
  315. package/modern/tests/describe.types.js +0 -1
  316. package/modern/tests/describeAdapters/describeAdapters.js +0 -29
  317. package/modern/tests/describeAdapters/index.js +0 -1
  318. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -29
  319. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -1
  320. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -2
  321. package/modern/tests/describeGregorianAdapter/index.js +0 -2
  322. package/modern/tests/describeGregorianAdapter/testCalculations.js +0 -706
  323. package/modern/tests/describeGregorianAdapter/testFormat.js +0 -27
  324. package/modern/tests/describeGregorianAdapter/testLocalization.js +0 -50
  325. package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +0 -21
  326. package/modern/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -1
  327. package/modern/tests/describeHijriAdapter/index.js +0 -1
  328. package/modern/tests/describeHijriAdapter/testCalculations.js +0 -164
  329. package/modern/tests/describeHijriAdapter/testLocalization.js +0 -21
  330. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -21
  331. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -1
  332. package/modern/tests/describeJalaliAdapter/index.js +0 -1
  333. package/modern/tests/describeJalaliAdapter/testCalculations.js +0 -237
  334. package/modern/tests/describeJalaliAdapter/testLocalization.js +0 -21
  335. package/modern/tests/describePicker/describePicker.js +0 -162
  336. package/modern/tests/describePicker/describePicker.types.js +0 -1
  337. package/modern/tests/describePicker/index.js +0 -1
  338. package/modern/tests/describeValidation/describeValidation.js +0 -31
  339. package/modern/tests/describeValidation/describeValidation.types.js +0 -1
  340. package/modern/tests/describeValidation/index.js +0 -1
  341. package/modern/tests/describeValidation/testDayViewValidation.js +0 -280
  342. package/modern/tests/describeValidation/testMinutesViewValidation.js +0 -193
  343. package/modern/tests/describeValidation/testMonthViewValidation.js +0 -137
  344. package/modern/tests/describeValidation/testTextFieldValidation.js +0 -470
  345. package/modern/tests/describeValidation/testYearViewValidation.js +0 -94
  346. package/modern/tests/describeValue/describeValue.js +0 -59
  347. package/modern/tests/describeValue/describeValue.types.js +0 -1
  348. package/modern/tests/describeValue/index.js +0 -1
  349. package/modern/tests/describeValue/testControlledUnControlled.js +0 -239
  350. package/modern/tests/describeValue/testPickerActionBar.js +0 -254
  351. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -371
  352. package/modern/tests/describeValue/testShortcuts.js +0 -112
  353. package/node/tests/describe.types.js +0 -5
  354. package/node/tests/describeAdapters/describeAdapters.js +0 -37
  355. package/node/tests/describeAdapters/index.js +0 -12
  356. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -37
  357. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -5
  358. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -10
  359. package/node/tests/describeGregorianAdapter/index.js +0 -19
  360. package/node/tests/describeGregorianAdapter/testCalculations.js +0 -711
  361. package/node/tests/describeGregorianAdapter/testFormat.js +0 -34
  362. package/node/tests/describeGregorianAdapter/testLocalization.js +0 -57
  363. package/node/tests/describeHijriAdapter/describeHijriAdapter.js +0 -29
  364. package/node/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -5
  365. package/node/tests/describeHijriAdapter/index.js +0 -12
  366. package/node/tests/describeHijriAdapter/testCalculations.js +0 -171
  367. package/node/tests/describeHijriAdapter/testLocalization.js +0 -28
  368. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -29
  369. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -5
  370. package/node/tests/describeJalaliAdapter/index.js +0 -12
  371. package/node/tests/describeJalaliAdapter/testCalculations.js +0 -244
  372. package/node/tests/describeJalaliAdapter/testLocalization.js +0 -28
  373. package/node/tests/describePicker/describePicker.js +0 -173
  374. package/node/tests/describePicker/describePicker.types.js +0 -5
  375. package/node/tests/describePicker/index.js +0 -12
  376. package/node/tests/describeValidation/describeValidation.js +0 -39
  377. package/node/tests/describeValidation/describeValidation.types.js +0 -5
  378. package/node/tests/describeValidation/index.js +0 -12
  379. package/node/tests/describeValidation/testDayViewValidation.js +0 -290
  380. package/node/tests/describeValidation/testMinutesViewValidation.js +0 -203
  381. package/node/tests/describeValidation/testMonthViewValidation.js +0 -147
  382. package/node/tests/describeValidation/testTextFieldValidation.js +0 -480
  383. package/node/tests/describeValidation/testYearViewValidation.js +0 -104
  384. package/node/tests/describeValue/describeValue.js +0 -69
  385. package/node/tests/describeValue/describeValue.types.js +0 -5
  386. package/node/tests/describeValue/index.js +0 -12
  387. package/node/tests/describeValue/testControlledUnControlled.js +0 -248
  388. package/node/tests/describeValue/testPickerActionBar.js +0 -264
  389. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -381
  390. package/node/tests/describeValue/testShortcuts.js +0 -122
  391. package/tests/describe.types.js +0 -1
  392. package/tests/describeAdapters/describeAdapters.js +0 -29
  393. package/tests/describeAdapters/index.js +0 -1
  394. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -30
  395. package/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -1
  396. package/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -2
  397. package/tests/describeGregorianAdapter/index.js +0 -2
  398. package/tests/describeGregorianAdapter/testCalculations.js +0 -706
  399. package/tests/describeGregorianAdapter/testFormat.js +0 -27
  400. package/tests/describeGregorianAdapter/testLocalization.js +0 -50
  401. package/tests/describeHijriAdapter/describeHijriAdapter.js +0 -21
  402. package/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -1
  403. package/tests/describeHijriAdapter/index.js +0 -1
  404. package/tests/describeHijriAdapter/testCalculations.js +0 -164
  405. package/tests/describeHijriAdapter/testLocalization.js +0 -21
  406. package/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -21
  407. package/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -1
  408. package/tests/describeJalaliAdapter/index.js +0 -1
  409. package/tests/describeJalaliAdapter/testCalculations.js +0 -237
  410. package/tests/describeJalaliAdapter/testLocalization.js +0 -21
  411. package/tests/describePicker/describePicker.js +0 -162
  412. package/tests/describePicker/describePicker.types.js +0 -1
  413. package/tests/describePicker/index.js +0 -1
  414. package/tests/describeValidation/describeValidation.js +0 -31
  415. package/tests/describeValidation/describeValidation.types.js +0 -1
  416. package/tests/describeValidation/index.js +0 -1
  417. package/tests/describeValidation/testDayViewValidation.js +0 -280
  418. package/tests/describeValidation/testMinutesViewValidation.js +0 -193
  419. package/tests/describeValidation/testMonthViewValidation.js +0 -137
  420. package/tests/describeValidation/testTextFieldValidation.js +0 -470
  421. package/tests/describeValidation/testYearViewValidation.js +0 -94
  422. package/tests/describeValue/describeValue.js +0 -59
  423. package/tests/describeValue/describeValue.types.js +0 -1
  424. package/tests/describeValue/index.js +0 -1
  425. package/tests/describeValue/testControlledUnControlled.js +0 -239
  426. package/tests/describeValue/testPickerActionBar.js +0 -254
  427. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -371
  428. package/tests/describeValue/testShortcuts.js +0 -112
@@ -1,711 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testCalculations = void 0;
7
- var _chai = require("chai");
8
- var _pickers = require("test/utils/pickers");
9
- var _describeGregorianAdapter = require("./describeGregorianAdapter.utils");
10
- /**
11
- * To check if the date has the right offset even after changing it's date parts,
12
- * we convert it to a different timezone that always has the same offset,
13
- * then we check that both dates have the same hour value.
14
- */ // We change to
15
- const expectSameTimeInMonacoTZ = (adapter, value) => {
16
- const valueInMonacoTz = adapter.setTimezone(value, 'Europe/Monaco');
17
- (0, _chai.expect)(adapter.getHours(value)).to.equal(adapter.getHours(valueInMonacoTz));
18
- };
19
- const testCalculations = ({
20
- adapter,
21
- adapterTZ,
22
- adapterFr,
23
- setDefaultTimezone,
24
- getLocaleFromDate
25
- }) => {
26
- const testDateIso = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
27
- const testDateLastNonDSTDay = adapterTZ.isTimezoneCompatible ? adapterTZ.dateWithTimezone('2022-03-27', 'Europe/Paris') : adapterTZ.date('2022-03-27');
28
- const testDateLocale = adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING);
29
- describe('Method: date', () => {
30
- it('should parse strings', () => {
31
- (0, _chai.expect)(adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING)).toEqualDateTime(testDateIso);
32
- (0, _chai.expect)(adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING)).toEqualDateTime(testDateLocale);
33
- });
34
- it('should parse native Date object', () => {
35
- (0, _chai.expect)(adapter.date(new Date(_describeGregorianAdapter.TEST_DATE_ISO_STRING))).toEqualDateTime(testDateIso);
36
- (0, _chai.expect)(adapter.date(new Date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING))).toEqualDateTime(testDateLocale);
37
- });
38
- it('should parse already-parsed object', () => {
39
- (0, _chai.expect)(adapter.date(testDateIso)).toEqualDateTime(testDateIso);
40
- (0, _chai.expect)(adapter.date(testDateLocale)).toEqualDateTime(testDateLocale);
41
- });
42
- it('should parse null', () => {
43
- (0, _chai.expect)(adapter.date(null)).to.equal(null);
44
- });
45
- it('should parse undefined', () => {
46
- (0, _chai.expect)(Math.abs(adapter.toJsDate(adapter.date(undefined)).getTime() - Date.now())).to.be.lessThan(5);
47
- });
48
- });
49
- describe('Method: dateWithTimezone', () => {
50
- it('should parse ISO strings', () => {
51
- if (adapter.isTimezoneCompatible) {
52
- const test = (timezone, expectedTimezones = timezone) => {
53
- [adapterTZ, adapterFr].forEach(instance => {
54
- const dateWithZone = instance.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, timezone);
55
- (0, _chai.expect)(instance.getTimezone(dateWithZone)).to.equal(expectedTimezones);
56
-
57
- // Should keep the time of the value in the UTC timezone
58
- (0, _chai.expect)(dateWithZone).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
59
- });
60
- };
61
- test('UTC');
62
- test('system');
63
- test('America/New_York');
64
- test('Europe/Paris');
65
- setDefaultTimezone('America/New_York');
66
- test('default', 'America/New_York');
67
- setDefaultTimezone('Europe/Paris');
68
- test('default', 'Europe/Paris');
69
-
70
- // Reset to the default timezone
71
- setDefaultTimezone(undefined);
72
- } else {
73
- (0, _chai.expect)(adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'system')).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
74
- (0, _chai.expect)(adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'default')).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
75
- }
76
- });
77
- it('should parse locale strings', () => {
78
- if (adapter.isTimezoneCompatible) {
79
- const test = timezone => {
80
- [adapterTZ, adapterFr].forEach(instance => {
81
- const dateWithZone = instance.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING, timezone);
82
- (0, _chai.expect)(instance.getTimezone(dateWithZone)).to.equal(timezone);
83
-
84
- // Should keep the time of the date in the target timezone
85
- (0, _chai.expect)(instance.format(dateWithZone, 'fullTime24h')).to.equal('00:00');
86
- });
87
- };
88
- test('UTC');
89
- test('system');
90
- test('America/New_York');
91
- test('Europe/Paris');
92
- } else {
93
- (0, _chai.expect)(adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING, 'system')).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING);
94
- }
95
- });
96
- it('should parse null', () => {
97
- (0, _chai.expect)(adapter.dateWithTimezone(null, 'system')).to.equal(null);
98
- if (adapter.isTimezoneCompatible) {
99
- (0, _chai.expect)(adapter.dateWithTimezone(null, 'UTC')).to.equal(null);
100
- (0, _chai.expect)(adapter.dateWithTimezone(null, 'America/New_York')).to.equal(null);
101
- }
102
- });
103
- it('should parse undefined', () => {
104
- if (adapter.isTimezoneCompatible) {
105
- const testTodayZone = timezone => {
106
- const dateWithZone = adapterTZ.dateWithTimezone(undefined, timezone);
107
- (0, _chai.expect)(adapterTZ.getTimezone(dateWithZone)).to.equal(timezone);
108
- (0, _chai.expect)(adapterTZ.getDiff(dateWithZone, adapterTZ.date(new Date()))).to.be.lessThan(5);
109
- (0, _chai.expect)(Math.abs(adapterTZ.toJsDate(dateWithZone).getTime() - Date.now())).to.be.lessThan(5);
110
- };
111
- testTodayZone('system');
112
- testTodayZone('UTC');
113
- testTodayZone('America/New_York');
114
- } else {
115
- (0, _chai.expect)(Math.abs(adapterTZ.toJsDate(adapter.dateWithTimezone(undefined, 'system')).getTime() - Date.now())).to.be.lessThan(5);
116
- }
117
- });
118
- });
119
- it('Method: getTimezone', () => {
120
- if (!adapter.isTimezoneCompatible) {
121
- return;
122
- }
123
- const testTimezone = (timezone, expectedTimezone = timezone) => {
124
- (0, _chai.expect)(adapter.getTimezone(adapter.dateWithTimezone(undefined, timezone))).to.equal(expectedTimezone);
125
- };
126
- testTimezone('system');
127
- testTimezone('Europe/Paris');
128
- testTimezone('America/New_York');
129
- testTimezone('UTC');
130
- setDefaultTimezone('America/Chicago');
131
- testTimezone('default', 'America/Chicago');
132
- setDefaultTimezone(undefined);
133
- });
134
- it('Method: setTimezone', () => {
135
- if (adapter.isTimezoneCompatible) {
136
- const test = timezone => {
137
- setDefaultTimezone(timezone);
138
- const dateWithLocaleTimezone = adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'system');
139
- const dateWithDefaultTimezone = adapter.setTimezone(dateWithLocaleTimezone, 'default');
140
- (0, _chai.expect)(adapter.getTimezone(dateWithDefaultTimezone)).to.equal(timezone);
141
- };
142
- test('America/New_York');
143
- test('Europe/Paris');
144
-
145
- // Reset to the default timezone
146
- setDefaultTimezone(undefined);
147
- } else {
148
- const systemDate = adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'system');
149
- (0, _chai.expect)(adapter.setTimezone(systemDate, 'default')).toEqualDateTime(systemDate);
150
- (0, _chai.expect)(adapter.setTimezone(systemDate, 'system')).toEqualDateTime(systemDate);
151
- const defaultDate = adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'default');
152
- (0, _chai.expect)(adapter.setTimezone(systemDate, 'default')).toEqualDateTime(defaultDate);
153
- (0, _chai.expect)(adapter.setTimezone(systemDate, 'system')).toEqualDateTime(defaultDate);
154
- }
155
- });
156
- it('Method: toJsDate', () => {
157
- (0, _chai.expect)(adapter.toJsDate(testDateIso)).to.be.instanceOf(Date);
158
- (0, _chai.expect)(adapter.toJsDate(testDateLocale)).to.be.instanceOf(Date);
159
- });
160
- it('Method: parseISO', () => {
161
- (0, _chai.expect)(adapter.parseISO(_describeGregorianAdapter.TEST_DATE_ISO_STRING)).toEqualDateTime(testDateIso);
162
- });
163
- it('Method: toISO', () => {
164
- const outputtedISO = adapter.toISO(testDateIso);
165
- if (adapter.lib === 'date-fns') {
166
- // date-fns never suppress useless milliseconds in the end
167
- (0, _chai.expect)(outputtedISO).to.equal(_describeGregorianAdapter.TEST_DATE_ISO_STRING.replace('.000Z', 'Z'));
168
- } else {
169
- (0, _chai.expect)(outputtedISO).to.equal(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
170
- }
171
- });
172
- it('Method: parse', () => {
173
- // Date time
174
- (0, _chai.expect)(adapter.parse('10/30/2018 11:44', adapter.formats.keyboardDateTime24h)).toEqualDateTime('2018-10-30T11:44:00.000Z');
175
-
176
- // Date
177
- (0, _chai.expect)(adapter.parse('10/30/2018', adapter.formats.keyboardDate)).toEqualDateTime('2018-10-30T00:00:00.000Z');
178
-
179
- // Empty string
180
- (0, _chai.expect)(adapter.parse('', adapter.formats.keyboardDate)).to.equal(null);
181
-
182
- // Invalid input
183
- (0, _chai.expect)(adapter.isValid(adapter.parse('99/99/9999', adapter.formats.keyboardDate))).to.equal(false);
184
- });
185
- it('Method: isNull', () => {
186
- (0, _chai.expect)(adapter.isNull(null)).to.equal(true);
187
- (0, _chai.expect)(adapter.isNull(testDateIso)).to.equal(false);
188
- (0, _chai.expect)(adapter.isNull(testDateLocale)).to.equal(false);
189
- });
190
- it('Method: isValid', () => {
191
- const invalidDate = adapter.date('2018-42-30T11:60:00.000Z');
192
- (0, _chai.expect)(adapter.isValid(testDateIso)).to.equal(true);
193
- (0, _chai.expect)(adapter.isValid(testDateLocale)).to.equal(true);
194
- (0, _chai.expect)(adapter.isValid(invalidDate)).to.equal(false);
195
- (0, _chai.expect)(adapter.isValid(undefined)).to.equal(true);
196
- (0, _chai.expect)(adapter.isValid(null)).to.equal(false);
197
- (0, _chai.expect)(adapter.isValid('2018-42-30T11:60:00.000Z')).to.equal(false);
198
- });
199
- describe('Method: getDiff', () => {
200
- it('should compute the millisecond diff when there is no unit', () => {
201
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-29T11:44:00.000Z'))).to.equal(86400000);
202
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-31T11:44:00.000Z'))).to.equal(-86400000);
203
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-31T11:44:00.000Z'))).to.equal(-86400000);
204
- });
205
- it('should compute the diff in the provided unit (ISO)', () => {
206
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2017-09-29T11:44:00.000Z'), 'years')).to.equal(1);
207
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-08-29T11:44:00.000Z'), 'months')).to.equal(2);
208
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-05-29T11:44:00.000Z'), 'quarters')).to.equal(1);
209
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'days')).to.equal(31);
210
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'weeks')).to.equal(4);
211
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'hours')).to.equal(744);
212
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'minutes')).to.equal(44640);
213
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-30T10:44:00.000Z'), 'seconds')).to.equal(3600);
214
- (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-30T10:44:00.000Z'), 'milliseconds')).to.equal(3600000);
215
- });
216
- it('should compute the diff in the provided unit (locale)', () => {
217
- (0, _chai.expect)(adapter.getDiff(testDateLocale, adapter.date('2017-09-29'), 'years')).to.equal(1);
218
- (0, _chai.expect)(adapter.getDiff(testDateLocale, adapter.date('2018-08-29'), 'months')).to.equal(2);
219
- (0, _chai.expect)(adapter.getDiff(testDateLocale, adapter.date('2018-05-29'), 'quarters')).to.equal(1);
220
- (0, _chai.expect)(adapter.getDiff(testDateLocale, adapter.date('2018-09-29'), 'days')).to.equal(31);
221
- (0, _chai.expect)(adapter.getDiff(testDateLocale, adapter.date('2018-09-29'), 'weeks')).to.equal(4);
222
- });
223
- it('should compute the diff with string "comparing" param', () => {
224
- (0, _chai.expect)(adapter.getDiff(testDateLocale, '2017-09-29', 'years')).to.equal(1);
225
- (0, _chai.expect)(adapter.getDiff(testDateLocale, '2018-08-29', 'months')).to.equal(2);
226
- (0, _chai.expect)(adapter.getDiff(testDateLocale, '2018-05-29', 'quarters')).to.equal(1);
227
- (0, _chai.expect)(adapter.getDiff(testDateLocale, '2018-09-29', 'days')).to.equal(31);
228
- (0, _chai.expect)(adapter.getDiff(testDateLocale, '2018-09-29', 'weeks')).to.equal(4);
229
- });
230
- });
231
- describe('Method: isEqual', () => {
232
- it('should work in the same timezone', () => {
233
- (0, _chai.expect)(adapter.isEqual(adapter.date(null), null)).to.equal(true);
234
- (0, _chai.expect)(adapter.isEqual(testDateIso, adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING))).to.equal(true);
235
- (0, _chai.expect)(adapter.isEqual(null, testDateIso)).to.equal(false);
236
- (0, _chai.expect)(adapter.isEqual(testDateLocale, adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING))).to.equal(true);
237
- (0, _chai.expect)(adapter.isEqual(null, testDateLocale)).to.equal(false);
238
- });
239
- it('should work with different timezones', function test() {
240
- if (!adapter.isTimezoneCompatible) {
241
- this.skip();
242
- }
243
- const dateInLondonTZ = adapterTZ.setTimezone(testDateIso, 'Europe/London');
244
- const dateInParisTZ = adapterTZ.setTimezone(testDateIso, 'Europe/Paris');
245
- (0, _chai.expect)(adapterTZ.isEqual(dateInLondonTZ, dateInParisTZ)).to.equal(true);
246
- });
247
- });
248
- describe('Method: isSameYear', () => {
249
- it('should work in the same timezone', () => {
250
- (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
251
- (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
252
- (0, _chai.expect)(adapter.isSameYear(testDateLocale, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
253
- (0, _chai.expect)(adapter.isSameYear(testDateLocale, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
254
- });
255
- it('should work with different timezones', function test() {
256
- if (!adapter.isTimezoneCompatible) {
257
- this.skip();
258
- }
259
-
260
- // Both dates below have the same timestamp, but they are not in the same year when represented in their respective timezone.
261
- // The adapter should still consider that they are in the same year.
262
- const dateInLondonTZ = adapterTZ.endOfYear(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
263
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
264
- (0, _chai.expect)(adapterTZ.isSameYear(dateInLondonTZ, dateInParisTZ)).to.equal(true);
265
- (0, _chai.expect)(adapterTZ.isSameYear(dateInParisTZ, dateInLondonTZ)).to.equal(true);
266
- });
267
- });
268
- describe('Method: isSameMonth', () => {
269
- it('should work in the same timezone', () => {
270
- (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
271
- (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
272
- (0, _chai.expect)(adapter.isSameMonth(testDateLocale, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
273
- (0, _chai.expect)(adapter.isSameMonth(testDateLocale, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
274
- });
275
- it('should work with different timezones', function test() {
276
- if (!adapter.isTimezoneCompatible) {
277
- this.skip();
278
- }
279
-
280
- // Both dates below have the same timestamp, but they are not in the same month when represented in their respective timezone.
281
- // The adapter should still consider that they are in the same month.
282
- const dateInLondonTZ = adapterTZ.endOfMonth(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
283
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
284
- (0, _chai.expect)(adapterTZ.isSameMonth(dateInLondonTZ, dateInParisTZ)).to.equal(true);
285
- (0, _chai.expect)(adapterTZ.isSameMonth(dateInParisTZ, dateInLondonTZ)).to.equal(true);
286
- });
287
- });
288
- describe('Method: isSameDay', () => {
289
- it('should work in the same timezone', () => {
290
- (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
291
- (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
292
- (0, _chai.expect)(adapter.isSameDay(testDateLocale, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
293
- (0, _chai.expect)(adapter.isSameDay(testDateLocale, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
294
- });
295
- it('should work with different timezones', function test() {
296
- if (!adapter.isTimezoneCompatible) {
297
- this.skip();
298
- }
299
-
300
- // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
301
- // The adapter should still consider that they are in the same day.
302
- const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
303
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
304
- (0, _chai.expect)(adapterTZ.isSameDay(dateInLondonTZ, dateInParisTZ)).to.equal(true);
305
- (0, _chai.expect)(adapterTZ.isSameDay(dateInParisTZ, dateInLondonTZ)).to.equal(true);
306
- });
307
- });
308
- describe('Method: isSameHour', () => {
309
- it('should work in the same timezone', () => {
310
- (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T11:00:00.000Z'))).to.equal(true);
311
- (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T12:00:00.000Z'))).to.equal(false);
312
- });
313
- it('should work with different timezones', function test() {
314
- if (!adapter.isTimezoneCompatible) {
315
- this.skip();
316
- }
317
-
318
- // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
319
- // The adapter should still consider that they are in the same day.
320
- const dateInLondonTZ = adapterTZ.setTimezone(testDateIso, 'Europe/London');
321
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
322
- (0, _chai.expect)(adapterTZ.isSameHour(dateInLondonTZ, dateInParisTZ)).to.equal(true);
323
- (0, _chai.expect)(adapterTZ.isSameHour(dateInParisTZ, dateInLondonTZ)).to.equal(true);
324
- });
325
- });
326
- describe('Method: isAfter', () => {
327
- it('should work with the same timezone', () => {
328
- (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
329
- (0, _chai.expect)(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
330
- (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateLocale)).to.equal(true);
331
- (0, _chai.expect)(adapter.isAfter(testDateLocale, adapter.date())).to.equal(false);
332
- });
333
- it('should work with different timezones', function test() {
334
- if (!adapter.isTimezoneCompatible) {
335
- this.skip();
336
- }
337
- const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
338
- const dateInParisTZ = adapterTZ.addMinutes(adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/Paris')), 30);
339
- (0, _chai.expect)(adapter.isAfter(dateInLondonTZ, dateInParisTZ)).to.equal(true);
340
- (0, _chai.expect)(adapter.isAfter(dateInParisTZ, dateInLondonTZ)).to.equal(false);
341
- });
342
- });
343
- describe('Method: isAfterYear', () => {
344
- it('should work in the same timezone', () => {
345
- const nextYearIso = adapter.addYears(testDateIso, 1);
346
- (0, _chai.expect)(adapter.isAfterYear(nextYearIso, testDateIso)).to.equal(true);
347
- (0, _chai.expect)(adapter.isAfterYear(testDateIso, nextYearIso)).to.equal(false);
348
- const nextYearLocale = adapter.addYears(testDateLocale, 1);
349
- (0, _chai.expect)(adapter.isAfterYear(nextYearLocale, testDateLocale)).to.equal(true);
350
- (0, _chai.expect)(adapter.isAfterYear(testDateLocale, nextYearLocale)).to.equal(false);
351
- });
352
- it('should work with different timezones', function test() {
353
- if (!adapter.isTimezoneCompatible) {
354
- this.skip();
355
- }
356
-
357
- // Both dates below have the same timestamp, but they are not in the same year when represented in their respective timezone.
358
- // The adapter should still consider that they are in the same year.
359
- const dateInLondonTZ = adapterTZ.endOfYear(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
360
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
361
- (0, _chai.expect)(adapterTZ.isAfterYear(dateInLondonTZ, dateInParisTZ)).to.equal(false);
362
- (0, _chai.expect)(adapterTZ.isAfterYear(dateInParisTZ, dateInLondonTZ)).to.equal(false);
363
- });
364
- });
365
- describe('Method: isAfterDay', () => {
366
- it('should work with the same timezone', () => {
367
- const nextDayIso = adapter.addDays(testDateIso, 1);
368
- (0, _chai.expect)(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
369
- (0, _chai.expect)(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
370
- const nextDayLocale = adapter.addDays(testDateLocale, 1);
371
- (0, _chai.expect)(adapter.isAfterDay(nextDayLocale, testDateLocale)).to.equal(true);
372
- (0, _chai.expect)(adapter.isAfterDay(testDateLocale, nextDayLocale)).to.equal(false);
373
- });
374
- it('should work with different timezones', function test() {
375
- if (!adapter.isTimezoneCompatible) {
376
- this.skip();
377
- }
378
-
379
- // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
380
- // The adapter should still consider that they are in the same day.
381
- const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
382
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
383
- (0, _chai.expect)(adapterTZ.isAfterDay(dateInLondonTZ, dateInParisTZ)).to.equal(false);
384
- (0, _chai.expect)(adapterTZ.isAfterDay(dateInParisTZ, dateInLondonTZ)).to.equal(false);
385
-
386
- // Both dates below have the same day when represented in their respective timezone,
387
- // But not when represented in the same timezone
388
- // The adapter should consider that they are not in the same day
389
- const dateInLondonTZ2 = adapterTZ.startOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
390
- const dateInParisTZ2 = adapterTZ.addHours(adapterTZ.setTimezone(dateInLondonTZ2, 'Europe/Paris'), -1);
391
- (0, _chai.expect)(adapterTZ.isAfterDay(dateInLondonTZ2, dateInParisTZ2)).to.equal(true);
392
- (0, _chai.expect)(adapterTZ.isAfterDay(dateInParisTZ2, dateInLondonTZ2)).to.equal(false);
393
- });
394
- });
395
- describe('Method: isBefore', () => {
396
- it('should work with the same timezone', () => {
397
- (0, _chai.expect)(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
398
- (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
399
- (0, _chai.expect)(adapter.isBefore(testDateLocale, adapter.date())).to.equal(true);
400
- (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateLocale)).to.equal(false);
401
- });
402
- it('should work with different timezones', function test() {
403
- if (!adapter.isTimezoneCompatible) {
404
- this.skip();
405
- }
406
- const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
407
- const dateInParisTZ = adapterTZ.addMinutes(adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/Paris')), 30);
408
- (0, _chai.expect)(adapter.isBefore(dateInLondonTZ, dateInParisTZ)).to.equal(false);
409
- (0, _chai.expect)(adapter.isBefore(dateInParisTZ, dateInLondonTZ)).to.equal(true);
410
- });
411
- });
412
- describe('Method: isBeforeYear', () => {
413
- it('should work in the same timezone', () => {
414
- const nextYearIso = adapter.addYears(testDateIso, -1);
415
- (0, _chai.expect)(adapter.isBeforeYear(nextYearIso, testDateIso)).to.equal(true);
416
- (0, _chai.expect)(adapter.isBeforeYear(testDateIso, nextYearIso)).to.equal(false);
417
- const nextYearLocale = adapter.addYears(testDateLocale, -1);
418
- (0, _chai.expect)(adapter.isBeforeYear(nextYearLocale, testDateLocale)).to.equal(true);
419
- (0, _chai.expect)(adapter.isBeforeYear(testDateLocale, nextYearLocale)).to.equal(false);
420
- });
421
- it('should work with different timezones', function test() {
422
- if (!adapter.isTimezoneCompatible) {
423
- this.skip();
424
- }
425
-
426
- // Both dates below have the same timestamp, but they are not in the same year when represented in their respective timezone.
427
- // The adapter should still consider that they are in the same year.
428
- const dateInLondonTZ = adapterTZ.endOfYear(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
429
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
430
- (0, _chai.expect)(adapterTZ.isBeforeYear(dateInLondonTZ, dateInParisTZ)).to.equal(false);
431
- (0, _chai.expect)(adapterTZ.isBeforeYear(dateInParisTZ, dateInLondonTZ)).to.equal(false);
432
- });
433
- });
434
- describe('Method: isBeforeDay', () => {
435
- it('should work with the same timezone', () => {
436
- const previousDayIso = adapter.addDays(testDateIso, -1);
437
- (0, _chai.expect)(adapter.isBeforeDay(previousDayIso, testDateIso)).to.equal(true);
438
- (0, _chai.expect)(adapter.isBeforeDay(testDateIso, previousDayIso)).to.equal(false);
439
- const previousDayLocale = adapter.addDays(testDateLocale, -1);
440
- (0, _chai.expect)(adapter.isBeforeDay(previousDayLocale, testDateLocale)).to.equal(true);
441
- (0, _chai.expect)(adapter.isBeforeDay(testDateLocale, previousDayLocale)).to.equal(false);
442
- });
443
- it('should work with different timezones', function test() {
444
- if (!adapter.isTimezoneCompatible) {
445
- this.skip();
446
- }
447
-
448
- // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
449
- // The adapter should still consider that they are in the same day.
450
- const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
451
- const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
452
- (0, _chai.expect)(adapterTZ.isBeforeDay(dateInLondonTZ, dateInParisTZ)).to.equal(false);
453
- (0, _chai.expect)(adapterTZ.isBeforeDay(dateInParisTZ, dateInLondonTZ)).to.equal(false);
454
-
455
- // Both dates below have the same day when represented in their respective timezone,
456
- // But not when represented in the same timezone
457
- // The adapter should consider that they are not in the same day
458
- const dateInLondonTZ2 = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
459
- const dateInParisTZ2 = adapterTZ.addHours(adapterTZ.setTimezone(dateInLondonTZ2, 'Europe/Paris'), -1);
460
- (0, _chai.expect)(adapterTZ.isBeforeDay(dateInLondonTZ2, dateInParisTZ2)).to.equal(false);
461
- (0, _chai.expect)(adapterTZ.isBeforeDay(dateInParisTZ2, dateInLondonTZ2)).to.equal(true);
462
- });
463
- });
464
- describe('Method: isWithinRange', () => {
465
- it('should work on simple examples', () => {
466
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-10-01T00:00:00.000Z'), [adapter.date('2019-09-01T00:00:00.000Z'), adapter.date('2019-11-01T00:00:00.000Z')])).to.equal(true);
467
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-12-01T00:00:00.000Z'), [adapter.date('2019-09-01T00:00:00.000Z'), adapter.date('2019-11-01T00:00:00.000Z')])).to.equal(false);
468
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-10-01'), [adapter.date('2019-09-01'), adapter.date('2019-11-01')])).to.equal(true);
469
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-12-01'), [adapter.date('2019-09-01'), adapter.date('2019-11-01')])).to.equal(false);
470
- });
471
- it('should use inclusivity of range', () => {
472
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-09-01T00:00:00.000Z'), [adapter.date('2019-09-01T00:00:00.000Z'), adapter.date('2019-12-01T00:00:00.000Z')])).to.equal(true);
473
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-12-01T00:00:00.000Z'), [adapter.date('2019-09-01T00:00:00.000Z'), adapter.date('2019-12-01T00:00:00.000Z')])).to.equal(true);
474
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-09-01'), [adapter.date('2019-09-01'), adapter.date('2019-12-01')])).to.equal(true);
475
- (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-12-01'), [adapter.date('2019-09-01'), adapter.date('2019-12-01')])).to.equal(true);
476
- });
477
- });
478
- it('Method: startOfYear', () => {
479
- const expected = '2018-01-01T00:00:00.000Z';
480
- (0, _chai.expect)(adapter.startOfYear(testDateIso)).toEqualDateTime(expected);
481
- (0, _chai.expect)(adapter.startOfYear(testDateLocale)).toEqualDateTime(expected);
482
- });
483
- it('Method: startOfMonth', () => {
484
- const expected = '2018-10-01T00:00:00.000Z';
485
- (0, _chai.expect)(adapter.startOfMonth(testDateIso)).toEqualDateTime(expected);
486
- (0, _chai.expect)(adapter.startOfMonth(testDateLocale)).toEqualDateTime(expected);
487
- });
488
- it('Method: startOfWeek', () => {
489
- const expected = adapter.lib === 'luxon' ? '2018-10-29T00:00:00.000Z' : '2018-10-28T00:00:00.000Z';
490
- (0, _chai.expect)(adapter.startOfWeek(testDateIso)).toEqualDateTime(expected);
491
- (0, _chai.expect)(adapter.startOfWeek(testDateLocale)).toEqualDateTime(expected);
492
- });
493
- it('Method: startOfDay', () => {
494
- const expected = '2018-10-30T00:00:00.000Z';
495
- (0, _chai.expect)(adapter.startOfDay(testDateIso)).toEqualDateTime(expected);
496
- (0, _chai.expect)(adapter.startOfDay(testDateLocale)).toEqualDateTime(expected);
497
- });
498
- it('Method: endOfYear', () => {
499
- const expected = '2018-12-31T23:59:59.999Z';
500
- (0, _chai.expect)(adapter.endOfYear(testDateIso)).toEqualDateTime(expected);
501
- (0, _chai.expect)(adapter.endOfYear(testDateLocale)).toEqualDateTime(expected);
502
- });
503
- describe('Method: endOfMonth', () => {
504
- it('should handle basic usecases', () => {
505
- const expected = '2018-10-31T23:59:59.999Z';
506
- (0, _chai.expect)(adapter.endOfMonth(testDateIso)).toEqualDateTime(expected);
507
- (0, _chai.expect)(adapter.endOfMonth(testDateLocale)).toEqualDateTime(expected);
508
- });
509
- it('should update the offset when entering DST', function test() {
510
- if (!adapterTZ.isTimezoneCompatible) {
511
- this.skip();
512
- }
513
- expectSameTimeInMonacoTZ(adapterTZ, testDateLastNonDSTDay);
514
- expectSameTimeInMonacoTZ(adapterTZ, adapterTZ.endOfMonth(testDateLastNonDSTDay));
515
- });
516
- });
517
- it('Method: endOfWeek', () => {
518
- const expected = adapter.lib === 'luxon' ? '2018-11-04T23:59:59.999Z' : '2018-11-03T23:59:59.999Z';
519
- (0, _chai.expect)(adapter.endOfWeek(testDateIso)).toEqualDateTime(expected);
520
- (0, _chai.expect)(adapter.endOfWeek(testDateLocale)).toEqualDateTime(expected);
521
- });
522
- it('Method: endOfDay', () => {
523
- const expected = '2018-10-30T23:59:59.999Z';
524
- (0, _chai.expect)(adapter.endOfDay(testDateIso)).toEqualDateTime(expected);
525
- (0, _chai.expect)(adapter.endOfDay(testDateLocale)).toEqualDateTime(expected);
526
- });
527
- it('Method: addYears', () => {
528
- (0, _chai.expect)(adapter.addYears(testDateIso, 2)).toEqualDateTime('2020-10-30T11:44:00.000Z');
529
- (0, _chai.expect)(adapter.addYears(testDateIso, -2)).toEqualDateTime('2016-10-30T11:44:00.000Z');
530
- });
531
- describe('Method: addMonths', () => {
532
- it('should handle basic usecases', () => {
533
- (0, _chai.expect)(adapter.addMonths(testDateIso, 2)).toEqualDateTime('2018-12-30T11:44:00.000Z');
534
- (0, _chai.expect)(adapter.addMonths(testDateIso, -2)).toEqualDateTime('2018-08-30T11:44:00.000Z');
535
- (0, _chai.expect)(adapter.addMonths(testDateIso, 3)).toEqualDateTime('2019-01-30T11:44:00.000Z');
536
- });
537
- it('should update the offset when entering DST', function test() {
538
- if (!adapterTZ.isTimezoneCompatible) {
539
- this.skip();
540
- }
541
- expectSameTimeInMonacoTZ(adapterTZ, testDateLastNonDSTDay);
542
- expectSameTimeInMonacoTZ(adapterTZ, adapterTZ.addMonths(testDateLastNonDSTDay, 1));
543
- });
544
- });
545
- describe('Method: addWeeks', () => {
546
- it('should handle basic usecases', () => {
547
- (0, _chai.expect)(adapter.addWeeks(testDateIso, 2)).toEqualDateTime('2018-11-13T11:44:00.000Z');
548
- (0, _chai.expect)(adapter.addWeeks(testDateIso, -2)).toEqualDateTime('2018-10-16T11:44:00.000Z');
549
- });
550
- it('should update the offset when entering DST', function test() {
551
- if (!adapterTZ.isTimezoneCompatible) {
552
- this.skip();
553
- }
554
- expectSameTimeInMonacoTZ(adapterTZ, testDateLastNonDSTDay);
555
- expectSameTimeInMonacoTZ(adapterTZ, adapterTZ.addWeeks(testDateLastNonDSTDay, 1));
556
- });
557
- });
558
- describe('Method: addWeeks', () => {
559
- it('should handle basic usecases', () => {
560
- (0, _chai.expect)(adapter.addDays(testDateIso, 2)).toEqualDateTime('2018-11-01T11:44:00.000Z');
561
- (0, _chai.expect)(adapter.addDays(testDateIso, -2)).toEqualDateTime('2018-10-28T11:44:00.000Z');
562
- });
563
- it('should update the offset when entering DST', function test() {
564
- if (!adapterTZ.isTimezoneCompatible) {
565
- this.skip();
566
- }
567
- expectSameTimeInMonacoTZ(adapterTZ, testDateLastNonDSTDay);
568
- expectSameTimeInMonacoTZ(adapterTZ, adapterTZ.addDays(testDateLastNonDSTDay, 1));
569
- });
570
- });
571
- it('Method: addHours', () => {
572
- (0, _chai.expect)(adapter.addHours(testDateIso, 2)).toEqualDateTime('2018-10-30T13:44:00.000Z');
573
- (0, _chai.expect)(adapter.addHours(testDateIso, -2)).toEqualDateTime('2018-10-30T09:44:00.000Z');
574
- (0, _chai.expect)(adapter.addHours(testDateIso, 15)).toEqualDateTime('2018-10-31T02:44:00.000Z');
575
- });
576
- it('Method: addMinutes', () => {
577
- (0, _chai.expect)(adapter.addMinutes(testDateIso, 2)).toEqualDateTime('2018-10-30T11:46:00.000Z');
578
- (0, _chai.expect)(adapter.addMinutes(testDateIso, -2)).toEqualDateTime('2018-10-30T11:42:00.000Z');
579
- (0, _chai.expect)(adapter.addMinutes(testDateIso, 20)).toEqualDateTime('2018-10-30T12:04:00.000Z');
580
- });
581
- it('Method: addSeconds', () => {
582
- (0, _chai.expect)(adapter.addSeconds(testDateIso, 2)).toEqualDateTime('2018-10-30T11:44:02.000Z');
583
- (0, _chai.expect)(adapter.addSeconds(testDateIso, -2)).toEqualDateTime('2018-10-30T11:43:58.000Z');
584
- (0, _chai.expect)(adapter.addSeconds(testDateIso, 70)).toEqualDateTime('2018-10-30T11:45:10.000Z');
585
- });
586
- it('Method: getYear', () => {
587
- (0, _chai.expect)(adapter.getYear(testDateIso)).to.equal(2018);
588
- });
589
- it('Method: getMonth', () => {
590
- (0, _chai.expect)(adapter.getMonth(testDateIso)).to.equal(9);
591
- });
592
- it('Method: getDate', () => {
593
- (0, _chai.expect)(adapter.getDate(testDateIso)).to.equal(30);
594
- });
595
- it('Method: getHours', () => {
596
- (0, _chai.expect)(adapter.getHours(testDateIso)).to.equal(11);
597
- });
598
- it('Method: getMinutes', () => {
599
- (0, _chai.expect)(adapter.getMinutes(testDateIso)).to.equal(44);
600
- });
601
- it('Method: getSeconds', () => {
602
- (0, _chai.expect)(adapter.getSeconds(testDateIso)).to.equal(0);
603
- });
604
- it('Method: getMilliseconds', () => {
605
- (0, _chai.expect)(adapter.getMilliseconds(testDateIso)).to.equal(0);
606
- });
607
- it('Method: setYear', () => {
608
- (0, _chai.expect)(adapter.setYear(testDateIso, 2011)).toEqualDateTime('2011-10-30T11:44:00.000Z');
609
- });
610
- it('Method: setMonth', () => {
611
- (0, _chai.expect)(adapter.setMonth(testDateIso, 4)).toEqualDateTime('2018-05-30T11:44:00.000Z');
612
- });
613
- it('Method: setDate', () => {
614
- (0, _chai.expect)(adapter.setDate(testDateIso, 15)).toEqualDateTime('2018-10-15T11:44:00.000Z');
615
- });
616
- it('Method: setHours', () => {
617
- (0, _chai.expect)(adapter.setHours(testDateIso, 0)).toEqualDateTime('2018-10-30T00:44:00.000Z');
618
- });
619
- it('Method: setMinutes', () => {
620
- (0, _chai.expect)(adapter.setMinutes(testDateIso, 12)).toEqualDateTime('2018-10-30T11:12:00.000Z');
621
- });
622
- it('Method: setSeconds', () => {
623
- (0, _chai.expect)(adapter.setSeconds(testDateIso, 11)).toEqualDateTime('2018-10-30T11:44:11.000Z');
624
- });
625
- it('Method: setMilliseconds', () => {
626
- (0, _chai.expect)(adapter.setMilliseconds(testDateIso, 11)).toEqualDateTime('2018-10-30T11:44:00.011Z');
627
- });
628
- it('Method: getDaysInMonth', () => {
629
- (0, _chai.expect)(adapter.getDaysInMonth(testDateIso)).to.equal(31);
630
- (0, _chai.expect)(adapter.getDaysInMonth(testDateLocale)).to.equal(31);
631
- (0, _chai.expect)(adapter.getDaysInMonth(adapter.addMonths(testDateIso, 1))).to.equal(30);
632
- });
633
- it('Method: getNextMonth', () => {
634
- (0, _chai.expect)(adapter.getNextMonth(testDateIso)).toEqualDateTime('2018-11-30T11:44:00.000Z');
635
- });
636
- it('Method: getPreviousMonth', () => {
637
- (0, _chai.expect)(adapter.getPreviousMonth(testDateIso)).toEqualDateTime('2018-09-30T11:44:00.000Z');
638
- });
639
- it('Method: getMonthArray', () => {
640
- const monthArray = adapter.getMonthArray(testDateIso);
641
- let expectedDate = adapter.date('2018-01-01T00:00:00.000Z');
642
- monthArray.forEach(month => {
643
- (0, _chai.expect)(month).toEqualDateTime(expectedDate);
644
- expectedDate = adapter.addMonths(expectedDate, 1);
645
- });
646
- });
647
- it('Method: mergeDateAndTime', () => {
648
- const mergedDate = adapter.mergeDateAndTime(testDateIso, adapter.date('2018-01-01T14:15:16.000Z'));
649
- (0, _chai.expect)(adapter.toJsDate(mergedDate)).toEqualDateTime('2018-10-30T14:15:16.000Z');
650
- });
651
- it('Method: getWeekdays', () => {
652
- const weekDays = adapter.getWeekdays();
653
- let date = adapter.startOfWeek(testDateIso);
654
- weekDays.forEach(dayLabel => {
655
- (0, _chai.expect)(adapter.format(date, 'weekday').startsWith(dayLabel)).to.equal(true);
656
- date = adapter.addDays(date, 1);
657
- });
658
- });
659
- describe('Method: getWeekArray', () => {
660
- it('should work without timezones', () => {
661
- const weekArray = adapter.getWeekArray(testDateIso);
662
- let expectedDate = adapter.startOfWeek(adapter.startOfMonth(testDateIso));
663
- (0, _chai.expect)(weekArray).to.have.length(5);
664
- weekArray.forEach(week => {
665
- (0, _chai.expect)(week).to.have.length(7);
666
- week.forEach(day => {
667
- (0, _chai.expect)(day).toEqualDateTime(expectedDate);
668
- expectedDate = adapter.addDays(expectedDate, 1);
669
- });
670
- });
671
- });
672
- it('should respect the DST', function test() {
673
- if (!adapterTZ.isTimezoneCompatible) {
674
- this.skip();
675
- }
676
- const referenceDate = adapterTZ.dateWithTimezone('2022-03-17', 'Europe/Paris');
677
- const weekArray = adapterTZ.getWeekArray(referenceDate);
678
- let expectedDate = adapter.startOfWeek(adapter.startOfMonth(referenceDate));
679
- (0, _chai.expect)(weekArray).to.have.length(5);
680
- weekArray.forEach(week => {
681
- (0, _chai.expect)(week).to.have.length(7);
682
- week.forEach(day => {
683
- (0, _chai.expect)(adapterTZ.startOfDay(day)).toEqualDateTime(adapterTZ.startOfDay(expectedDate));
684
- expectedDate = adapterTZ.addDays(expectedDate, 1);
685
- (0, _chai.expect)((0, _pickers.getDateOffset)(adapterTZ, day)).to.equal(adapterTZ.isAfter(day, testDateLastNonDSTDay) ? 120 : 60);
686
- });
687
- });
688
- });
689
- it('should respect the locale of the adapter, not the locale of the date', function test() {
690
- const dateFr = adapterFr.dateWithTimezone('2022-03-17', 'default');
691
- const weekArray = adapter.getWeekArray(dateFr);
692
- if (getLocaleFromDate) {
693
- (0, _chai.expect)(getLocaleFromDate(weekArray[0][0])).to.match(/en/);
694
- }
695
-
696
- // Week should start on Monday (28th of March) for adapters supporting locale-based week start.
697
- (0, _chai.expect)(adapter.getDate(weekArray[0][0])).to.equal(adapter.lib === 'luxon' ? 28 : 27);
698
- });
699
- });
700
- it('Method: getWeekNumber', () => {
701
- (0, _chai.expect)(adapter.getWeekNumber(testDateIso)).to.equal(44);
702
- });
703
- it('Method: getYearRange', () => {
704
- const yearRange = adapter.getYearRange(testDateIso, adapter.setYear(testDateIso, 2124));
705
- (0, _chai.expect)(yearRange).to.have.length(107);
706
- (0, _chai.expect)(adapter.getYear(yearRange[yearRange.length - 1])).to.equal(2124);
707
- const emptyYearRange = adapter.getYearRange(testDateIso, adapter.setYear(testDateIso, adapter.getYear(testDateIso) - 1));
708
- (0, _chai.expect)(emptyYearRange).to.have.length(0);
709
- });
710
- };
711
- exports.testCalculations = testCalculations;