UNPKG

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