UNPKG

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