1 | import { PluginFunc } from 'dayjs'
|
2 | import { OpUnitType, UnitTypeLongPlural } from "../index";
|
3 |
|
4 | declare const plugin: PluginFunc
|
5 | export as namespace plugin;
|
6 | export = plugin
|
7 |
|
8 | declare namespace plugin {
|
9 | type DurationUnitsObjectType = Partial<{
|
10 | [unit in Exclude<UnitTypeLongPlural, "dates"> | "weeks"]: number
|
11 | }>;
|
12 | type DurationUnitType = Exclude<OpUnitType, "date" | "dates">
|
13 | type CreateDurationType =
|
14 | ((units: DurationUnitsObjectType) => Duration)
|
15 | & ((time: number, unit?: DurationUnitType) => Duration)
|
16 | & ((ISO_8601: string) => Duration)
|
17 |
|
18 | interface Duration {
|
19 | new (input: string | number | object, unit?: string, locale?: string): Duration
|
20 |
|
21 | clone(): Duration
|
22 |
|
23 | humanize(withSuffix?: boolean): string
|
24 |
|
25 | milliseconds(): number
|
26 | asMilliseconds(): number
|
27 |
|
28 | seconds(): number
|
29 | asSeconds(): number
|
30 |
|
31 | minutes(): number
|
32 | asMinutes(): number
|
33 |
|
34 | hours(): number
|
35 | asHours(): number
|
36 |
|
37 | days(): number
|
38 | asDays(): number
|
39 |
|
40 | weeks(): number
|
41 | asWeeks(): number
|
42 |
|
43 | months(): number
|
44 | asMonths(): number
|
45 |
|
46 | years(): number
|
47 | asYears(): number
|
48 |
|
49 | as(unit: DurationUnitType): number
|
50 |
|
51 | get(unit: DurationUnitType): number
|
52 |
|
53 | add: CreateDurationType;
|
54 |
|
55 | subtract: CreateDurationType
|
56 |
|
57 | toJSON(): string
|
58 |
|
59 | toISOString(): string
|
60 |
|
61 | format(formatStr?: string): string
|
62 |
|
63 | locale(locale: string): Duration
|
64 | }
|
65 | }
|
66 |
|
67 | declare module 'dayjs' {
|
68 | interface Dayjs {
|
69 | add(duration: plugin.Duration): Dayjs
|
70 | subtract(duration: plugin.Duration): Dayjs
|
71 | }
|
72 |
|
73 | /**
|
74 | * @param time If unit is not present, time treated as number of milliseconds
|
75 | */
|
76 | export const duration: plugin.CreateDurationType;
|
77 | export function isDuration(d: any): d is plugin.Duration
|
78 | }
|
79 |
|
\ | No newline at end of file |