You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Constants
  2. date-fns provides with a number of useful constants.
  3. ## Usage
  4. The constants could be imported from `date-fns/constants` or directly
  5. from `date-fns`:
  6. ```js
  7. import { maxTime } from 'date-fns/constants'
  8. import { minTime } from 'date-fns'
  9. function isAllowedTime(time) {
  10. return time <= maxTime && time >= minTime
  11. }
  12. ```
  13. ## Constants
  14. ### `maxTime`
  15. Maximum allowed time:
  16. ```js
  17. import { maxTime } from 'date-fns'
  18. const isValid = 8640000000000001 <= maxTime
  19. //=> false
  20. new Date(8640000000000001)
  21. //=> Invalid Date
  22. ```
  23. ### `minTime`
  24. Minimum allowed time:
  25. ```js
  26. import { minTime } from 'date-fns'
  27. const isValid = -8640000000000001 >= minTime
  28. //=> false
  29. new Date(-8640000000000001)
  30. //=> Invalid Date
  31. ```