@mui/x-date-pickers 6.4.0 → 6.6.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 (329) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +6 -0
  2. package/AdapterDateFns/AdapterDateFns.js +18 -0
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +6 -0
  4. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
  5. package/AdapterDayjs/AdapterDayjs.d.ts +14 -1
  6. package/AdapterDayjs/AdapterDayjs.js +131 -14
  7. package/AdapterLuxon/AdapterLuxon.d.ts +7 -1
  8. package/AdapterLuxon/AdapterLuxon.js +58 -9
  9. package/AdapterMoment/AdapterMoment.d.ts +12 -1
  10. package/AdapterMoment/AdapterMoment.js +91 -2
  11. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +4 -0
  12. package/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
  13. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +4 -0
  14. package/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
  15. package/CHANGELOG.md +134 -2
  16. package/DateCalendar/DateCalendar.js +2 -2
  17. package/DateCalendar/DayCalendar.d.ts +1 -1
  18. package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
  19. package/DateCalendar/PickersCalendarHeader.js +2 -2
  20. package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
  21. package/DateCalendar/PickersSlideTransition.d.ts +1 -1
  22. package/DateField/DateField.js +6 -0
  23. package/DateField/DateField.types.d.ts +2 -2
  24. package/DateField/index.d.ts +1 -1
  25. package/DateField/useDateField.d.ts +1 -1
  26. package/DateField/useDateField.js +9 -46
  27. package/DateTimeField/DateTimeField.js +6 -0
  28. package/DateTimeField/DateTimeField.types.d.ts +2 -2
  29. package/DateTimeField/index.d.ts +1 -1
  30. package/DateTimeField/useDateTimeField.d.ts +1 -1
  31. package/DateTimeField/useDateTimeField.js +9 -60
  32. package/DateTimePicker/DateTimePicker.js +19 -2
  33. package/DateTimePicker/DateTimePicker.types.d.ts +4 -3
  34. package/DateTimePicker/DateTimePickerTabs.d.ts +3 -3
  35. package/DateTimePicker/DateTimePickerTabs.js +6 -5
  36. package/DateTimePicker/DateTimePickerToolbar.d.ts +5 -4
  37. package/DateTimePicker/DateTimePickerToolbar.js +46 -22
  38. package/DateTimePicker/shared.d.ts +6 -6
  39. package/DayCalendarSkeleton/DayCalendarSkeleton.d.ts +1 -1
  40. package/DesktopDatePicker/DesktopDatePicker.js +2 -2
  41. package/DesktopDateTimePicker/DesktopDateTimePicker.js +54 -12
  42. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +10 -3
  43. package/DesktopTimePicker/DesktopTimePicker.js +3 -4
  44. package/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  45. package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +8 -7
  46. package/MobileTimePicker/MobileTimePicker.js +1 -2
  47. package/MonthCalendar/MonthCalendar.js +2 -2
  48. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
  49. package/PickersActionBar/PickersActionBar.d.ts +2 -2
  50. package/PickersLayout/PickersLayout.d.ts +1 -1
  51. package/PickersShortcuts/PickersShortcuts.d.ts +2 -2
  52. package/README.md +5 -5
  53. package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -1
  54. package/TimeClock/Clock.d.ts +1 -1
  55. package/TimeClock/ClockNumber.d.ts +1 -1
  56. package/TimeClock/ClockNumbers.d.ts +2 -2
  57. package/TimeClock/ClockPointer.d.ts +1 -1
  58. package/TimeField/TimeField.js +6 -0
  59. package/TimeField/TimeField.types.d.ts +1 -1
  60. package/TimeField/index.d.ts +1 -1
  61. package/TimeField/useTimeField.d.ts +1 -1
  62. package/TimeField/useTimeField.js +9 -50
  63. package/TimePicker/TimePickerToolbar.d.ts +2 -2
  64. package/YearCalendar/YearCalendar.js +2 -2
  65. package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +13 -0
  66. package/dateTimeViewRenderers/dateTimeViewRenderers.js +148 -0
  67. package/dateTimeViewRenderers/index.d.ts +2 -0
  68. package/dateTimeViewRenderers/index.js +1 -0
  69. package/dateTimeViewRenderers/package.json +6 -0
  70. package/dateViewRenderers/dateViewRenderers.d.ts +3 -2
  71. package/dateViewRenderers/dateViewRenderers.js +2 -2
  72. package/icons/index.d.ts +42 -0
  73. package/{internals/components/icons → icons}/index.js +7 -7
  74. package/icons/package.json +6 -0
  75. package/index.d.ts +1 -0
  76. package/index.js +3 -2
  77. package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.d.ts +2 -0
  78. package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
  79. package/internals/components/DateTimeViewWrapper/index.d.ts +1 -0
  80. package/internals/components/DateTimeViewWrapper/index.js +1 -0
  81. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  82. package/internals/components/PickersModalDialog.d.ts +1 -1
  83. package/internals/components/PickersPopper.d.ts +1 -1
  84. package/internals/components/PickersToolbarButton.d.ts +1 -0
  85. package/internals/components/PickersToolbarButton.js +8 -3
  86. package/internals/constants/dimensions.d.ts +1 -0
  87. package/internals/constants/dimensions.js +2 -1
  88. package/internals/demo/DemoContainer.d.ts +2 -2
  89. package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
  90. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
  91. package/internals/hooks/useField/useField.d.ts +1 -1
  92. package/internals/hooks/useField/useField.js +18 -5
  93. package/internals/hooks/useField/useField.types.d.ts +8 -2
  94. package/internals/hooks/useField/useFieldState.d.ts +1 -1
  95. package/internals/hooks/useField/useFieldState.js +22 -2
  96. package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
  97. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
  98. package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -2
  99. package/internals/hooks/usePicker/usePickerViews.js +8 -10
  100. package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +2 -2
  101. package/internals/hooks/useViews.js +12 -9
  102. package/internals/index.d.ts +4 -2
  103. package/internals/index.js +4 -2
  104. package/internals/models/fields.d.ts +1 -1
  105. package/internals/utils/date-utils.d.ts +4 -1
  106. package/internals/utils/date-utils.js +4 -1
  107. package/internals/utils/fields.d.ts +5 -0
  108. package/internals/utils/fields.js +28 -0
  109. package/internals/utils/getDefaultReferenceDate.d.ts +15 -0
  110. package/internals/utils/getDefaultReferenceDate.js +62 -0
  111. package/internals/utils/time-utils.d.ts +2 -1
  112. package/internals/utils/time-utils.js +1 -0
  113. package/internals/utils/validation/extractValidationProps.d.ts +5 -1
  114. package/internals/utils/validation/extractValidationProps.js +4 -1
  115. package/internals/utils/valueManagers.js +21 -3
  116. package/legacy/AdapterDateFns/AdapterDateFns.js +18 -0
  117. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
  118. package/legacy/AdapterDayjs/AdapterDayjs.js +135 -14
  119. package/legacy/AdapterLuxon/AdapterLuxon.js +58 -9
  120. package/legacy/AdapterMoment/AdapterMoment.js +97 -6
  121. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
  122. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
  123. package/legacy/DateCalendar/DateCalendar.js +2 -2
  124. package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
  125. package/legacy/DateField/DateField.js +6 -0
  126. package/legacy/DateField/useDateField.js +8 -44
  127. package/legacy/DateTimeField/DateTimeField.js +6 -0
  128. package/legacy/DateTimeField/useDateTimeField.js +8 -60
  129. package/legacy/DateTimePicker/DateTimePicker.js +19 -2
  130. package/legacy/DateTimePicker/DateTimePickerTabs.js +6 -5
  131. package/legacy/DateTimePicker/DateTimePickerToolbar.js +51 -23
  132. package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -2
  133. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +55 -12
  134. package/legacy/DesktopTimePicker/DesktopTimePicker.js +3 -4
  135. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  136. package/legacy/MobileTimePicker/MobileTimePicker.js +1 -2
  137. package/legacy/MonthCalendar/MonthCalendar.js +2 -2
  138. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
  139. package/legacy/TimeField/TimeField.js +6 -0
  140. package/legacy/TimeField/useTimeField.js +8 -48
  141. package/legacy/YearCalendar/YearCalendar.js +2 -2
  142. package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
  143. package/legacy/dateTimeViewRenderers/index.js +1 -0
  144. package/legacy/dateViewRenderers/dateViewRenderers.js +2 -4
  145. package/legacy/{internals/components/icons → icons}/index.js +7 -7
  146. package/legacy/index.js +3 -2
  147. package/legacy/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
  148. package/legacy/internals/components/DateTimeViewWrapper/index.js +1 -0
  149. package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  150. package/legacy/internals/components/PickersToolbarButton.js +7 -2
  151. package/legacy/internals/constants/dimensions.js +2 -1
  152. package/legacy/internals/hooks/useField/useField.js +20 -7
  153. package/legacy/internals/hooks/useField/useFieldState.js +22 -2
  154. package/legacy/internals/hooks/usePicker/usePickerViews.js +4 -4
  155. package/legacy/internals/hooks/useViews.js +12 -9
  156. package/legacy/internals/index.js +4 -2
  157. package/legacy/internals/utils/date-utils.js +7 -0
  158. package/legacy/internals/utils/fields.js +28 -0
  159. package/legacy/internals/utils/getDefaultReferenceDate.js +64 -0
  160. package/legacy/internals/utils/time-utils.js +3 -0
  161. package/legacy/internals/utils/validation/extractValidationProps.js +4 -1
  162. package/legacy/internals/utils/valueManagers.js +20 -4
  163. package/legacy/locales/index.js +1 -0
  164. package/legacy/locales/viVN.js +93 -0
  165. package/legacy/models/index.js +1 -0
  166. package/legacy/models/timezone.js +1 -0
  167. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +16 -1
  168. package/legacy/tests/describeGregorianAdapter/testCalculations.js +350 -80
  169. package/legacy/tests/describeGregorianAdapter/testLocalization.js +3 -3
  170. package/legacy/tests/describeValidation/testDayViewValidation.js +129 -52
  171. package/legacy/tests/describeValidation/testMinutesViewValidation.js +3 -10
  172. package/legacy/tests/describeValidation/testMonthViewValidation.js +3 -10
  173. package/legacy/tests/describeValidation/testYearViewValidation.js +3 -10
  174. package/legacy/tests/describeValue/describeValue.js +38 -4
  175. package/legacy/tests/describeValue/testControlledUnControlled.js +44 -23
  176. package/legacy/tests/describeValue/testPickerActionBar.js +51 -45
  177. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +102 -78
  178. package/legacy/timeViewRenderers/timeViewRenderers.js +1 -1
  179. package/locales/index.d.ts +1 -0
  180. package/locales/index.js +1 -0
  181. package/locales/viVN.d.ts +53 -0
  182. package/locales/viVN.js +57 -0
  183. package/models/adapters.d.ts +50 -9
  184. package/models/fields.d.ts +1 -1
  185. package/models/index.d.ts +1 -0
  186. package/models/index.js +1 -0
  187. package/models/timezone.d.ts +1 -0
  188. package/models/timezone.js +1 -0
  189. package/modern/AdapterDateFns/AdapterDateFns.js +18 -0
  190. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
  191. package/modern/AdapterDayjs/AdapterDayjs.js +130 -14
  192. package/modern/AdapterLuxon/AdapterLuxon.js +57 -9
  193. package/modern/AdapterMoment/AdapterMoment.js +90 -2
  194. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
  195. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
  196. package/modern/DateCalendar/DateCalendar.js +2 -2
  197. package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
  198. package/modern/DateField/DateField.js +6 -0
  199. package/modern/DateField/useDateField.js +9 -46
  200. package/modern/DateTimeField/DateTimeField.js +6 -0
  201. package/modern/DateTimeField/useDateTimeField.js +9 -60
  202. package/modern/DateTimePicker/DateTimePicker.js +19 -2
  203. package/modern/DateTimePicker/DateTimePickerTabs.js +6 -5
  204. package/modern/DateTimePicker/DateTimePickerToolbar.js +46 -22
  205. package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -2
  206. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +53 -11
  207. package/modern/DesktopTimePicker/DesktopTimePicker.js +3 -4
  208. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  209. package/modern/MobileTimePicker/MobileTimePicker.js +1 -2
  210. package/modern/MonthCalendar/MonthCalendar.js +2 -2
  211. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
  212. package/modern/TimeField/TimeField.js +6 -0
  213. package/modern/TimeField/useTimeField.js +9 -50
  214. package/modern/YearCalendar/YearCalendar.js +2 -2
  215. package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
  216. package/modern/dateTimeViewRenderers/index.js +1 -0
  217. package/modern/dateViewRenderers/dateViewRenderers.js +2 -2
  218. package/modern/{internals/components/icons → icons}/index.js +7 -7
  219. package/modern/index.js +3 -2
  220. package/modern/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
  221. package/modern/internals/components/DateTimeViewWrapper/index.js +1 -0
  222. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  223. package/modern/internals/components/PickersToolbarButton.js +8 -3
  224. package/modern/internals/constants/dimensions.js +2 -1
  225. package/modern/internals/hooks/useField/useField.js +18 -5
  226. package/modern/internals/hooks/useField/useFieldState.js +22 -2
  227. package/modern/internals/hooks/usePicker/usePickerViews.js +8 -10
  228. package/modern/internals/hooks/useViews.js +12 -9
  229. package/modern/internals/index.js +4 -2
  230. package/modern/internals/utils/date-utils.js +4 -1
  231. package/modern/internals/utils/fields.js +28 -0
  232. package/modern/internals/utils/getDefaultReferenceDate.js +58 -0
  233. package/modern/internals/utils/time-utils.js +1 -0
  234. package/modern/internals/utils/validation/extractValidationProps.js +4 -1
  235. package/modern/internals/utils/valueManagers.js +21 -3
  236. package/modern/locales/index.js +1 -0
  237. package/modern/locales/viVN.js +57 -0
  238. package/modern/models/index.js +1 -0
  239. package/modern/models/timezone.js +1 -0
  240. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
  241. package/modern/tests/describeGregorianAdapter/testCalculations.js +348 -80
  242. package/modern/tests/describeGregorianAdapter/testLocalization.js +3 -3
  243. package/modern/tests/describeValidation/testDayViewValidation.js +129 -52
  244. package/modern/tests/describeValidation/testMinutesViewValidation.js +3 -10
  245. package/modern/tests/describeValidation/testMonthViewValidation.js +3 -10
  246. package/modern/tests/describeValidation/testYearViewValidation.js +3 -10
  247. package/modern/tests/describeValue/describeValue.js +39 -4
  248. package/modern/tests/describeValue/testControlledUnControlled.js +35 -16
  249. package/modern/tests/describeValue/testPickerActionBar.js +38 -29
  250. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +89 -58
  251. package/modern/timeViewRenderers/timeViewRenderers.js +1 -1
  252. package/node/AdapterDateFns/AdapterDateFns.js +18 -0
  253. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
  254. package/node/AdapterDayjs/AdapterDayjs.js +130 -14
  255. package/node/AdapterLuxon/AdapterLuxon.js +57 -9
  256. package/node/AdapterMoment/AdapterMoment.js +90 -2
  257. package/node/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
  258. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
  259. package/node/DateCalendar/DateCalendar.js +2 -2
  260. package/node/DateCalendar/PickersCalendarHeader.js +2 -2
  261. package/node/DateField/DateField.js +6 -0
  262. package/node/DateField/useDateField.js +9 -46
  263. package/node/DateTimeField/DateTimeField.js +6 -0
  264. package/node/DateTimeField/useDateTimeField.js +9 -60
  265. package/node/DateTimePicker/DateTimePicker.js +19 -2
  266. package/node/DateTimePicker/DateTimePickerTabs.js +6 -5
  267. package/node/DateTimePicker/DateTimePickerToolbar.js +46 -22
  268. package/node/DesktopDatePicker/DesktopDatePicker.js +2 -2
  269. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +53 -11
  270. package/node/DesktopTimePicker/DesktopTimePicker.js +3 -4
  271. package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  272. package/node/MobileTimePicker/MobileTimePicker.js +1 -2
  273. package/node/MonthCalendar/MonthCalendar.js +2 -2
  274. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -2
  275. package/node/TimeField/TimeField.js +6 -0
  276. package/node/TimeField/useTimeField.js +9 -50
  277. package/node/YearCalendar/YearCalendar.js +2 -2
  278. package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +156 -0
  279. package/node/dateTimeViewRenderers/index.js +12 -0
  280. package/node/dateViewRenderers/dateViewRenderers.js +3 -3
  281. package/node/{internals/components/icons → icons}/index.js +15 -15
  282. package/node/index.js +13 -1
  283. package/node/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +12 -0
  284. package/node/internals/components/DateTimeViewWrapper/index.js +12 -0
  285. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  286. package/node/internals/components/PickersToolbarButton.js +8 -3
  287. package/node/internals/constants/dimensions.js +4 -2
  288. package/node/internals/hooks/useField/useField.js +18 -5
  289. package/node/internals/hooks/useField/useFieldState.js +22 -2
  290. package/node/internals/hooks/usePicker/usePickerViews.js +8 -10
  291. package/node/internals/hooks/useViews.js +12 -9
  292. package/node/internals/index.js +26 -0
  293. package/node/internals/utils/date-utils.js +7 -2
  294. package/node/internals/utils/fields.js +36 -0
  295. package/node/internals/utils/getDefaultReferenceDate.js +66 -0
  296. package/node/internals/utils/time-utils.js +3 -1
  297. package/node/internals/utils/validation/extractValidationProps.js +8 -2
  298. package/node/internals/utils/valueManagers.js +21 -2
  299. package/node/locales/index.js +11 -0
  300. package/node/locales/viVN.js +64 -0
  301. package/node/models/index.js +11 -0
  302. package/node/models/timezone.js +5 -0
  303. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
  304. package/node/tests/describeGregorianAdapter/testCalculations.js +348 -80
  305. package/node/tests/describeGregorianAdapter/testLocalization.js +3 -4
  306. package/node/tests/describeValidation/testDayViewValidation.js +129 -52
  307. package/node/tests/describeValidation/testMinutesViewValidation.js +3 -10
  308. package/node/tests/describeValidation/testMonthViewValidation.js +3 -10
  309. package/node/tests/describeValidation/testYearViewValidation.js +3 -10
  310. package/node/tests/describeValue/describeValue.js +39 -4
  311. package/node/tests/describeValue/testControlledUnControlled.js +35 -16
  312. package/node/tests/describeValue/testPickerActionBar.js +38 -28
  313. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +88 -57
  314. package/node/timeViewRenderers/timeViewRenderers.js +1 -1
  315. package/package.json +5 -5
  316. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +14 -1
  317. package/tests/describeGregorianAdapter/testCalculations.js +348 -80
  318. package/tests/describeGregorianAdapter/testLocalization.js +3 -3
  319. package/tests/describeValidation/testDayViewValidation.js +129 -52
  320. package/tests/describeValidation/testMinutesViewValidation.js +3 -10
  321. package/tests/describeValidation/testMonthViewValidation.js +3 -10
  322. package/tests/describeValidation/testYearViewValidation.js +3 -10
  323. package/tests/describeValue/describeValue.js +39 -4
  324. package/tests/describeValue/testControlledUnControlled.js +35 -16
  325. package/tests/describeValue/testPickerActionBar.js +38 -29
  326. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +89 -58
  327. package/timeViewRenderers/timeViewRenderers.d.ts +4 -4
  328. package/timeViewRenderers/timeViewRenderers.js +1 -1
  329. package/internals/components/icons/index.d.ts +0 -42
