1 | # Constants
|
2 |
|
3 | date-fns provides with a number of useful constants.
|
4 |
|
5 | ## Usage
|
6 |
|
7 | The constants could be imported from `date-fns/constants` or directly
|
8 | from `date-fns`:
|
9 |
|
10 | ```js
|
11 | import { maxTime } from 'date-fns/constants'
|
12 | import { minTime } from 'date-fns'
|
13 |
|
14 | function isAllowedTime(time) {
|
15 | return time <= maxTime && time >= minTime
|
16 | }
|
17 | ```
|
18 |
|
19 | ## Constants
|
20 |
|
21 | ### `maxTime`
|
22 |
|
23 | Maximum allowed time:
|
24 |
|
25 | ```js
|
26 | import { maxTime } from 'date-fns'
|
27 |
|
28 | const isValid = 8640000000000001 <= maxTime
|
29 | //=> false
|
30 |
|
31 | new Date(8640000000000001)
|
32 | //=> Invalid Date
|
33 | ```
|
34 |
|
35 | ### `minTime`
|
36 |
|
37 | Minimum allowed time:
|
38 |
|
39 | ```js
|
40 | import { minTime } from 'date-fns'
|
41 |
|
42 | const isValid = -8640000000000001 >= minTime
|
43 | //=> false
|
44 |
|
45 | new Date(-8640000000000001)
|
46 | //=> Invalid Date
|
47 | ```
|