UNPKG

2.63 kBTypeScriptView Raw
1/// <reference path="./locale/index.d.ts" />
2
3export = dayjs;
4
5declare function dayjs (date?: dayjs.ConfigType): dayjs.Dayjs
6
7declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, strict?: boolean): dayjs.Dayjs
8
9declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean): dayjs.Dayjs
10
11declare 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 type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
17 export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | UnitTypeShort;
18
19 export type OpUnitType = UnitType | "week" | 'w';
20 export type QUnitType = UnitType | "quarter" | 'Q';
21
22 class Dayjs {
23 constructor (config?: ConfigType)
24
25 clone(): Dayjs
26
27 isValid(): boolean
28
29 year(): number
30
31 year(value: number): Dayjs
32
33 month(): number
34
35 month(value: number): Dayjs
36
37 date(): number
38
39 date(value: number): Dayjs
40
41 day(): number
42
43 day(value: number): Dayjs
44
45 hour(): number
46
47 hour(value: number): Dayjs
48
49 minute(): number
50
51 minute(value: number): Dayjs
52
53 second(): number
54
55 second(value: number): Dayjs
56
57 millisecond(): number
58
59 millisecond(value: number): Dayjs
60
61 set(unit: UnitType, value: number): Dayjs
62
63 get(unit: UnitType): number
64
65 add(value: number, unit: OpUnitType): Dayjs
66
67 subtract(value: number, unit: OpUnitType): Dayjs
68
69 startOf(unit: OpUnitType): Dayjs
70
71 endOf(unit: OpUnitType): Dayjs
72
73 format(template?: string): string
74
75 diff(date: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number
76
77 valueOf(): number
78
79 unix(): number
80
81 daysInMonth(): number
82
83 toDate(): Date
84
85 toJSON(): string
86
87 toISOString(): string
88
89 toString(): string
90
91 utcOffset(): number
92
93 isBefore(date: ConfigType, unit?: OpUnitType): boolean
94
95 isSame(date: ConfigType, unit?: OpUnitType): boolean
96
97 isAfter(date: ConfigType, unit?: OpUnitType): boolean
98
99 locale(): string
100
101 locale(preset: string | ILocale, object?: Partial<ILocale>): Dayjs
102 }
103
104 export type PluginFunc<T = unknown> = (option: T, c: typeof Dayjs, d: typeof dayjs) => void
105
106 export function extend<T = unknown>(plugin: PluginFunc<T>, option?: T): Dayjs
107
108 export function locale(preset?: string | ILocale, object?: Partial<ILocale>, isLocal?: boolean): string
109
110 export function isDayjs(d: any): d is Dayjs
111
112 export function unix(t: number): Dayjs
113
114 const Ls : { [key: string] : ILocale }
115}