@@ -7,28 +7,136 @@ exports.testCalculations = void 0;
7
7
  var _chai = require("chai");
8
8
  var _describeGregorianAdapter = require("./describeGregorianAdapter.utils");
9
9
  const testCalculations = ({
10
- adapter
10
+ adapter,
11
+ adapterTZ,
12
+ adapterFr,
13
+ setDefaultTimezone
11
14
  }) => {
12
15
  const testDateIso = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
13
16
  const testDateLocale = adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING);
14
17
  describe('Method: date', () => {
15
18
  it('should parse strings', () => {
16
- (0, _chai.expect)(adapter.isEqual(testDateIso, adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING))).to.equal(true);
17
- (0, _chai.expect)(adapter.isEqual(testDateLocale, adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING))).to.equal(true);
19
+ (0, _chai.expect)(adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING)).toEqualDateTime(testDateIso);
20
+ (0, _chai.expect)(adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING)).toEqualDateTime(testDateLocale);
18
21
  });
19
22
  it('should parse native Date object', () => {
20
- (0, _chai.expect)(adapter.isEqual(testDateIso, adapter.date(new Date(_describeGregorianAdapter.TEST_DATE_ISO_STRING)))).to.equal(true);
21
- (0, _chai.expect)(adapter.isEqual(testDateLocale, adapter.date(new Date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING)))).to.equal(true);
23
+ (0, _chai.expect)(adapter.date(new Date(_describeGregorianAdapter.TEST_DATE_ISO_STRING))).toEqualDateTime(testDateIso);
24
+ (0, _chai.expect)(adapter.date(new Date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING))).toEqualDateTime(testDateLocale);
22
25
  });
