a2bei4-utils 1.0.3 → 1.0.4
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/a2bei4.utils.cjs.js +195 -104
- package/dist/a2bei4.utils.cjs.js.map +1 -1
- package/dist/a2bei4.utils.cjs.min.js +1 -1
- package/dist/a2bei4.utils.cjs.min.js.map +1 -1
- package/dist/a2bei4.utils.esm.js +190 -101
- package/dist/a2bei4.utils.esm.js.map +1 -1
- package/dist/a2bei4.utils.esm.min.js +1 -1
- package/dist/a2bei4.utils.esm.min.js.map +1 -1
- package/dist/a2bei4.utils.umd.js +195 -104
- package/dist/a2bei4.utils.umd.js.map +1 -1
- package/dist/a2bei4.utils.umd.min.js +1 -1
- package/dist/a2bei4.utils.umd.min.js.map +1 -1
- package/dist/date.cjs +191 -100
- package/dist/date.cjs.map +1 -1
- package/dist/date.js +186 -97
- package/dist/date.js.map +1 -1
- package/package.json +1 -1
- package/types/date.d.ts +186 -47
- package/types/index.d.ts +185 -47
package/types/date.d.ts
CHANGED
|
@@ -19,60 +19,119 @@ declare function toDate(val: any): Date | null;
|
|
|
19
19
|
*/
|
|
20
20
|
declare function randomDateInRange(date1: Date, date2: Date): Date;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
* @
|
|
22
|
+
* 时间持续对象(完整版本,包含年月日时分秒毫秒)
|
|
23
|
+
* @typedef {Object} DurationObject
|
|
24
|
+
* @property {number} years - 年数
|
|
25
|
+
* @property {number} months - 月数(0-11)
|
|
26
|
+
* @property {number} days - 天数(0-29,取决于 monthDays)
|
|
27
|
+
* @property {number} hours - 小时数(0-23)
|
|
28
|
+
* @property {number} minutes - 分钟数(0-59)
|
|
29
|
+
* @property {number} seconds - 秒数(0-59)
|
|
30
|
+
* @property {number} milliseconds - 毫秒数(0-999)
|
|
27
31
|
*/
|
|
28
|
-
declare function calcTimeDifference(originalTime: string | number | Date, currentTime?: Date): {
|
|
29
|
-
days: number;
|
|
30
|
-
hours: string;
|
|
31
|
-
minutes: string;
|
|
32
|
-
seconds: string;
|
|
33
|
-
};
|
|
34
32
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
day: string;
|
|
52
|
-
hour: string;
|
|
53
|
-
minute: string;
|
|
54
|
-
second: string;
|
|
55
|
-
}> | undefined;
|
|
56
|
-
maxUnit?: "year" | "month" | "day" | "hour" | "minute" | "second" | undefined;
|
|
57
|
-
minUnit?: "year" | "month" | "day" | "hour" | "minute" | "second" | undefined;
|
|
58
|
-
showZero?: boolean | undefined;
|
|
59
|
-
}): string;
|
|
33
|
+
* 时间持续对象(最大单位为天)
|
|
34
|
+
* @typedef {Object} DurationMaxDayObject
|
|
35
|
+
* @property {number} days - 天数
|
|
36
|
+
* @property {number} hours - 小时数(0-23)
|
|
37
|
+
* @property {number} minutes - 分钟数(0-59)
|
|
38
|
+
* @property {number} seconds - 秒数(0-59)
|
|
39
|
+
* @property {number} milliseconds - 毫秒数(0-999)
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* 时间持续对象(最大单位为小时)
|
|
43
|
+
* @typedef {Object} DurationMaxHourObject
|
|
44
|
+
* @property {number} hours - 小时数
|
|
45
|
+
* @property {number} minutes - 分钟数(0-59)
|
|
46
|
+
* @property {number} seconds - 秒数(0-59)
|
|
47
|
+
* @property {number} milliseconds - 毫秒数(0-999)
|
|
48
|
+
*/
|
|
60
49
|
/**
|
|
61
|
-
*
|
|
50
|
+
* 将毫秒转换为时间持续对象。
|
|
62
51
|
*
|
|
63
|
-
* @param {number}
|
|
64
|
-
* @param {
|
|
65
|
-
* @
|
|
52
|
+
* @param {number} milliseconds - 毫秒数(非负整数)
|
|
53
|
+
* @param {Object} [options] - 选项对象。
|
|
54
|
+
* @param {number} [options.yearDays=365] - 一年的天数。
|
|
55
|
+
* @param {number} [options.monthDays=30] - 一月的天数。
|
|
56
|
+
* @returns {DurationObject} 时间持续对象
|
|
57
|
+
* @throws {TypeError} 当 milliseconds 不是有效数字
|
|
58
|
+
* @throws {RangeError} 当 milliseconds 为负数
|
|
59
|
+
* @throws {RangeError} 当 yearDays 或 monthDays 不是正整数
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // 基本用法
|
|
63
|
+
* millisecond2Duration(42070000500);
|
|
64
|
+
* // 返回: { years: 1, months: 4, days: 1, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
65
|
+
*/
|
|
66
|
+
declare function millisecond2Duration(milliseconds: number, options?: {
|
|
67
|
+
yearDays?: number | undefined;
|
|
68
|
+
monthDays?: number | undefined;
|
|
69
|
+
}): DurationObject;
|
|
70
|
+
/**
|
|
71
|
+
* 将毫秒转换为时间持续对象(最大单位为天)。
|
|
72
|
+
* @param {number} milliseconds - 毫秒数(非负整数)
|
|
73
|
+
* @returns {DurationMaxDayObject} 包含天、小时、分钟、秒、毫秒的时间持续对象
|
|
74
|
+
* @throws {TypeError} 当 milliseconds 不是有效数字时抛出
|
|
75
|
+
* @throws {RangeError} 当 milliseconds 为负数时抛出
|
|
76
|
+
* @example
|
|
77
|
+
* // 返回 { days: 486, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
78
|
+
* millisecond2DurationMaxDay(42070000500);
|
|
66
79
|
*/
|
|
67
|
-
declare function
|
|
80
|
+
declare function millisecond2DurationMaxDay(milliseconds: number): DurationMaxDayObject;
|
|
68
81
|
/**
|
|
69
|
-
*
|
|
82
|
+
* 将毫秒转换为时间持续对象(最大单位为小时)。
|
|
83
|
+
* @param {number} milliseconds - 毫秒数(非负整数)
|
|
84
|
+
* @returns {DurationMaxHourObject} 包含小时、分钟、秒、毫秒的时间持续对象
|
|
85
|
+
* @throws {TypeError} 当 milliseconds 不是有效数字时抛出
|
|
86
|
+
* @throws {RangeError} 当 milliseconds 为负数时抛出
|
|
87
|
+
* @example
|
|
88
|
+
* // 返回 { hours: 11686, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
89
|
+
* millisecond2DurationMaxHour(42070000500);
|
|
90
|
+
*/
|
|
91
|
+
declare function millisecond2DurationMaxHour(milliseconds: number): DurationMaxHourObject;
|
|
92
|
+
/**
|
|
93
|
+
* 将秒转换为时间持续对象。
|
|
94
|
+
*
|
|
95
|
+
* @param {number} seconds - 秒数(非负整数)
|
|
96
|
+
* @param {Object} [options] - 选项对象。
|
|
97
|
+
* @param {number} [options.yearDays=365] - 一年的天数。
|
|
98
|
+
* @param {number} [options.monthDays=30] - 一月的天数。
|
|
99
|
+
* @returns {DurationObject} 时间持续对象
|
|
100
|
+
* @throws {TypeError} 当 seconds 不是有效数字
|
|
101
|
+
* @throws {RangeError} 当 seconds 为负数
|
|
102
|
+
* @throws {RangeError} 当 yearDays 或 monthDays 不是正整数
|
|
70
103
|
*
|
|
71
|
-
* @
|
|
72
|
-
*
|
|
73
|
-
*
|
|
104
|
+
* @example
|
|
105
|
+
* // 基本用法
|
|
106
|
+
* second2Duration(42070000.5);
|
|
107
|
+
* // 返回: { years: 1, months: 4, days: 1, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
74
108
|
*/
|
|
75
|
-
declare function
|
|
109
|
+
declare function second2Duration(seconds: number, options?: {
|
|
110
|
+
yearDays?: number | undefined;
|
|
111
|
+
monthDays?: number | undefined;
|
|
112
|
+
}): DurationObject;
|
|
113
|
+
/**
|
|
114
|
+
* 将秒转换为时间持续对象(最大单位为天)。
|
|
115
|
+
* @param {number} seconds - 秒数(非负整数)
|
|
116
|
+
* @returns {DurationMaxDayObject} 包含天、小时、分钟、秒、毫秒的时间持续对象
|
|
117
|
+
* @throws {TypeError} 当 seconds 不是有效数字时抛出
|
|
118
|
+
* @throws {RangeError} 当 seconds 为负数时抛出
|
|
119
|
+
* @example
|
|
120
|
+
* // 返回 { days: 486, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
121
|
+
* second2DurationMaxDay(42070000.5);
|
|
122
|
+
*/
|
|
123
|
+
declare function second2DurationMaxDay(seconds: number): DurationMaxDayObject;
|
|
124
|
+
/**
|
|
125
|
+
* 将秒转换为时间持续对象(最大单位为小时)。
|
|
126
|
+
* @param {number} seconds - 秒数(非负整数)
|
|
127
|
+
* @returns {DurationMaxHourObject} 包含小时、分钟、秒、毫秒的时间持续对象
|
|
128
|
+
* @throws {TypeError} 当 seconds 不是有效数字时抛出
|
|
129
|
+
* @throws {RangeError} 当 seconds 为负数时抛出
|
|
130
|
+
* @example
|
|
131
|
+
* // 返回 { hours: 11686, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
132
|
+
* second2DurationMaxHour(42070000.5);
|
|
133
|
+
*/
|
|
134
|
+
declare function second2DurationMaxHour(seconds: number): DurationMaxHourObject;
|
|
76
135
|
/**
|
|
77
136
|
* 根据小时数返回对应的时间段名称。
|
|
78
137
|
*
|
|
@@ -132,5 +191,85 @@ declare function formatTimeForLocale(timestamp: number, locales?: {
|
|
|
132
191
|
} | undefined;
|
|
133
192
|
weekDays?: string[] | undefined;
|
|
134
193
|
}): string;
|
|
194
|
+
/**
|
|
195
|
+
* 时间持续对象(完整版本,包含年月日时分秒毫秒)
|
|
196
|
+
*/
|
|
197
|
+
type DurationObject = {
|
|
198
|
+
/**
|
|
199
|
+
* - 年数
|
|
200
|
+
*/
|
|
201
|
+
years: number;
|
|
202
|
+
/**
|
|
203
|
+
* - 月数(0-11)
|
|
204
|
+
*/
|
|
205
|
+
months: number;
|
|
206
|
+
/**
|
|
207
|
+
* - 天数(0-29,取决于 monthDays)
|
|
208
|
+
*/
|
|
209
|
+
days: number;
|
|
210
|
+
/**
|
|
211
|
+
* - 小时数(0-23)
|
|
212
|
+
*/
|
|
213
|
+
hours: number;
|
|
214
|
+
/**
|
|
215
|
+
* - 分钟数(0-59)
|
|
216
|
+
*/
|
|
217
|
+
minutes: number;
|
|
218
|
+
/**
|
|
219
|
+
* - 秒数(0-59)
|
|
220
|
+
*/
|
|
221
|
+
seconds: number;
|
|
222
|
+
/**
|
|
223
|
+
* - 毫秒数(0-999)
|
|
224
|
+
*/
|
|
225
|
+
milliseconds: number;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* 时间持续对象(最大单位为天)
|
|
229
|
+
*/
|
|
230
|
+
type DurationMaxDayObject = {
|
|
231
|
+
/**
|
|
232
|
+
* - 天数
|
|
233
|
+
*/
|
|
234
|
+
days: number;
|
|
235
|
+
/**
|
|
236
|
+
* - 小时数(0-23)
|
|
237
|
+
*/
|
|
238
|
+
hours: number;
|
|
239
|
+
/**
|
|
240
|
+
* - 分钟数(0-59)
|
|
241
|
+
*/
|
|
242
|
+
minutes: number;
|
|
243
|
+
/**
|
|
244
|
+
* - 秒数(0-59)
|
|
245
|
+
*/
|
|
246
|
+
seconds: number;
|
|
247
|
+
/**
|
|
248
|
+
* - 毫秒数(0-999)
|
|
249
|
+
*/
|
|
250
|
+
milliseconds: number;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* 时间持续对象(最大单位为小时)
|
|
254
|
+
*/
|
|
255
|
+
type DurationMaxHourObject = {
|
|
256
|
+
/**
|
|
257
|
+
* - 小时数
|
|
258
|
+
*/
|
|
259
|
+
hours: number;
|
|
260
|
+
/**
|
|
261
|
+
* - 分钟数(0-59)
|
|
262
|
+
*/
|
|
263
|
+
minutes: number;
|
|
264
|
+
/**
|
|
265
|
+
* - 秒数(0-59)
|
|
266
|
+
*/
|
|
267
|
+
seconds: number;
|
|
268
|
+
/**
|
|
269
|
+
* - 毫秒数(0-999)
|
|
270
|
+
*/
|
|
271
|
+
milliseconds: number;
|
|
272
|
+
};
|
|
135
273
|
|
|
136
|
-
export {
|
|
274
|
+
export { formatTimeForLocale, getTimePeriodName, millisecond2Duration, millisecond2DurationMaxDay, millisecond2DurationMaxHour, randomDateInRange, second2Duration, second2DurationMaxDay, second2DurationMaxHour, toDate };
|
|
275
|
+
export type { DurationMaxDayObject, DurationMaxHourObject, DurationObject };
|
package/types/index.d.ts
CHANGED
|
@@ -464,60 +464,119 @@ declare function toDate(val: any): Date | null;
|
|
|
464
464
|
*/
|
|
465
465
|
declare function randomDateInRange(date1: Date, date2: Date): Date;
|
|
466
466
|
/**
|
|
467
|
-
*
|
|
467
|
+
* 时间持续对象(完整版本,包含年月日时分秒毫秒)
|
|
468
|
+
* @typedef {Object} DurationObject
|
|
469
|
+
* @property {number} years - 年数
|
|
470
|
+
* @property {number} months - 月数(0-11)
|
|
471
|
+
* @property {number} days - 天数(0-29,取决于 monthDays)
|
|
472
|
+
* @property {number} hours - 小时数(0-23)
|
|
473
|
+
* @property {number} minutes - 分钟数(0-59)
|
|
474
|
+
* @property {number} seconds - 秒数(0-59)
|
|
475
|
+
* @property {number} milliseconds - 毫秒数(0-999)
|
|
476
|
+
*/
|
|
477
|
+
/**
|
|
478
|
+
* 时间持续对象(最大单位为天)
|
|
479
|
+
* @typedef {Object} DurationMaxDayObject
|
|
480
|
+
* @property {number} days - 天数
|
|
481
|
+
* @property {number} hours - 小时数(0-23)
|
|
482
|
+
* @property {number} minutes - 分钟数(0-59)
|
|
483
|
+
* @property {number} seconds - 秒数(0-59)
|
|
484
|
+
* @property {number} milliseconds - 毫秒数(0-999)
|
|
485
|
+
*/
|
|
486
|
+
/**
|
|
487
|
+
* 时间持续对象(最大单位为小时)
|
|
488
|
+
* @typedef {Object} DurationMaxHourObject
|
|
489
|
+
* @property {number} hours - 小时数
|
|
490
|
+
* @property {number} minutes - 分钟数(0-59)
|
|
491
|
+
* @property {number} seconds - 秒数(0-59)
|
|
492
|
+
* @property {number} milliseconds - 毫秒数(0-999)
|
|
493
|
+
*/
|
|
494
|
+
/**
|
|
495
|
+
* 将毫秒转换为时间持续对象。
|
|
496
|
+
*
|
|
497
|
+
* @param {number} milliseconds - 毫秒数(非负整数)
|
|
498
|
+
* @param {Object} [options] - 选项对象。
|
|
499
|
+
* @param {number} [options.yearDays=365] - 一年的天数。
|
|
500
|
+
* @param {number} [options.monthDays=30] - 一月的天数。
|
|
501
|
+
* @returns {DurationObject} 时间持续对象
|
|
502
|
+
* @throws {TypeError} 当 milliseconds 不是有效数字
|
|
503
|
+
* @throws {RangeError} 当 milliseconds 为负数
|
|
504
|
+
* @throws {RangeError} 当 yearDays 或 monthDays 不是正整数
|
|
468
505
|
*
|
|
469
|
-
* @
|
|
470
|
-
*
|
|
471
|
-
*
|
|
506
|
+
* @example
|
|
507
|
+
* // 基本用法
|
|
508
|
+
* millisecond2Duration(42070000500);
|
|
509
|
+
* // 返回: { years: 1, months: 4, days: 1, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
510
|
+
*/
|
|
511
|
+
declare function millisecond2Duration(milliseconds: number, options?: {
|
|
512
|
+
yearDays?: number | undefined;
|
|
513
|
+
monthDays?: number | undefined;
|
|
514
|
+
}): DurationObject;
|
|
515
|
+
/**
|
|
516
|
+
* 将毫秒转换为时间持续对象(最大单位为天)。
|
|
517
|
+
* @param {number} milliseconds - 毫秒数(非负整数)
|
|
518
|
+
* @returns {DurationMaxDayObject} 包含天、小时、分钟、秒、毫秒的时间持续对象
|
|
519
|
+
* @throws {TypeError} 当 milliseconds 不是有效数字时抛出
|
|
520
|
+
* @throws {RangeError} 当 milliseconds 为负数时抛出
|
|
521
|
+
* @example
|
|
522
|
+
* // 返回 { days: 486, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
523
|
+
* millisecond2DurationMaxDay(42070000500);
|
|
472
524
|
*/
|
|
473
|
-
declare function
|
|
474
|
-
days: number;
|
|
475
|
-
hours: string;
|
|
476
|
-
minutes: string;
|
|
477
|
-
seconds: string;
|
|
478
|
-
};
|
|
525
|
+
declare function millisecond2DurationMaxDay(milliseconds: number): DurationMaxDayObject;
|
|
479
526
|
/**
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
* @
|
|
484
|
-
* @
|
|
485
|
-
* @
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
* @throws {TypeError} 当 totalSeconds 为非数字或负数时抛出
|
|
491
|
-
*/
|
|
492
|
-
declare function formatDuration(totalSeconds: number, options?: {
|
|
493
|
-
labels?: Partial<{
|
|
494
|
-
year: string;
|
|
495
|
-
month: string;
|
|
496
|
-
day: string;
|
|
497
|
-
hour: string;
|
|
498
|
-
minute: string;
|
|
499
|
-
second: string;
|
|
500
|
-
}> | undefined;
|
|
501
|
-
maxUnit?: "year" | "month" | "day" | "hour" | "minute" | "second" | undefined;
|
|
502
|
-
minUnit?: "year" | "month" | "day" | "hour" | "minute" | "second" | undefined;
|
|
503
|
-
showZero?: boolean | undefined;
|
|
504
|
-
}): string;
|
|
527
|
+
* 将毫秒转换为时间持续对象(最大单位为小时)。
|
|
528
|
+
* @param {number} milliseconds - 毫秒数(非负整数)
|
|
529
|
+
* @returns {DurationMaxHourObject} 包含小时、分钟、秒、毫秒的时间持续对象
|
|
530
|
+
* @throws {TypeError} 当 milliseconds 不是有效数字时抛出
|
|
531
|
+
* @throws {RangeError} 当 milliseconds 为负数时抛出
|
|
532
|
+
* @example
|
|
533
|
+
* // 返回 { hours: 11686, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
534
|
+
* millisecond2DurationMaxHour(42070000500);
|
|
535
|
+
*/
|
|
536
|
+
declare function millisecond2DurationMaxHour(milliseconds: number): DurationMaxHourObject;
|
|
505
537
|
/**
|
|
506
|
-
*
|
|
538
|
+
* 将秒转换为时间持续对象。
|
|
507
539
|
*
|
|
508
|
-
* @param {number}
|
|
509
|
-
* @param {
|
|
510
|
-
* @
|
|
540
|
+
* @param {number} seconds - 秒数(非负整数)
|
|
541
|
+
* @param {Object} [options] - 选项对象。
|
|
542
|
+
* @param {number} [options.yearDays=365] - 一年的天数。
|
|
543
|
+
* @param {number} [options.monthDays=30] - 一月的天数。
|
|
544
|
+
* @returns {DurationObject} 时间持续对象
|
|
545
|
+
* @throws {TypeError} 当 seconds 不是有效数字
|
|
546
|
+
* @throws {RangeError} 当 seconds 为负数
|
|
547
|
+
* @throws {RangeError} 当 yearDays 或 monthDays 不是正整数
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* // 基本用法
|
|
551
|
+
* second2Duration(42070000.5);
|
|
552
|
+
* // 返回: { years: 1, months: 4, days: 1, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
553
|
+
*/
|
|
554
|
+
declare function second2Duration(seconds: number, options?: {
|
|
555
|
+
yearDays?: number | undefined;
|
|
556
|
+
monthDays?: number | undefined;
|
|
557
|
+
}): DurationObject;
|
|
558
|
+
/**
|
|
559
|
+
* 将秒转换为时间持续对象(最大单位为天)。
|
|
560
|
+
* @param {number} seconds - 秒数(非负整数)
|
|
561
|
+
* @returns {DurationMaxDayObject} 包含天、小时、分钟、秒、毫秒的时间持续对象
|
|
562
|
+
* @throws {TypeError} 当 seconds 不是有效数字时抛出
|
|
563
|
+
* @throws {RangeError} 当 seconds 为负数时抛出
|
|
564
|
+
* @example
|
|
565
|
+
* // 返回 { days: 486, hours: 22, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
566
|
+
* second2DurationMaxDay(42070000.5);
|
|
511
567
|
*/
|
|
512
|
-
declare function
|
|
568
|
+
declare function second2DurationMaxDay(seconds: number): DurationMaxDayObject;
|
|
513
569
|
/**
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* @
|
|
517
|
-
* @
|
|
518
|
-
* @
|
|
570
|
+
* 将秒转换为时间持续对象(最大单位为小时)。
|
|
571
|
+
* @param {number} seconds - 秒数(非负整数)
|
|
572
|
+
* @returns {DurationMaxHourObject} 包含小时、分钟、秒、毫秒的时间持续对象
|
|
573
|
+
* @throws {TypeError} 当 seconds 不是有效数字时抛出
|
|
574
|
+
* @throws {RangeError} 当 seconds 为负数时抛出
|
|
575
|
+
* @example
|
|
576
|
+
* // 返回 { hours: 11686, minutes: 6, seconds: 40, milliseconds: 500 }
|
|
577
|
+
* second2DurationMaxHour(42070000.5);
|
|
519
578
|
*/
|
|
520
|
-
declare function
|
|
579
|
+
declare function second2DurationMaxHour(seconds: number): DurationMaxHourObject;
|
|
521
580
|
/**
|
|
522
581
|
* 根据小时数返回对应的时间段名称。
|
|
523
582
|
*
|
|
@@ -577,6 +636,85 @@ declare function formatTimeForLocale(timestamp: number, locales?: {
|
|
|
577
636
|
} | undefined;
|
|
578
637
|
weekDays?: string[] | undefined;
|
|
579
638
|
}): string;
|
|
639
|
+
/**
|
|
640
|
+
* 时间持续对象(完整版本,包含年月日时分秒毫秒)
|
|
641
|
+
*/
|
|
642
|
+
type DurationObject = {
|
|
643
|
+
/**
|
|
644
|
+
* - 年数
|
|
645
|
+
*/
|
|
646
|
+
years: number;
|
|
647
|
+
/**
|
|
648
|
+
* - 月数(0-11)
|
|
649
|
+
*/
|
|
650
|
+
months: number;
|
|
651
|
+
/**
|
|
652
|
+
* - 天数(0-29,取决于 monthDays)
|
|
653
|
+
*/
|
|
654
|
+
days: number;
|
|
655
|
+
/**
|
|
656
|
+
* - 小时数(0-23)
|
|
657
|
+
*/
|
|
658
|
+
hours: number;
|
|
659
|
+
/**
|
|
660
|
+
* - 分钟数(0-59)
|
|
661
|
+
*/
|
|
662
|
+
minutes: number;
|
|
663
|
+
/**
|
|
664
|
+
* - 秒数(0-59)
|
|
665
|
+
*/
|
|
666
|
+
seconds: number;
|
|
667
|
+
/**
|
|
668
|
+
* - 毫秒数(0-999)
|
|
669
|
+
*/
|
|
670
|
+
milliseconds: number;
|
|
671
|
+
};
|
|
672
|
+
/**
|
|
673
|
+
* 时间持续对象(最大单位为天)
|
|
674
|
+
*/
|
|
675
|
+
type DurationMaxDayObject = {
|
|
676
|
+
/**
|
|
677
|
+
* - 天数
|
|
678
|
+
*/
|
|
679
|
+
days: number;
|
|
680
|
+
/**
|
|
681
|
+
* - 小时数(0-23)
|
|
682
|
+
*/
|
|
683
|
+
hours: number;
|
|
684
|
+
/**
|
|
685
|
+
* - 分钟数(0-59)
|
|
686
|
+
*/
|
|
687
|
+
minutes: number;
|
|
688
|
+
/**
|
|
689
|
+
* - 秒数(0-59)
|
|
690
|
+
*/
|
|
691
|
+
seconds: number;
|
|
692
|
+
/**
|
|
693
|
+
* - 毫秒数(0-999)
|
|
694
|
+
*/
|
|
695
|
+
milliseconds: number;
|
|
696
|
+
};
|
|
697
|
+
/**
|
|
698
|
+
* 时间持续对象(最大单位为小时)
|
|
699
|
+
*/
|
|
700
|
+
type DurationMaxHourObject = {
|
|
701
|
+
/**
|
|
702
|
+
* - 小时数
|
|
703
|
+
*/
|
|
704
|
+
hours: number;
|
|
705
|
+
/**
|
|
706
|
+
* - 分钟数(0-59)
|
|
707
|
+
*/
|
|
708
|
+
minutes: number;
|
|
709
|
+
/**
|
|
710
|
+
* - 秒数(0-59)
|
|
711
|
+
*/
|
|
712
|
+
seconds: number;
|
|
713
|
+
/**
|
|
714
|
+
* - 毫秒数(0-999)
|
|
715
|
+
*/
|
|
716
|
+
milliseconds: number;
|
|
717
|
+
};
|
|
580
718
|
|
|
581
719
|
/**
|
|
582
720
|
* 通过动态创建 `<a>` 标签触发浏览器下载。
|
|
@@ -761,4 +899,4 @@ declare function extractFullyCheckedKeys(treeData: any[], selectedKeys: any[], i
|
|
|
761
899
|
};
|
|
762
900
|
declare function findObjAttrValueById<T>(id: string | number, arr: T[], resultKey?: string, idKey?: string, childrenKey?: string): any;
|
|
763
901
|
|
|
764
|
-
export { AudioStreamResampler, IntervalTimer, MyEvent, MyEvent_CrossPagePlugin, MyId, WebSocketManager, assignExisting,
|
|
902
|
+
export { AudioStreamResampler, IntervalTimer, MyEvent, MyEvent_CrossPagePlugin, MyId, WebSocketManager, assignExisting, debounce, deepCloneByJSON, downloadByBlob, downloadByData, downloadByUrl, downloadExcel, downloadJSON, extractFullyCheckedKeys, fetchOrDownloadByUrl, findObjAttrValueById, flatCompleteTree2NestedTree, formatTimeForLocale, getAllSearchParams, getDataType, getFunctionArgNames, getGUID, getSearchParam, getTimePeriodName, getViewportSize, isBlob, isDate, isFunction, isNonEmptyString, isPlainObject, isPromise, millisecond2Duration, millisecond2DurationMaxDay, millisecond2DurationMaxHour, moveItem, nestedTree2IdMap, pcmToWavBlob, randomDateInRange, randomEnLetter, randomHan, randomHanOrEn, randomIntInRange, readBlobAsText, second2Duration, second2DurationMaxDay, second2DurationMaxHour, shuffle, throttle, toDate };
|