UNPKG

4.36 kBTypeScriptView Raw
1/**
2 * @module constants
3 * @summary Useful constants
4 * @description
5 * Collection of useful date constants.
6 *
7 * The constants could be imported from `date-fns/constants`:
8 *
9 * ```ts
10 * import { maxTime, minTime } from "./constants/date-fns/constants";
11 *
12 * function isAllowedTime(time) {
13 * return time <= maxTime && time >= minTime;
14 * }
15 * ```
16 */
17/**
18 * @constant
19 * @name daysInWeek
20 * @summary Days in 1 week.
21 */
22export declare const daysInWeek = 7;
23/**
24 * @constant
25 * @name daysInYear
26 * @summary Days in 1 year.
27 *
28 * @description
29 * How many days in a year.
30 *
31 * One years equals 365.2425 days according to the formula:
32 *
33 * > Leap year occurs every 4 years, except for years that are divisible by 100 and not divisible by 400.
34 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
35 */
36export declare const daysInYear = 365.2425;
37/**
38 * @constant
39 * @name maxTime
40 * @summary Maximum allowed time.
41 *
42 * @example
43 * import { maxTime } from "./constants/date-fns/constants";
44 *
45 * const isValid = 8640000000000001 <= maxTime;
46 * //=> false
47 *
48 * new Date(8640000000000001);
49 * //=> Invalid Date
50 */
51export declare const maxTime: number;
52/**
53 * @constant
54 * @name minTime
55 * @summary Minimum allowed time.
56 *
57 * @example
58 * import { minTime } from "./constants/date-fns/constants";
59 *
60 * const isValid = -8640000000000001 >= minTime;
61 * //=> false
62 *
63 * new Date(-8640000000000001)
64 * //=> Invalid Date
65 */
66export declare const minTime: number;
67/**
68 * @constant
69 * @name millisecondsInWeek
70 * @summary Milliseconds in 1 week.
71 */
72export declare const millisecondsInWeek = 604800000;
73/**
74 * @constant
75 * @name millisecondsInDay
76 * @summary Milliseconds in 1 day.
77 */
78export declare const millisecondsInDay = 86400000;
79/**
80 * @constant
81 * @name millisecondsInMinute
82 * @summary Milliseconds in 1 minute
83 */
84export declare const millisecondsInMinute = 60000;
85/**
86 * @constant
87 * @name millisecondsInHour
88 * @summary Milliseconds in 1 hour
89 */
90export declare const millisecondsInHour = 3600000;
91/**
92 * @constant
93 * @name millisecondsInSecond
94 * @summary Milliseconds in 1 second
95 */
96export declare const millisecondsInSecond = 1000;
97/**
98 * @constant
99 * @name minutesInYear
100 * @summary Minutes in 1 year.
101 */
102export declare const minutesInYear = 525600;
103/**
104 * @constant
105 * @name minutesInMonth
106 * @summary Minutes in 1 month.
107 */
108export declare const minutesInMonth = 43200;
109/**
110 * @constant
111 * @name minutesInDay
112 * @summary Minutes in 1 day.
113 */
114export declare const minutesInDay = 1440;
115/**
116 * @constant
117 * @name minutesInHour
118 * @summary Minutes in 1 hour.
119 */
120export declare const minutesInHour = 60;
121/**
122 * @constant
123 * @name monthsInQuarter
124 * @summary Months in 1 quarter.
125 */
126export declare const monthsInQuarter = 3;
127/**
128 * @constant
129 * @name monthsInYear
130 * @summary Months in 1 year.
131 */
132export declare const monthsInYear = 12;
133/**
134 * @constant
135 * @name quartersInYear
136 * @summary Quarters in 1 year
137 */
138export declare const quartersInYear = 4;
139/**
140 * @constant
141 * @name secondsInHour
142 * @summary Seconds in 1 hour.
143 */
144export declare const secondsInHour = 3600;
145/**
146 * @constant
147 * @name secondsInMinute
148 * @summary Seconds in 1 minute.
149 */
150export declare const secondsInMinute = 60;
151/**
152 * @constant
153 * @name secondsInDay
154 * @summary Seconds in 1 day.
155 */
156export declare const secondsInDay: number;
157/**
158 * @constant
159 * @name secondsInWeek
160 * @summary Seconds in 1 week.
161 */
162export declare const secondsInWeek: number;
163/**
164 * @constant
165 * @name secondsInYear
166 * @summary Seconds in 1 year.
167 */
168export declare const secondsInYear: number;
169/**
170 * @constant
171 * @name secondsInMonth
172 * @summary Seconds in 1 month
173 */
174export declare const secondsInMonth: number;
175/**
176 * @constant
177 * @name secondsInQuarter
178 * @summary Seconds in 1 quarter.
179 */
180export declare const secondsInQuarter: number;
181/**
182 * @constant
183 * @name constructFromSymbol
184 * @summary Symbol enabling Date extensions to inherit properties from the reference date.
185 *
186 * The symbol is used to enable the `constructFrom` function to construct a date
187 * using a reference date and a value. It allows to transfer extra properties
188 * from the reference date to the new date. It's useful for extensions like
189 * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as
190 * a constructor argument.
191 */
192export declare const constructFromSymbol: unique symbol;