@h3ravel/support 0.16.0 → 0.17.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Time-CSQCyEfN.d.ts +166 -0
- package/dist/Time-DXrqE9Zj.js +242 -0
- package/dist/Time-DY_lqAIR.d.ts +166 -0
- package/dist/Time-H1gLMvCJ.cjs +314 -0
- package/dist/facades.cjs +45 -5
- package/dist/facades.d.ts +14 -2
- package/dist/facades.js +39 -3
- package/dist/index.cjs +91 -246
- package/dist/index.d.ts +52 -117
- package/dist/index.js +77 -182
- package/dist/traits.cjs +56 -0
- package/dist/traits.d.ts +41 -0
- package/dist/traits.js +55 -0
- package/package.json +7 -4
- /package/dist/{RuntimeException-CmsL83ow.cjs → RuntimeException-BlF2onMq.cjs} +0 -0
- /package/dist/{RuntimeException-CrNX0B-p.js → RuntimeException-Bt4SxSOi.js} +0 -0
- /package/dist/{chunk-NmTyJVUt.js → chunk-CGA-kHjv.js} +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import dayjs, { ConfigType, Dayjs, OpUnitType, OptionType, QUnitType } from "dayjs";
|
|
2
|
+
|
|
3
|
+
//#region src/Helpers/Time.d.ts
|
|
4
|
+
declare function format(date: ConfigType, fmt: string): string;
|
|
5
|
+
declare const TimeClass: {
|
|
6
|
+
new (date?: any): Dayjs;
|
|
7
|
+
} & typeof Dayjs;
|
|
8
|
+
declare class DateTime extends TimeClass {
|
|
9
|
+
private instance;
|
|
10
|
+
constructor(config?: ConfigType | DateTime);
|
|
11
|
+
constructor(config?: ConfigType | DateTime, format?: OptionType, locale?: boolean);
|
|
12
|
+
/**
|
|
13
|
+
* Start time of a specific unit.
|
|
14
|
+
*
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
start(unit?: OpUnitType): dayjs.Dayjs;
|
|
18
|
+
/**
|
|
19
|
+
* Set the timezone for the instance
|
|
20
|
+
*
|
|
21
|
+
* @param timezone
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
setTimezone(timezone?: string | undefined, keepLocalTime?: boolean | undefined): DateTime;
|
|
25
|
+
/**
|
|
26
|
+
* Returns a cloned Day.js object with a specified amount of time added.
|
|
27
|
+
* ```
|
|
28
|
+
* dayjs().add(7, 'day')// => Dayjs
|
|
29
|
+
* ```
|
|
30
|
+
* Units are case insensitive, and support plural and short forms.
|
|
31
|
+
*
|
|
32
|
+
* Docs: https://day.js.org/docs/en/manipulate/add
|
|
33
|
+
*
|
|
34
|
+
* @alias dayjs().add()
|
|
35
|
+
*/
|
|
36
|
+
add(value: number, unit?: dayjs.ManipulateType | undefined): DateTime;
|
|
37
|
+
/**
|
|
38
|
+
* End time of a specific unit.
|
|
39
|
+
*
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
end(unit?: OpUnitType): dayjs.Dayjs;
|
|
43
|
+
/**
|
|
44
|
+
* This indicates the difference between two date-time in the specified unit.
|
|
45
|
+
*
|
|
46
|
+
* To get the difference in milliseconds, use `dayjs#diff`
|
|
47
|
+
* ```
|
|
48
|
+
* const date1 = dayjs('2019-01-25')
|
|
49
|
+
* const date2 = dayjs('2018-06-05')
|
|
50
|
+
* date1.diff(date2) // 20214000000 default milliseconds
|
|
51
|
+
* date1.diff() // milliseconds to current time
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* To get the difference in another unit of measurement, pass that measurement as the second argument.
|
|
55
|
+
* ```
|
|
56
|
+
* const date1 = dayjs('2019-01-25')
|
|
57
|
+
* date1.diff('2018-06-05', 'month') // 7
|
|
58
|
+
* ```
|
|
59
|
+
* Units are case insensitive, and support plural and short forms.
|
|
60
|
+
*
|
|
61
|
+
* Docs: https://day.js.org/docs/en/display/difference
|
|
62
|
+
*/
|
|
63
|
+
diff(date?: string | number | Dayjs | DateTime | Date | null | undefined, unit?: QUnitType | OpUnitType, float?: boolean): number;
|
|
64
|
+
/**
|
|
65
|
+
* Get the first day of the month of the given date
|
|
66
|
+
*
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
firstDayOfMonth(): DateTime;
|
|
70
|
+
carbonFormat(template?: string | undefined): string;
|
|
71
|
+
/**
|
|
72
|
+
* This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
|
|
73
|
+
* ```
|
|
74
|
+
* dayjs('2019-01-25').unix() // 1548381600
|
|
75
|
+
* ```
|
|
76
|
+
* This value is floored to the nearest second, and does not include a milliseconds component.
|
|
77
|
+
*
|
|
78
|
+
* Docs: https://day.js.org/docs/en/display/unix-timestamp
|
|
79
|
+
*
|
|
80
|
+
* @alias dayjs('2019-01-25').unix()
|
|
81
|
+
*/
|
|
82
|
+
getTimestamp(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Get the last day of the month of the given date
|
|
85
|
+
*
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
lastDayOfMonth(): DateTime;
|
|
89
|
+
/**
|
|
90
|
+
* Get a random time between the specified hour and minute.
|
|
91
|
+
*
|
|
92
|
+
* @param startHour
|
|
93
|
+
* @param startMinute
|
|
94
|
+
* @param endHour
|
|
95
|
+
* @param endMinute
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
randomTime(startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): DateTime;
|
|
99
|
+
/**
|
|
100
|
+
* Create a date for a given timestamp.
|
|
101
|
+
*
|
|
102
|
+
* @param timestamp - Unix timestamp
|
|
103
|
+
*
|
|
104
|
+
* @return {Date} object
|
|
105
|
+
*/
|
|
106
|
+
static fromTimestamp(timestamp: number): DateTime;
|
|
107
|
+
/**
|
|
108
|
+
* Get current time instance.
|
|
109
|
+
*
|
|
110
|
+
* @returns Current time
|
|
111
|
+
*/
|
|
112
|
+
static now(): DateTime;
|
|
113
|
+
/**
|
|
114
|
+
* Parse the time
|
|
115
|
+
*
|
|
116
|
+
* @param date
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
static parse(date: dayjs.ConfigType): DateTime;
|
|
120
|
+
/**
|
|
121
|
+
* Get the formatted date according to the string of tokens passed in.
|
|
122
|
+
*
|
|
123
|
+
* To escape characters, wrap them in square brackets (e.g. [MM]).
|
|
124
|
+
*
|
|
125
|
+
* @param time - current time
|
|
126
|
+
* @param template - time format
|
|
127
|
+
*/
|
|
128
|
+
static format(time?: ConfigType, template?: string | undefined): string;
|
|
129
|
+
/**
|
|
130
|
+
* Get the difference in days from today.
|
|
131
|
+
*
|
|
132
|
+
* @param time
|
|
133
|
+
* @param startHour
|
|
134
|
+
* @param startMinute
|
|
135
|
+
* @param endHour
|
|
136
|
+
* @param endMinute
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
static randomTime(time?: ConfigType, startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): DateTime;
|
|
140
|
+
/**
|
|
141
|
+
* Use a dayjs plugin
|
|
142
|
+
*
|
|
143
|
+
* @param plugin
|
|
144
|
+
* @param option
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
static plugin<T = unknown>(plugin: dayjs.PluginFunc<T>, option?: T | undefined): typeof dayjs;
|
|
148
|
+
/**
|
|
149
|
+
* Get the first day of the month of the given date
|
|
150
|
+
*
|
|
151
|
+
* @param time
|
|
152
|
+
*
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
static firstDayOfMonth(time: ConfigType): DateTime;
|
|
156
|
+
/**
|
|
157
|
+
* Get the last day of the month of the given date
|
|
158
|
+
*
|
|
159
|
+
* @param time
|
|
160
|
+
*
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
static lastDayOfMonth(time: ConfigType): DateTime;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { format as n, DateTime as t };
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
3
|
+
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
4
|
+
import dayOfYear from "dayjs/plugin/dayOfYear.js";
|
|
5
|
+
import isBetween from "dayjs/plugin/isBetween.js";
|
|
6
|
+
import isLeapYear from "dayjs/plugin/isLeapYear.js";
|
|
7
|
+
import relativeTime from "dayjs/plugin/relativeTime.js";
|
|
8
|
+
import timezone from "dayjs/plugin/timezone.js";
|
|
9
|
+
import utc from "dayjs/plugin/utc.js";
|
|
10
|
+
|
|
11
|
+
//#region src/Helpers/Time.ts
|
|
12
|
+
dayjs.extend(utc);
|
|
13
|
+
dayjs.extend(timezone);
|
|
14
|
+
dayjs.extend(dayOfYear);
|
|
15
|
+
dayjs.extend(isBetween);
|
|
16
|
+
dayjs.extend(isLeapYear);
|
|
17
|
+
dayjs.extend(relativeTime);
|
|
18
|
+
dayjs.extend(advancedFormat);
|
|
19
|
+
dayjs.extend(customParseFormat);
|
|
20
|
+
const phpToDayjsTokens = (format$1) => format$1.replace(/Y/g, "YYYY").replace(/m/g, "MM").replace(/d/g, "DD").replace(/H/g, "HH").replace(/i/g, "mm").replace(/s/g, "ss");
|
|
21
|
+
function format(date, fmt) {
|
|
22
|
+
return dayjs(date).format(phpToDayjsTokens(fmt));
|
|
23
|
+
}
|
|
24
|
+
const TimeClass = class {};
|
|
25
|
+
var DateTime = class DateTime extends TimeClass {
|
|
26
|
+
instance;
|
|
27
|
+
constructor(config, format$1, locale, strict) {
|
|
28
|
+
super(config);
|
|
29
|
+
if (config instanceof DateTime) config = config.instance;
|
|
30
|
+
this.instance = dayjs(config, format$1, locale, strict);
|
|
31
|
+
return new Proxy(this, { get: (target, prop, receiver) => {
|
|
32
|
+
if (prop in target) return Reflect.get(target, prop, receiver);
|
|
33
|
+
const value = Reflect.get(this.instance, prop, receiver);
|
|
34
|
+
if (typeof value === "function") return (...args) => {
|
|
35
|
+
const result = value.apply(this.instance, args);
|
|
36
|
+
return dayjs.isDayjs(result) ? new DateTime(result) : result;
|
|
37
|
+
};
|
|
38
|
+
return value;
|
|
39
|
+
} });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Start time of a specific unit.
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
start(unit = "days") {
|
|
47
|
+
return this.startOf(unit);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Set the timezone for the instance
|
|
51
|
+
*
|
|
52
|
+
* @param timezone
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
setTimezone(timezone$1, keepLocalTime) {
|
|
56
|
+
return new DateTime(this.tz(timezone$1, keepLocalTime));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns a cloned Day.js object with a specified amount of time added.
|
|
60
|
+
* ```
|
|
61
|
+
* dayjs().add(7, 'day')// => Dayjs
|
|
62
|
+
* ```
|
|
63
|
+
* Units are case insensitive, and support plural and short forms.
|
|
64
|
+
*
|
|
65
|
+
* Docs: https://day.js.org/docs/en/manipulate/add
|
|
66
|
+
*
|
|
67
|
+
* @alias dayjs().add()
|
|
68
|
+
*/
|
|
69
|
+
add(value, unit) {
|
|
70
|
+
return new DateTime(this.instance.add(value, unit));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* End time of a specific unit.
|
|
74
|
+
*
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
end(unit = "days") {
|
|
78
|
+
return this.endOf(unit);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* This indicates the difference between two date-time in the specified unit.
|
|
82
|
+
*
|
|
83
|
+
* To get the difference in milliseconds, use `dayjs#diff`
|
|
84
|
+
* ```
|
|
85
|
+
* const date1 = dayjs('2019-01-25')
|
|
86
|
+
* const date2 = dayjs('2018-06-05')
|
|
87
|
+
* date1.diff(date2) // 20214000000 default milliseconds
|
|
88
|
+
* date1.diff() // milliseconds to current time
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* To get the difference in another unit of measurement, pass that measurement as the second argument.
|
|
92
|
+
* ```
|
|
93
|
+
* const date1 = dayjs('2019-01-25')
|
|
94
|
+
* date1.diff('2018-06-05', 'month') // 7
|
|
95
|
+
* ```
|
|
96
|
+
* Units are case insensitive, and support plural and short forms.
|
|
97
|
+
*
|
|
98
|
+
* Docs: https://day.js.org/docs/en/display/difference
|
|
99
|
+
*/
|
|
100
|
+
diff(date, unit, float) {
|
|
101
|
+
if (date instanceof DateTime) date = date.instance;
|
|
102
|
+
return this.instance.diff(date, unit, float);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get the first day of the month of the given date
|
|
106
|
+
*
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
firstDayOfMonth() {
|
|
110
|
+
return new DateTime(new Date(Date.UTC(this.year(), this.month(), 1)));
|
|
111
|
+
}
|
|
112
|
+
carbonFormat(template) {
|
|
113
|
+
return template ? this.format(phpToDayjsTokens(template)) : this.format();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
|
|
117
|
+
* ```
|
|
118
|
+
* dayjs('2019-01-25').unix() // 1548381600
|
|
119
|
+
* ```
|
|
120
|
+
* This value is floored to the nearest second, and does not include a milliseconds component.
|
|
121
|
+
*
|
|
122
|
+
* Docs: https://day.js.org/docs/en/display/unix-timestamp
|
|
123
|
+
*
|
|
124
|
+
* @alias dayjs('2019-01-25').unix()
|
|
125
|
+
*/
|
|
126
|
+
getTimestamp() {
|
|
127
|
+
return this.instance.unix();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get the last day of the month of the given date
|
|
131
|
+
*
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
lastDayOfMonth() {
|
|
135
|
+
return new DateTime(new Date(Date.UTC(this.year(), this.month() + 1, 0)));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get a random time between the specified hour and minute.
|
|
139
|
+
*
|
|
140
|
+
* @param startHour
|
|
141
|
+
* @param startMinute
|
|
142
|
+
* @param endHour
|
|
143
|
+
* @param endMinute
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
146
|
+
randomTime(startHour = 9, startMinute = 0, endHour = 17, endMinute = 0) {
|
|
147
|
+
const today = /* @__PURE__ */ new Date();
|
|
148
|
+
const startMinutes = startHour * 60 + startMinute;
|
|
149
|
+
const endMinutes = endHour * 60 + endMinute;
|
|
150
|
+
const randomMinutes = Math.floor(Math.random() * (endMinutes - startMinutes)) + startMinutes;
|
|
151
|
+
const hour = Math.floor(randomMinutes / 60);
|
|
152
|
+
const minute = randomMinutes % 60;
|
|
153
|
+
const date = new Date(today);
|
|
154
|
+
date.setHours(hour, minute, 0, 0);
|
|
155
|
+
return new DateTime(date);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Create a date for a given timestamp.
|
|
159
|
+
*
|
|
160
|
+
* @param timestamp - Unix timestamp
|
|
161
|
+
*
|
|
162
|
+
* @return {Date} object
|
|
163
|
+
*/
|
|
164
|
+
static fromTimestamp(timestamp) {
|
|
165
|
+
return new DateTime(timestamp * 1e3);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get current time instance.
|
|
169
|
+
*
|
|
170
|
+
* @returns Current time
|
|
171
|
+
*/
|
|
172
|
+
static now() {
|
|
173
|
+
return new DateTime();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Parse the time
|
|
177
|
+
*
|
|
178
|
+
* @param date
|
|
179
|
+
* @returns
|
|
180
|
+
*/
|
|
181
|
+
static parse(date) {
|
|
182
|
+
return new DateTime(date);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get the formatted date according to the string of tokens passed in.
|
|
186
|
+
*
|
|
187
|
+
* To escape characters, wrap them in square brackets (e.g. [MM]).
|
|
188
|
+
*
|
|
189
|
+
* @param time - current time
|
|
190
|
+
* @param template - time format
|
|
191
|
+
*/
|
|
192
|
+
static format(time, template) {
|
|
193
|
+
return new DateTime(time).format(template);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get the difference in days from today.
|
|
197
|
+
*
|
|
198
|
+
* @param time
|
|
199
|
+
* @param startHour
|
|
200
|
+
* @param startMinute
|
|
201
|
+
* @param endHour
|
|
202
|
+
* @param endMinute
|
|
203
|
+
* @returns
|
|
204
|
+
*/
|
|
205
|
+
static randomTime(time, startHour, startMinute, endHour, endMinute) {
|
|
206
|
+
return new DateTime(time).randomTime(startHour, startMinute, endHour, endMinute);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Use a dayjs plugin
|
|
210
|
+
*
|
|
211
|
+
* @param plugin
|
|
212
|
+
* @param option
|
|
213
|
+
* @returns
|
|
214
|
+
*/
|
|
215
|
+
static plugin(plugin, option) {
|
|
216
|
+
dayjs.extend(plugin, option);
|
|
217
|
+
return dayjs;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get the first day of the month of the given date
|
|
221
|
+
*
|
|
222
|
+
* @param time
|
|
223
|
+
*
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
static firstDayOfMonth(time) {
|
|
227
|
+
return new DateTime(time).firstDayOfMonth();
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get the last day of the month of the given date
|
|
231
|
+
*
|
|
232
|
+
* @param time
|
|
233
|
+
*
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
static lastDayOfMonth(time) {
|
|
237
|
+
return new DateTime(time).lastDayOfMonth();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
//#endregion
|
|
242
|
+
export { format as n, DateTime as t };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import dayjs, { ConfigType, Dayjs, OpUnitType, OptionType, QUnitType } from "dayjs";
|
|
2
|
+
|
|
3
|
+
//#region src/Helpers/Time.d.ts
|
|
4
|
+
declare function format(date: ConfigType, fmt: string): string;
|
|
5
|
+
declare const TimeClass: {
|
|
6
|
+
new (date?: any): Dayjs;
|
|
7
|
+
} & typeof Dayjs;
|
|
8
|
+
declare class DateTime extends TimeClass {
|
|
9
|
+
private instance;
|
|
10
|
+
constructor(config?: ConfigType | DateTime);
|
|
11
|
+
constructor(config?: ConfigType | DateTime, format?: OptionType, locale?: boolean);
|
|
12
|
+
/**
|
|
13
|
+
* Start time of a specific unit.
|
|
14
|
+
*
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
start(unit?: OpUnitType): dayjs.Dayjs;
|
|
18
|
+
/**
|
|
19
|
+
* Set the timezone for the instance
|
|
20
|
+
*
|
|
21
|
+
* @param timezone
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
setTimezone(timezone?: string | undefined, keepLocalTime?: boolean | undefined): DateTime;
|
|
25
|
+
/**
|
|
26
|
+
* Returns a cloned Day.js object with a specified amount of time added.
|
|
27
|
+
* ```
|
|
28
|
+
* dayjs().add(7, 'day')// => Dayjs
|
|
29
|
+
* ```
|
|
30
|
+
* Units are case insensitive, and support plural and short forms.
|
|
31
|
+
*
|
|
32
|
+
* Docs: https://day.js.org/docs/en/manipulate/add
|
|
33
|
+
*
|
|
34
|
+
* @alias dayjs().add()
|
|
35
|
+
*/
|
|
36
|
+
add(value: number, unit?: dayjs.ManipulateType | undefined): DateTime;
|
|
37
|
+
/**
|
|
38
|
+
* End time of a specific unit.
|
|
39
|
+
*
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
end(unit?: OpUnitType): dayjs.Dayjs;
|
|
43
|
+
/**
|
|
44
|
+
* This indicates the difference between two date-time in the specified unit.
|
|
45
|
+
*
|
|
46
|
+
* To get the difference in milliseconds, use `dayjs#diff`
|
|
47
|
+
* ```
|
|
48
|
+
* const date1 = dayjs('2019-01-25')
|
|
49
|
+
* const date2 = dayjs('2018-06-05')
|
|
50
|
+
* date1.diff(date2) // 20214000000 default milliseconds
|
|
51
|
+
* date1.diff() // milliseconds to current time
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* To get the difference in another unit of measurement, pass that measurement as the second argument.
|
|
55
|
+
* ```
|
|
56
|
+
* const date1 = dayjs('2019-01-25')
|
|
57
|
+
* date1.diff('2018-06-05', 'month') // 7
|
|
58
|
+
* ```
|
|
59
|
+
* Units are case insensitive, and support plural and short forms.
|
|
60
|
+
*
|
|
61
|
+
* Docs: https://day.js.org/docs/en/display/difference
|
|
62
|
+
*/
|
|
63
|
+
diff(date?: string | number | Dayjs | DateTime | Date | null | undefined, unit?: QUnitType | OpUnitType, float?: boolean): number;
|
|
64
|
+
/**
|
|
65
|
+
* Get the first day of the month of the given date
|
|
66
|
+
*
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
firstDayOfMonth(): DateTime;
|
|
70
|
+
carbonFormat(template?: string | undefined): string;
|
|
71
|
+
/**
|
|
72
|
+
* This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
|
|
73
|
+
* ```
|
|
74
|
+
* dayjs('2019-01-25').unix() // 1548381600
|
|
75
|
+
* ```
|
|
76
|
+
* This value is floored to the nearest second, and does not include a milliseconds component.
|
|
77
|
+
*
|
|
78
|
+
* Docs: https://day.js.org/docs/en/display/unix-timestamp
|
|
79
|
+
*
|
|
80
|
+
* @alias dayjs('2019-01-25').unix()
|
|
81
|
+
*/
|
|
82
|
+
getTimestamp(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Get the last day of the month of the given date
|
|
85
|
+
*
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
lastDayOfMonth(): DateTime;
|
|
89
|
+
/**
|
|
90
|
+
* Get a random time between the specified hour and minute.
|
|
91
|
+
*
|
|
92
|
+
* @param startHour
|
|
93
|
+
* @param startMinute
|
|
94
|
+
* @param endHour
|
|
95
|
+
* @param endMinute
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
randomTime(startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): DateTime;
|
|
99
|
+
/**
|
|
100
|
+
* Create a date for a given timestamp.
|
|
101
|
+
*
|
|
102
|
+
* @param timestamp - Unix timestamp
|
|
103
|
+
*
|
|
104
|
+
* @return {Date} object
|
|
105
|
+
*/
|
|
106
|
+
static fromTimestamp(timestamp: number): DateTime;
|
|
107
|
+
/**
|
|
108
|
+
* Get current time instance.
|
|
109
|
+
*
|
|
110
|
+
* @returns Current time
|
|
111
|
+
*/
|
|
112
|
+
static now(): DateTime;
|
|
113
|
+
/**
|
|
114
|
+
* Parse the time
|
|
115
|
+
*
|
|
116
|
+
* @param date
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
static parse(date: dayjs.ConfigType): DateTime;
|
|
120
|
+
/**
|
|
121
|
+
* Get the formatted date according to the string of tokens passed in.
|
|
122
|
+
*
|
|
123
|
+
* To escape characters, wrap them in square brackets (e.g. [MM]).
|
|
124
|
+
*
|
|
125
|
+
* @param time - current time
|
|
126
|
+
* @param template - time format
|
|
127
|
+
*/
|
|
128
|
+
static format(time?: ConfigType, template?: string | undefined): string;
|
|
129
|
+
/**
|
|
130
|
+
* Get the difference in days from today.
|
|
131
|
+
*
|
|
132
|
+
* @param time
|
|
133
|
+
* @param startHour
|
|
134
|
+
* @param startMinute
|
|
135
|
+
* @param endHour
|
|
136
|
+
* @param endMinute
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
static randomTime(time?: ConfigType, startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): DateTime;
|
|
140
|
+
/**
|
|
141
|
+
* Use a dayjs plugin
|
|
142
|
+
*
|
|
143
|
+
* @param plugin
|
|
144
|
+
* @param option
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
static plugin<T = unknown>(plugin: dayjs.PluginFunc<T>, option?: T | undefined): typeof dayjs;
|
|
148
|
+
/**
|
|
149
|
+
* Get the first day of the month of the given date
|
|
150
|
+
*
|
|
151
|
+
* @param time
|
|
152
|
+
*
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
static firstDayOfMonth(time: ConfigType): DateTime;
|
|
156
|
+
/**
|
|
157
|
+
* Get the last day of the month of the given date
|
|
158
|
+
*
|
|
159
|
+
* @param time
|
|
160
|
+
*
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
static lastDayOfMonth(time: ConfigType): DateTime;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { format as n, DateTime as t };
|