23
26
  it('should parse already-parsed object', () => {
24
- (0, _chai.expect)(adapter.isEqual(testDateIso, adapter.date(adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING)))).to.equal(true);
25
- (0, _chai.expect)(adapter.isEqual(testDateLocale, adapter.date(adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING)))).to.equal(true);
27
+ (0, _chai.expect)(adapter.date(testDateIso)).toEqualDateTime(testDateIso);
28
+ (0, _chai.expect)(adapter.date(testDateLocale)).toEqualDateTime(testDateLocale);
26
29
  });
27
30
  it('should parse null', () => {
28
31
  (0, _chai.expect)(adapter.date(null)).to.equal(null);
29
32
  });
30
33
  it('should parse undefined', () => {
31
- (0, _chai.expect)(adapter.date(undefined)).toEqualDateTime(new Date());
34
+ (0, _chai.expect)(Math.abs(adapter.toJsDate(adapter.date(undefined)).getTime() - Date.now())).to.be.lessThan(5);
35
+ });
36
+ });
37
+ describe('Method: dateWithTimezone', () => {
38
+ it('should parse ISO strings', () => {
39
+ if (adapter.isTimezoneCompatible) {
40
+ const test = (timezone, expectedTimezones = timezone) => {
41
+ [adapterTZ, adapterFr].forEach(instance => {
42
+ const dateWithZone = instance.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, timezone);
43
+ (0, _chai.expect)(instance.getTimezone(dateWithZone)).to.equal(expectedTimezones);
44
+
45
+ // Should keep the time of the value in the UTC timezone
46
+ (0, _chai.expect)(dateWithZone).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
47
+ });
48
+ };
49
+ test('UTC');
50
+ test('system');
51
+ test('America/New_York');
52
+ test('Europe/Paris');
53
+ setDefaultTimezone('America/New_York');
54
+ test('default', 'America/New_York');
55
+ setDefaultTimezone('Europe/Paris');
56
+ test('default', 'Europe/Paris');
57
+
58
+ // Reset to the default timezone
59
+ setDefaultTimezone(undefined);
60
+ } else {
61
+ (0, _chai.expect)(adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'system')).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
62
+ (0, _chai.expect)(adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_ISO_STRING, 'default')).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
63
+ }
64
+ });
65
+ it('should parse locale strings', () => {
66
+ if (adapter.isTimezoneCompatible) {
67
+ const test = timezone => {
68
+ [adapterTZ, adapterFr].forEach(instance => {
69
+ const dateWithZone = instance.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING, timezone);
70
+ (0, _chai.expect)(instance.getTimezone(dateWithZone)).to.equal(timezone);
71
+
72
+ // Should keep the time of the date in the target timezone
73
+ (0, _chai.expect)(instance.format(dateWithZone, 'fullTime24h')).to.equal('00:00');
74
+ });
75
+ };
76
+ test('UTC');
77
+ test('system');
78
+ test('America/New_York');
79
+ test('Europe/Paris');
80
+ } else {
81
+ (0, _chai.expect)(adapter.dateWithTimezone(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING, 'system')).toEqualDateTime(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING);
82
+ }
83
+ });
84
+ it('should parse null', () => {
85
+ (0, _chai.expect)(adapter.dateWithTimezone(null, 'system')).to.equal(null);
86
+ if (adapter.isTimezoneCompatible) {
87
+ (0, _chai.expect)(adapter.dateWithTimezone(null, 'UTC')).to.equal(null);
88
+ (0, _chai.expect)(adapter.dateWithTimezone(null, 'America/New_York')).to.equal(null);
89
+ }
90
+ });
91
+ it('should parse undefined', () => {
92
+ if (adapter.isTimezoneCompatible) {
93
+ const testTodayZone = timezone => {
94
+ const dateWithZone = adapterTZ.dateWithTimezone(undefined, timezone);
95
+ (0, _chai.expect)(adapterTZ.getTimezone(dateWithZone)).to.equal(timezone);
96
+ (0, _chai.expect)(adapterTZ.getDiff(dateWithZone, adapterTZ.date(new Date()))).to.be.lessThan(5);
97
+ (0, _chai.expect)(Math.abs(adapterTZ.toJsDate(dateWithZone).getTime() - Date.now())).to.be.lessThan(5);
98
+ };
99
+ testTodayZone('system');
100
+ testTodayZone('UTC');
101
+ testTodayZone('America/New_York');
102
+ } else {
103
+ (0, _chai.expect)(Math.abs(adapterTZ.toJsDate(adapter.dateWithTimezone(undefined, 'system')).getTime() - Date.now())).to.be.lessThan(5);
104
+ }
105
+ });
106
+ });
107
+ it('Method: getTimezone', () => {
108
+ if (!adapter.isTimezoneCompatible) {
109
+ return;
110
+ }
111
+ const testTimezone = (timezone, expectedTimezone = timezone) => {
112
+ (0, _chai.expect)(adapter.getTimezone(adapter.dateWithTimezone(undefined, timezone))).to.equal(expectedTimezone);
113
+ };
114
+ testTimezone('system');
115
+ testTimezone('Europe/Paris');
116
+ testTimezone('America/New_York');
117
+ testTimezone('UTC');
118
+ setDefaultTimezone('America/Chicago');
119
+ testTimezone('default', 'America/Chicago');
120
+ setDefaultTimezone(undefined);
121
+ });
122
+ describe('Method: setTimezone', () => {
123
+ it('should support "default"', () => {
124
+ if (adapter.isTimezoneCompatible) {
125
+ const test = timezone => {
126
+ setDefaultTimezone(timezone);
127
+ const dateWithLocaleTimezone = adapter.dateWithTimezone(undefined, 'system');
128
+ const dateWithDefaultTimezone = adapter.setTimezone(dateWithLocaleTimezone, 'default');
129
+ (0, _chai.expect)(adapter.getTimezone(dateWithDefaultTimezone)).to.equal(timezone);
130
+ };
131
+ test('America/New_York');
132
+ test('Europe/Paris');
133
+
134
+ // Reset to the default timezone
135
+ setDefaultTimezone(undefined);
136
+ } else {
137
+ const localeDate = adapter.dateWithTimezone(undefined, 'system');
138
+ (0, _chai.expect)(adapter.setTimezone(localeDate, 'default')).to.equal(localeDate);
139
+ }
32
140
  });
33
141
  });
