1 |
|
2 |
|
3 | export = dayjs;
|
4 |
|
5 | declare function dayjs (date?: dayjs.ConfigType): dayjs.Dayjs
|
6 |
|
7 | declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, strict?: boolean): dayjs.Dayjs
|
8 |
|
9 | declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean): dayjs.Dayjs
|
10 |
|
11 | declare namespace dayjs {
|
12 | export type ConfigType = string | number | Date | Dayjs
|
13 |
|
14 | export type OptionType = { locale?: string, format?: string, utc?: boolean } | string | string[]
|
15 |
|
16 | export type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
|
17 |
|
18 | export type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date'
|
19 |
|
20 | export type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates'
|
21 |
|
22 | export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort;
|
23 |
|
24 | export type OpUnitType = UnitType | "week" | "weeks" | 'w';
|
25 | export type QUnitType = UnitType | "quarter" | "quarters" | 'Q';
|
26 |
|
27 | class Dayjs {
|
28 | constructor (config?: ConfigType)
|
29 | /**
|
30 | * All Day.js objects are immutable. Still, `dayjs#clone` can create a clone of the current object if you need one.
|
31 | * ```
|
32 | * dayjs().clone()// => Dayjs
|
33 | * dayjs(dayjs('2019-01-25')) // passing a Dayjs object to a constructor will also clone it
|
34 | * ```
|
35 | * Docs: https://day.js.org/docs/en/parse/dayjs-clone
|
36 | */
|
37 | clone(): Dayjs
|
38 | /**
|
39 | * This returns a `boolean` indicating whether the Day.js object contains a valid date or not.
|
40 | * ```
|
41 | * dayjs().isValid()// => boolean
|
42 | * ```
|
43 | * Docs: https://day.js.org/docs/en/parse/is-valid
|
44 | */
|
45 | isValid(): boolean
|
46 | /**
|
47 | * Get the year.
|
48 | * ```
|
49 | * dayjs().year()// => 2020
|
50 | * ```
|
51 | * Docs: https://day.js.org/docs/en/get-set/year
|
52 | */
|
53 | year(): number
|
54 | /**
|
55 | * Set the year.
|
56 | * ```
|
57 | * dayjs().year(2000)// => Dayjs
|
58 | * ```
|
59 | * Docs: https://day.js.org/docs/en/get-set/year
|
60 | */
|
61 | year(value: number): Dayjs
|
62 | /**
|
63 | * Get the month.
|
64 | *
|
65 | * Months are zero indexed, so January is month 0.
|
66 | * ```
|
67 | * dayjs().month()// => 0-11
|
68 | * ```
|
69 | * Docs: https://day.js.org/docs/en/get-set/month
|
70 | */
|
71 | month(): number
|
72 | /**
|
73 | * Set the month.
|
74 | *
|
75 | * Months are zero indexed, so January is month 0.
|
76 | *
|
77 | * Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the year.
|
78 | * ```
|
79 | * dayjs().month(0)// => Dayjs
|
80 | * ```
|
81 | * Docs: https://day.js.org/docs/en/get-set/month
|
82 | */
|
83 | month(value: number): Dayjs
|
84 | /**
|
85 | * Get the date of the month.
|
86 | * ```
|
87 | * dayjs().date()// => 1-31
|
88 | * ```
|
89 | * Docs: https://day.js.org/docs/en/get-set/date
|
90 | */
|
91 | date(): number
|
92 | /**
|
93 | * Set the date of the month.
|
94 | *
|
95 | * Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the months.
|
96 | * ```
|
97 | * dayjs().date(1)// => Dayjs
|
98 | * ```
|
99 | * Docs: https://day.js.org/docs/en/get-set/date
|
100 | */
|
101 | date(value: number): Dayjs
|
102 | /**
|
103 | * Get the day of the week.
|
104 | *
|
105 | * Returns numbers from 0 (Sunday) to 6 (Saturday).
|
106 | * ```
|
107 | * dayjs().day()// 0-6
|
108 | * ```
|
109 | * Docs: https://day.js.org/docs/en/get-set/day
|
110 | */
|
111 | day(): number
|
112 | /**
|
113 | * Set the day of the week.
|
114 | *
|
115 | * Accepts numbers from 0 (Sunday) to 6 (Saturday). If the range is exceeded, it will bubble up to other weeks.
|
116 | * ```
|
117 | * dayjs().day(0)// => Dayjs
|
118 | * ```
|
119 | * Docs: https://day.js.org/docs/en/get-set/day
|
120 | */
|
121 | day(value: number): Dayjs
|
122 | /**
|
123 | * Get the hour.
|
124 | * ```
|
125 | * dayjs().hour()// => 0-23
|
126 | * ```
|
127 | * Docs: https://day.js.org/docs/en/get-set/hour
|
128 | */
|
129 | hour(): number
|
130 | /**
|
131 | * Set the hour.
|
132 | *
|
133 | * Accepts numbers from 0 to 23. If the range is exceeded, it will bubble up to the day.
|
134 | * ```
|
135 | * dayjs().hour(12)// => Dayjs
|
136 | * ```
|
137 | * Docs: https://day.js.org/docs/en/get-set/hour
|
138 | */
|
139 | hour(value: number): Dayjs
|
140 | /**
|
141 | * Get the minutes.
|
142 | * ```
|
143 | * dayjs().minute()// => 0-59
|
144 | * ```
|
145 | * Docs: https://day.js.org/docs/en/get-set/minute
|
146 | */
|
147 | minute(): number
|
148 | /**
|
149 | * Set the minutes.
|
150 | *
|
151 | * Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the hour.
|
152 | * ```
|
153 | * dayjs().minute(59)// => Dayjs
|
154 | * ```
|
155 | * Docs: https://day.js.org/docs/en/get-set/minute
|
156 | */
|
157 | minute(value: number): Dayjs
|
158 | /**
|
159 | * Get the seconds.
|
160 | * ```
|
161 | * dayjs().second()// => 0-59
|
162 | * ```
|
163 | * Docs: https://day.js.org/docs/en/get-set/second
|
164 | */
|
165 | second(): number
|
166 | /**
|
167 | * Set the seconds.
|
168 | *
|
169 | * Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the minutes.
|
170 | * ```
|
171 | * dayjs().second(1)// Dayjs
|
172 | * ```
|
173 | */
|
174 | second(value: number): Dayjs
|
175 | /**
|
176 | * Get the milliseconds.
|
177 | * ```
|
178 | * dayjs().millisecond()// => 0-999
|
179 | * ```
|
180 | * Docs: https://day.js.org/docs/en/get-set/millisecond
|
181 | */
|
182 | millisecond(): number
|
183 | /**
|
184 | * Set the milliseconds.
|
185 | *
|
186 | * Accepts numbers from 0 to 999. If the range is exceeded, it will bubble up to the seconds.
|
187 | * ```
|
188 | * dayjs().millisecond(1)// => Dayjs
|
189 | * ```
|
190 | * Docs: https://day.js.org/docs/en/get-set/millisecond
|
191 | */
|
192 | millisecond(value: number): Dayjs
|
193 | /**
|
194 | * Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes.
|
195 | *
|
196 | * In general:
|
197 | * ```
|
198 | * dayjs().set(unit, value) === dayjs()[unit](value)
|
199 | * ```
|
200 | * Units are case insensitive, and support plural and short forms.
|
201 | * ```
|
202 | * dayjs().set('date', 1)
|
203 | * dayjs().set('month', 3) // April
|
204 | * dayjs().set('second', 30)
|
205 | * ```
|
206 | * Docs: https://day.js.org/docs/en/get-set/set
|
207 | */
|
208 | set(unit: UnitType, value: number): Dayjs
|
209 | /**
|
210 | * String getter, returns the corresponding information getting from Day.js object.
|
211 | *
|
212 | * In general:
|
213 | * ```
|
214 | * dayjs().get(unit) === dayjs()[unit]()
|
215 | * ```
|
216 | * Units are case insensitive, and support plural and short forms.
|
217 | * ```
|
218 | * dayjs().get('year')
|
219 | * dayjs().get('month') // start 0
|
220 | * dayjs().get('date')
|
221 | * ```
|
222 | * Docs: https://day.js.org/docs/en/get-set/get
|
223 | */
|
224 | get(unit: UnitType): number
|
225 | /**
|
226 | * Returns a cloned Day.js object with a specified amount of time added.
|
227 | * ```
|
228 | * dayjs().add(7, 'day')// => Dayjs
|
229 | * ```
|
230 | * Units are case insensitive, and support plural and short forms.
|
231 | *
|
232 | * Docs: https://day.js.org/docs/en/manipulate/add
|
233 | */
|
234 | add(value: number, unit?: OpUnitType): Dayjs
|
235 | /**
|
236 | * Returns a cloned Day.js object with a specified amount of time subtracted.
|
237 | * ```
|
238 | * dayjs().subtract(7, 'year')// => Dayjs
|
239 | * ```
|
240 | * Units are case insensitive, and support plural and short forms.
|
241 | *
|
242 | * Docs: https://day.js.org/docs/en/manipulate/subtract
|
243 | */
|
244 | subtract(value: number, unit?: OpUnitType): Dayjs
|
245 | /**
|
246 | * Returns a cloned Day.js object and set it to the start of a unit of time.
|
247 | * ```
|
248 | * dayjs().startOf('year')// => Dayjs
|
249 | * ```
|
250 | * Units are case insensitive, and support plural and short forms.
|
251 | *
|
252 | * Docs: https://day.js.org/docs/en/manipulate/start-of
|
253 | */
|
254 | startOf(unit: OpUnitType): Dayjs
|
255 | /**
|
256 | * Returns a cloned Day.js object and set it to the end of a unit of time.
|
257 | * ```
|
258 | * dayjs().endOf('month')// => Dayjs
|
259 | * ```
|
260 | * Units are case insensitive, and support plural and short forms.
|
261 | *
|
262 | * Docs: https://day.js.org/docs/en/manipulate/end-of
|
263 | */
|
264 | endOf(unit: OpUnitType): Dayjs
|
265 | /**
|
266 | * Get the formatted date according to the string of tokens passed in.
|
267 | *
|
268 | * To escape characters, wrap them in square brackets (e.g. [MM]).
|
269 | * ```
|
270 | * dayjs().format()// => current date in ISO8601, without fraction seconds e.g. '2020-04-02T08:02:17-05:00'
|
271 | * dayjs('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]')// 'YYYYescape 2019-01-25T00:00:00-02:00Z'
|
272 | * dayjs('2019-01-25').format('DD/MM/YYYY') // '25/01/2019'
|
273 | * ```
|
274 | * Docs: https://day.js.org/docs/en/display/format
|
275 | */
|
276 | format(template?: string): string
|
277 | /**
|
278 | * This indicates the difference between two date-time in the specified unit.
|
279 | *
|
280 | * To get the difference in milliseconds, use `dayjs#diff`
|
281 | * ```
|
282 | * const date1 = dayjs('2019-01-25')
|
283 | * const date2 = dayjs('2018-06-05')
|
284 | * date1.diff(date2) // 20214000000 default milliseconds
|
285 | * ```
|
286 | * To get the difference in another unit of measurement, pass that measurement as the second argument.
|
287 | * ```
|
288 | * const date1 = dayjs('2019-01-25')
|
289 | * date1.diff('2018-06-05', 'month') // 7
|
290 | * ```
|
291 | * Units are case insensitive, and support plural and short forms.
|
292 | *
|
293 | * Docs: https://day.js.org/docs/en/display/difference
|
294 | */
|
295 | diff(date: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number
|
296 | /**
|
297 | * This returns the number of **milliseconds** since the Unix Epoch of the Day.js object.
|
298 | * ```
|
299 | * dayjs('2019-01-25').valueOf() // 1548381600000
|
300 | * +dayjs(1548381600000) // 1548381600000
|
301 | * ```
|
302 | * To get a Unix timestamp (the number of seconds since the epoch) from a Day.js object, you should use Unix Timestamp `dayjs#unix()`.
|
303 | *
|
304 | * Docs: https://day.js.org/docs/en/display/unix-timestamp-milliseconds
|
305 | */
|
306 | valueOf(): number
|
307 | /**
|
308 | * This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
|
309 | * ```
|
310 | * dayjs('2019-01-25').unix() // 1548381600
|
311 | * ```
|
312 | * This value is floored to the nearest second, and does not include a milliseconds component.
|
313 | *
|
314 | * Docs: https://day.js.org/docs/en/display/unix-timestamp
|
315 | */
|
316 | unix(): number
|
317 | /**
|
318 | * Get the number of days in the current month.
|
319 | * ```
|
320 | * dayjs('2019-01-25').daysInMonth() // 31
|
321 | * ```
|
322 | * Docs: https://day.js.org/docs/en/display/days-in-month
|
323 | */
|
324 | daysInMonth(): number
|
325 | /**
|
326 | * To get a copy of the native `Date` object parsed from the Day.js object use `dayjs#toDate`.
|
327 | * ```
|
328 | * dayjs('2019-01-25').toDate()// => Date
|
329 | * ```
|
330 | */
|
331 | toDate(): Date
|
332 | /**
|
333 | * To serialize as an ISO 8601 string.
|
334 | * ```
|
335 | * dayjs('2019-01-25').toJSON() // '2019-01-25T02:00:00.000Z'
|
336 | * ```
|
337 | * Docs: https://day.js.org/docs/en/display/as-json
|
338 | */
|
339 | toJSON(): string
|
340 | /**
|
341 | * To format as an ISO 8601 string.
|
342 | * ```
|
343 | * dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z'
|
344 | * ```
|
345 | * Docs: https://day.js.org/docs/en/display/as-iso-string
|
346 | */
|
347 | toISOString(): string
|
348 | /**
|
349 | * Returns a string representation of the date.
|
350 | * ```
|
351 | * dayjs('2019-01-25').toString() // 'Fri, 25 Jan 2019 02:00:00 GMT'
|
352 | * ```
|
353 | * Docs: https://day.js.org/docs/en/display/as-string
|
354 | */
|
355 | toString(): string
|
356 | /**
|
357 | * Get the UTC offset in minutes.
|
358 | * ```
|
359 | * dayjs().utcOffset()
|
360 | * ```
|
361 | * Docs: https://day.js.org/docs/en/manipulate/utc-offset
|
362 | */
|
363 | utcOffset(): number
|
364 | /**
|
365 | * This indicates whether the Day.js object is before the other supplied date-time.
|
366 | * ```
|
367 | * dayjs().isBefore(dayjs('2011-01-01')) // default milliseconds
|
368 | * ```
|
369 | * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
|
370 | * ```
|
371 | * dayjs().isBefore('2011-01-01', 'year')// => boolean
|
372 | * ```
|
373 | * Units are case insensitive, and support plural and short forms.
|
374 | *
|
375 | * Docs: https://day.js.org/docs/en/query/is-before
|
376 | */
|
377 | isBefore(date: ConfigType, unit?: OpUnitType): boolean
|
378 | /**
|
379 | * This indicates whether the Day.js object is the same as the other supplied date-time.
|
380 | * ```
|
381 | * dayjs().isSame(dayjs('2011-01-01')) // default milliseconds
|
382 | * ```
|
383 | * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
|
384 | * ```
|
385 | * dayjs().isSame('2011-01-01', 'year')// => boolean
|
386 | * ```
|
387 | * Docs: https://day.js.org/docs/en/query/is-same
|
388 | */
|
389 | isSame(date: ConfigType, unit?: OpUnitType): boolean
|
390 | /**
|
391 | * This indicates whether the Day.js object is after the other supplied date-time.
|
392 | * ```
|
393 | * dayjs().isAfter(dayjs('2011-01-01')) // default milliseconds
|
394 | * ```
|
395 | * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
|
396 | * ```
|
397 | * dayjs().isAfter('2011-01-01', 'year')// => boolean
|
398 | * ```
|
399 | * Units are case insensitive, and support plural and short forms.
|
400 | *
|
401 | * Docs: https://day.js.org/docs/en/query/is-after
|
402 | */
|
403 | isAfter(date: ConfigType, unit?: OpUnitType): boolean
|
404 |
|
405 | locale(): string
|
406 |
|
407 | locale(preset: string | ILocale, object?: Partial<ILocale>): Dayjs
|
408 | }
|
409 |
|
410 | export type PluginFunc<T = unknown> = (option: T, c: typeof Dayjs, d: typeof dayjs) => void
|
411 |
|
412 | export function extend<T = unknown>(plugin: PluginFunc<T>, option?: T): Dayjs
|
413 |
|
414 | export function locale(preset?: string | ILocale, object?: Partial<ILocale>, isLocal?: boolean): string
|
415 |
|
416 | export function isDayjs(d: any): d is Dayjs
|
417 |
|
418 | export function unix(t: number): Dayjs
|
419 |
|
420 | const Ls : { [key: string] : ILocale }
|
421 | }
|