34
142
  it('Method: toJsDate', () => {
@@ -109,78 +217,238 @@ const testCalculations = ({
109
217
  (0, _chai.expect)(adapter.getDiff(testDateLocale, '2018-09-29', 'weeks')).to.equal(4);
110
218
  });
111
219
  });
112
- it('Method: isEqual', () => {
113
- (0, _chai.expect)(adapter.isEqual(adapter.date(null), null)).to.equal(true);
114
- (0, _chai.expect)(adapter.isEqual(testDateIso, adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING))).to.equal(true);
115
- (0, _chai.expect)(adapter.isEqual(null, testDateIso)).to.equal(false);
116
- (0, _chai.expect)(adapter.isEqual(testDateLocale, adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING))).to.equal(true);
117
- (0, _chai.expect)(adapter.isEqual(null, testDateLocale)).to.equal(false);
118
- });
119
- it('Method: isSameYear', () => {
120
- (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
121
- (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
122
- (0, _chai.expect)(adapter.isSameYear(testDateLocale, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
123
- (0, _chai.expect)(adapter.isSameYear(testDateLocale, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
124
- });
125
- it('Method: isSameMonth', () => {
126
- (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
127
- (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
128
- (0, _chai.expect)(adapter.isSameMonth(testDateLocale, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
129
- (0, _chai.expect)(adapter.isSameMonth(testDateLocale, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
130
- });
131
- it('Method: isSameDay', () => {
132
- (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
133
- (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
134
- (0, _chai.expect)(adapter.isSameDay(testDateLocale, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
135
- (0, _chai.expect)(adapter.isSameDay(testDateLocale, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
136
- });
137
- it('Method: isSameHour', () => {
138
- (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T11:00:00.000Z'))).to.equal(true);
139
- (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T12:00:00.000Z'))).to.equal(false);
140
- });
141
- it('Method: isAfter', () => {
142
- (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
143
- (0, _chai.expect)(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
144
- (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateLocale)).to.equal(true);
145
- (0, _chai.expect)(adapter.isAfter(testDateLocale, adapter.date())).to.equal(false);
146
- });
147
- it('Method: isAfterYear', () => {
148
- const nextYearIso = adapter.addYears(testDateIso, 1);
149
- (0, _chai.expect)(adapter.isAfterYear(nextYearIso, testDateIso)).to.equal(true);
150
- (0, _chai.expect)(adapter.isAfterYear(testDateIso, nextYearIso)).to.equal(false);
151
- const nextYearLocale = adapter.addYears(testDateLocale, 1);
152
- (0, _chai.expect)(adapter.isAfterYear(nextYearLocale, testDateLocale)).to.equal(true);
153
- (0, _chai.expect)(adapter.isAfterYear(testDateLocale, nextYearLocale)).to.equal(false);
154
- });
155
- it('Method: isAfterDay', () => {
156
- const nextDayIso = adapter.addDays(testDateIso, 1);
157
- (0, _chai.expect)(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
158
- (0, _chai.expect)(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
159
- const nextDayLocale = adapter.addDays(testDateLocale, 1);
160
- (0, _chai.expect)(adapter.isAfterDay(nextDayLocale, testDateLocale)).to.equal(true);
161
- (0, _chai.expect)(adapter.isAfterDay(testDateLocale, nextDayLocale)).to.equal(false);
162
- });
163
- it('Method: isBefore', () => {
164
- (0, _chai.expect)(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
165
- (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
166
- (0, _chai.expect)(adapter.isBefore(testDateLocale, adapter.date())).to.equal(true);
167
- (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateLocale)).to.equal(false);
168
- });
169
- it('Method: isBeforeYear', () => {
170
- const nextYearIso = adapter.addYears(testDateIso, -1);
171
- (0, _chai.expect)(adapter.isBeforeYear(nextYearIso, testDateIso)).to.equal(true);
172
- (0, _chai.expect)(adapter.isBeforeYear(testDateIso, nextYearIso)).to.equal(false);
173
- const nextYearLocale = adapter.addYears(testDateLocale, -1);
174
- (0, _chai.expect)(adapter.isBeforeYear(nextYearLocale, testDateLocale)).to.equal(true);
175
- (0, _chai.expect)(adapter.isBeforeYear(testDateLocale, nextYearLocale)).to.equal(false);
176
- });
177
- it('Method: isBeforeDay', () => {
178
- const nextDayIso = adapter.addDays(testDateIso, -1);
179
- (0, _chai.expect)(adapter.isBeforeDay(nextDayIso, testDateIso)).to.equal(true);
180
- (0, _chai.expect)(adapter.isBeforeDay(testDateIso, nextDayIso)).to.equal(false);
181
- const nextDayLocale = adapter.addDays(testDateLocale, -1);
182
- (0, _chai.expect)(adapter.isBeforeDay(nextDayLocale, testDateLocale)).to.equal(true);
183
- (0, _chai.expect)(adapter.isBeforeDay(testDateLocale, nextDayLocale)).to.equal(false);
220
+ describe('Method: isEqual', () => {
221
+ it('should work in the same timezone', () => {
222
+ (0, _chai.expect)(adapter.isEqual(adapter.date(null), null)).to.equal(true);
223
+ (0, _chai.expect)(adapter.isEqual(testDateIso, adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING))).to.equal(true);
224
+ (0, _chai.expect)(adapter.isEqual(null, testDateIso)).to.equal(false);
225
+ (0, _chai.expect)(adapter.isEqual(testDateLocale, adapter.date(_describeGregorianAdapter.TEST_DATE_LOCALE_STRING))).to.equal(true);
226
+ (0, _chai.expect)(adapter.isEqual(null, testDateLocale)).to.equal(false);
227
+ });
228
+ it('should work with different timezones', function test() {
229
+ if (!adapter.isTimezoneCompatible) {
230
+ this.skip();
231
+ }
232
+ const dateInLondonTZ = adapterTZ.setTimezone(testDateIso, 'Europe/London');
233
+ const dateInParisTZ = adapterTZ.setTimezone(testDateIso, 'Europe/Paris');
234
+ (0, _chai.expect)(adapterTZ.isEqual(dateInLondonTZ, dateInParisTZ)).to.equal(true);
235
+ });
236
+ });
237
+ describe('Method: isSameYear', () => {
238
+ it('should work in the same timezone', () => {
239
+ (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
240
+ (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
241
+ (0, _chai.expect)(adapter.isSameYear(testDateLocale, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
242
+ (0, _chai.expect)(adapter.isSameYear(testDateLocale, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
243
+ });
244
+ it('should work with different timezones', function test() {
245
+ if (!adapter.isTimezoneCompatible) {
246
+ this.skip();
247
+ }
248
+
249
+ // Both dates below have the same timestamp, but they are not in the same year when represented in their respective timezone.
250
+ // The adapter should still consider that they are in the same year.
251
+ const dateInLondonTZ = adapterTZ.endOfYear(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
252
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
253
+ (0, _chai.expect)(adapterTZ.isSameYear(dateInLondonTZ, dateInParisTZ)).to.equal(true);
254
+ (0, _chai.expect)(adapterTZ.isSameYear(dateInParisTZ, dateInLondonTZ)).to.equal(true);
255
+ });
256
+ });
257
+ describe('Method: isSameMonth', () => {
258
+ it('should work in the same timezone', () => {
259
+ (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
260
+ (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
261
+ (0, _chai.expect)(adapter.isSameMonth(testDateLocale, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
262
+ (0, _chai.expect)(adapter.isSameMonth(testDateLocale, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
263
+ });
264
+ it('should work with different timezones', function test() {
265
+ if (!adapter.isTimezoneCompatible) {
266
+ this.skip();
267
+ }
268
+
269
+ // Both dates below have the same timestamp, but they are not in the same month when represented in their respective timezone.
270
+ // The adapter should still consider that they are in the same month.
271
+ const dateInLondonTZ = adapterTZ.endOfMonth(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
272
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
273
+ (0, _chai.expect)(adapterTZ.isSameMonth(dateInLondonTZ, dateInParisTZ)).to.equal(true);
274
+ (0, _chai.expect)(adapterTZ.isSameMonth(dateInParisTZ, dateInLondonTZ)).to.equal(true);
275
+ });
276
+ });
277
+ describe('Method: isSameDay', () => {
278
+ it('should work in the same timezone', () => {
279
+ (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
280
+ (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
281
+ (0, _chai.expect)(adapter.isSameDay(testDateLocale, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
282
+ (0, _chai.expect)(adapter.isSameDay(testDateLocale, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
283
+ });
284
+ it('should work with different timezones', function test() {
285
+ if (!adapter.isTimezoneCompatible) {
286
+ this.skip();
287
+ }
288
+
289
+ // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
290
+ // The adapter should still consider that they are in the same day.
291
+ const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
292
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
293
+ (0, _chai.expect)(adapterTZ.isSameDay(dateInLondonTZ, dateInParisTZ)).to.equal(true);
294
+ (0, _chai.expect)(adapterTZ.isSameDay(dateInParisTZ, dateInLondonTZ)).to.equal(true);
295
+ });
296
+ });
297
+ describe('Method: isSameHour', () => {
298
+ it('should work in the same timezone', () => {
299
+ (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T11:00:00.000Z'))).to.equal(true);
300
+ (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T12:00:00.000Z'))).to.equal(false);
301
+ });
302
+ it('should work with different timezones', function test() {
303
+ if (!adapter.isTimezoneCompatible) {
304
+ this.skip();
305
+ }
306
+
307
+ // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
308
+ // The adapter should still consider that they are in the same day.
309
+ const dateInLondonTZ = adapterTZ.setTimezone(testDateIso, 'Europe/London');
310
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
311
+ (0, _chai.expect)(adapterTZ.isSameHour(dateInLondonTZ, dateInParisTZ)).to.equal(true);
312
+ (0, _chai.expect)(adapterTZ.isSameHour(dateInParisTZ, dateInLondonTZ)).to.equal(true);
313
+ });
314
+ });
315
+ describe('Method: isAfter', () => {
316
+ it('should work with the same timezone', () => {
317
+ (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
318
+ (0, _chai.expect)(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
319
+ (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateLocale)).to.equal(true);
320
+ (0, _chai.expect)(adapter.isAfter(testDateLocale, adapter.date())).to.equal(false);
321
+ });
322
+ it('should work with different timezones', function test() {
323
+ if (!adapter.isTimezoneCompatible) {
324
+ this.skip();
325
+ }
326
+ const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
327
+ const dateInParisTZ = adapterTZ.addMinutes(adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/Paris')), 30);
328
+ (0, _chai.expect)(adapter.isAfter(dateInLondonTZ, dateInParisTZ)).to.equal(true);
329
+ (0, _chai.expect)(adapter.isAfter(dateInParisTZ, dateInLondonTZ)).to.equal(false);
330
+ });
331
+ });
332
+ describe('Method: isAfterYear', () => {
333
+ it('should work in the same timezone', () => {
334
+ const nextYearIso = adapter.addYears(testDateIso, 1);
335
+ (0, _chai.expect)(adapter.isAfterYear(nextYearIso, testDateIso)).to.equal(true);
336
+ (0, _chai.expect)(adapter.isAfterYear(testDateIso, nextYearIso)).to.equal(false);
337
+ const nextYearLocale = adapter.addYears(testDateLocale, 1);
338
+ (0, _chai.expect)(adapter.isAfterYear(nextYearLocale, testDateLocale)).to.equal(true);
339
+ (0, _chai.expect)(adapter.isAfterYear(testDateLocale, nextYearLocale)).to.equal(false);
340
+ });
341
+ it('should work with different timezones', function test() {
342
+ if (!adapter.isTimezoneCompatible) {
343
+ this.skip();
344
+ }
345
+
346
+ // Both dates below have the same timestamp, but they are not in the same year when represented in their respective timezone.
347
+ // The adapter should still consider that they are in the same year.
348
+ const dateInLondonTZ = adapterTZ.endOfYear(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
349
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
350
+ (0, _chai.expect)(adapterTZ.isAfterYear(dateInLondonTZ, dateInParisTZ)).to.equal(false);
351
+ (0, _chai.expect)(adapterTZ.isAfterYear(dateInParisTZ, dateInLondonTZ)).to.equal(false);
352
+ });
353
+ });
354
+ describe('Method: isAfterDay', () => {
355
+ it('should work with the same timezone', () => {
356
+ const nextDayIso = adapter.addDays(testDateIso, 1);
357
+ (0, _chai.expect)(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
358
+ (0, _chai.expect)(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
359
+ const nextDayLocale = adapter.addDays(testDateLocale, 1);
360
+ (0, _chai.expect)(adapter.isAfterDay(nextDayLocale, testDateLocale)).to.equal(true);
361
+ (0, _chai.expect)(adapter.isAfterDay(testDateLocale, nextDayLocale)).to.equal(false);
362
+ });
363
+ it('should work with different timezones', function test() {
364
+ if (!adapter.isTimezoneCompatible) {
365
+ this.skip();
366
+ }
367
+
368
+ // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
369
+ // The adapter should still consider that they are in the same day.
370
+ const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
371
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
372
+ (0, _chai.expect)(adapterTZ.isAfterDay(dateInLondonTZ, dateInParisTZ)).to.equal(false);
373
+ (0, _chai.expect)(adapterTZ.isAfterDay(dateInParisTZ, dateInLondonTZ)).to.equal(false);
374
+
375
+ // Both dates below have the same day when represented in their respective timezone,
376
+ // But not when represented in the same timezone
377
+ // The adapter should consider that they are not in the same day
378
+ const dateInLondonTZ2 = adapterTZ.startOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
379
+ const dateInParisTZ2 = adapterTZ.addHours(adapterTZ.setTimezone(dateInLondonTZ2, 'Europe/Paris'), -1);
380
+ (0, _chai.expect)(adapterTZ.isAfterDay(dateInLondonTZ2, dateInParisTZ2)).to.equal(true);
381
+ (0, _chai.expect)(adapterTZ.isAfterDay(dateInParisTZ2, dateInLondonTZ2)).to.equal(false);
382
+ });
383
+ });
384
+ describe('Method: isBefore', () => {
385
+ it('should work with the same timezone', () => {
386
+ (0, _chai.expect)(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
387
+ (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
388
+ (0, _chai.expect)(adapter.isBefore(testDateLocale, adapter.date())).to.equal(true);
389
+ (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateLocale)).to.equal(false);
390
+ });
391
+ it('should work with different timezones', function test() {
392
+ if (!adapter.isTimezoneCompatible) {
393
+ this.skip();
394
+ }
395
+ const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
396
+ const dateInParisTZ = adapterTZ.addMinutes(adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/Paris')), 30);
397
+ (0, _chai.expect)(adapter.isBefore(dateInLondonTZ, dateInParisTZ)).to.equal(false);
398
+ (0, _chai.expect)(adapter.isBefore(dateInParisTZ, dateInLondonTZ)).to.equal(true);
399
+ });
400
+ });
401
+ describe('Method: isBeforeYear', () => {
402
+ it('should work in the same timezone', () => {
403
+ const nextYearIso = adapter.addYears(testDateIso, -1);
404
+ (0, _chai.expect)(adapter.isBeforeYear(nextYearIso, testDateIso)).to.equal(true);
405
+ (0, _chai.expect)(adapter.isBeforeYear(testDateIso, nextYearIso)).to.equal(false);
406
+ const nextYearLocale = adapter.addYears(testDateLocale, -1);
407
+ (0, _chai.expect)(adapter.isBeforeYear(nextYearLocale, testDateLocale)).to.equal(true);
408
+ (0, _chai.expect)(adapter.isBeforeYear(testDateLocale, nextYearLocale)).to.equal(false);
409
+ });
410
+ it('should work with different timezones', function test() {
411
+ if (!adapter.isTimezoneCompatible) {
412
+ this.skip();
413
+ }
414
+
415
+ // Both dates below have the same timestamp, but they are not in the same year when represented in their respective timezone.
416
+ // The adapter should still consider that they are in the same year.
417
+ const dateInLondonTZ = adapterTZ.endOfYear(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
418
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
419
+ (0, _chai.expect)(adapterTZ.isBeforeYear(dateInLondonTZ, dateInParisTZ)).to.equal(false);
420
+ (0, _chai.expect)(adapterTZ.isBeforeYear(dateInParisTZ, dateInLondonTZ)).to.equal(false);
421
+ });
422
+ });
423
+ describe('Method: isBeforeDay', () => {
424
+ it('should work with the same timezone', () => {
425
+ const previousDayIso = adapter.addDays(testDateIso, -1);
426
+ (0, _chai.expect)(adapter.isBeforeDay(previousDayIso, testDateIso)).to.equal(true);
427
+ (0, _chai.expect)(adapter.isBeforeDay(testDateIso, previousDayIso)).to.equal(false);
428
+ const previousDayLocale = adapter.addDays(testDateLocale, -1);
429
+ (0, _chai.expect)(adapter.isBeforeDay(previousDayLocale, testDateLocale)).to.equal(true);
430
+ (0, _chai.expect)(adapter.isBeforeDay(testDateLocale, previousDayLocale)).to.equal(false);
431
+ });
432
+ it('should work with different timezones', function test() {
433
+ if (!adapter.isTimezoneCompatible) {
434
+ this.skip();
435
+ }
436
+
437
+ // Both dates below have the same timestamp, but they are not in the same day when represented in their respective timezone.
438
+ // The adapter should still consider that they are in the same day.
439
+ const dateInLondonTZ = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
440
+ const dateInParisTZ = adapterTZ.setTimezone(dateInLondonTZ, 'Europe/Paris');
441
+ (0, _chai.expect)(adapterTZ.isBeforeDay(dateInLondonTZ, dateInParisTZ)).to.equal(false);
442
+ (0, _chai.expect)(adapterTZ.isBeforeDay(dateInParisTZ, dateInLondonTZ)).to.equal(false);
443
+
444
+ // Both dates below have the same day when represented in their respective timezone,
445
+ // But not when represented in the same timezone
446
+ // The adapter should consider that they are not in the same day
447
+ const dateInLondonTZ2 = adapterTZ.endOfDay(adapterTZ.setTimezone(testDateIso, 'Europe/London'));
448
+ const dateInParisTZ2 = adapterTZ.addHours(adapterTZ.setTimezone(dateInLondonTZ2, 'Europe/Paris'), -1);
449
+ (0, _chai.expect)(adapterTZ.isBeforeDay(dateInLondonTZ2, dateInParisTZ2)).to.equal(false);
450
+ (0, _chai.expect)(adapterTZ.isBeforeDay(dateInParisTZ2, dateInLondonTZ2)).to.equal(true);
451
+ });
184
452
  });
185
453
  describe('Method: isWithinRange', () => {
186
454
  it('should work on simple examples', () => {
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.testLocalization = void 0;
8
7
  var _chai = require("chai");
9
- var _sinon = _interopRequireDefault(require("sinon"));
8
+ var _sinon = require("sinon");
10
9
  var _pickersUtils = require("test/utils/pickers-utils");
11
10
  var _describeGregorianAdapter = require("./describeGregorianAdapter.utils");
12
11
  const testLocalization = ({
@@ -22,10 +21,10 @@ const testLocalization = ({
22
21
 
23
22
  // Moment only translates for 12-hour cycle.
24
23
  if (adapter.lib === 'moment') {
25
- const stub = _sinon.default.stub(adapter, 'is12HourCycleInCurrentLocale').returns(false);
24
+ const sinonStub = (0, _sinon.stub)(adapter, 'is12HourCycleInCurrentLocale').returns(false);
26
25
  (0, _chai.expect)(adapter.getMeridiemText('am')).to.equal('AM');
27
26
  (0, _chai.expect)(adapter.getMeridiemText('pm')).to.equal('PM');
28
- stub.restore();
27
+ sinonStub.restore();
29
28
  }
30
29
  });
31
30
  it('Method: expandFormat', () => {