nhb-toolbox 3.6.2 → 3.6.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/date/Chronos.d.ts +99 -13
- package/dist/date/Chronos.d.ts.map +1 -1
- package/dist/date/Chronos.js +276 -12
- package/dist/date/types.d.ts +2 -0
- package/dist/date/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +15 -0
- package/package.json +1 -1
package/dist/date/Chronos.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export declare class Chronos {
|
|
|
18
18
|
* @returns The primitive value based on the hint.
|
|
19
19
|
*/
|
|
20
20
|
[Symbol.toPrimitive](hint: string): string | number;
|
|
21
|
+
/** * Clones and returns a new Chronos instance with the same date. */
|
|
22
|
+
clone(): Chronos;
|
|
21
23
|
/** * Enables JSON.stringify and console logging to show readable output. */
|
|
22
24
|
toJSON(): string;
|
|
23
25
|
/** * Enables arithmetic and comparison operations (e.g., +new Chronos()). */
|
|
@@ -58,7 +60,7 @@ export declare class Chronos {
|
|
|
58
60
|
* * Formats the date into a custom string format (local time).
|
|
59
61
|
*
|
|
60
62
|
* @param format - The desired format (Default format is `dd, MMM DD, YYYY HH:mm:ss:mss` = `Sun, Apr 06, 2025 16:11:55:379`).
|
|
61
|
-
* @param useUTC - Optional `useUTC` to get the formatted time using UTC Offset, defaults to `false`.
|
|
63
|
+
* @param useUTC - Optional `useUTC` to get the formatted time using UTC Offset, defaults to `false`. Equivalent to `formatUTC()` method if set to `true`.
|
|
62
64
|
* @returns Formatted date string in desired format (in local time unless `useUTC` passed as `true`).
|
|
63
65
|
*/
|
|
64
66
|
format(format?: string, useUTC?: boolean): string;
|
|
@@ -69,12 +71,42 @@ export declare class Chronos {
|
|
|
69
71
|
* @returns Formatted date string in desired format (UTC time).
|
|
70
72
|
*/
|
|
71
73
|
formatUTC(format?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* * Adds seconds and returns a new immutable instance.
|
|
76
|
+
* @param seconds - Number of seconds to add.
|
|
77
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
78
|
+
*/
|
|
79
|
+
addSeconds(seconds: number): Chronos;
|
|
80
|
+
/**
|
|
81
|
+
* * Adds minutes and returns a new immutable instance.
|
|
82
|
+
* @param minutes - Number of minutes to add.
|
|
83
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
84
|
+
*/
|
|
85
|
+
addMinutes(minutes: number): Chronos;
|
|
86
|
+
/**
|
|
87
|
+
* * Adds hours and returns a new immutable instance.
|
|
88
|
+
* @param hours - Number of hours to add.
|
|
89
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
90
|
+
*/
|
|
91
|
+
addHours(hours: number): Chronos;
|
|
72
92
|
/**
|
|
73
93
|
* * Adds days and returns a new immutable instance.
|
|
74
94
|
* @param days - Number of days to add.
|
|
75
95
|
* @returns A new `Chronos` instance with the updated date.
|
|
76
96
|
*/
|
|
77
97
|
addDays(days: number): Chronos;
|
|
98
|
+
/**
|
|
99
|
+
* * Adds months and returns a new immutable instance.
|
|
100
|
+
* @param months - Number of months to add.
|
|
101
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
102
|
+
*/
|
|
103
|
+
addMonths(months: number): Chronos;
|
|
104
|
+
/**
|
|
105
|
+
* * Adds years and returns a new immutable instance.
|
|
106
|
+
* @param years - Number of years to add.
|
|
107
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
108
|
+
*/
|
|
109
|
+
addYears(years: number): Chronos;
|
|
78
110
|
/**
|
|
79
111
|
* * Subtracts days and returns a new immutable instance.
|
|
80
112
|
* @param days - Number of days to subtract.
|
|
@@ -102,23 +134,26 @@ export declare class Chronos {
|
|
|
102
134
|
/** - Checks if the current date is yesterday. */
|
|
103
135
|
isYesterday(): boolean;
|
|
104
136
|
/**
|
|
105
|
-
* * Returns full time difference from now (or specified time)
|
|
106
|
-
*
|
|
107
|
-
* @
|
|
137
|
+
* * Returns full time difference from now (or a specified time) down to a given level.
|
|
138
|
+
*
|
|
139
|
+
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `minute`.
|
|
140
|
+
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
141
|
+
* @param time An optional time value to compare with (`string`, `number`, `Date`, or `Chronos` instance). Defaults to `now`.
|
|
142
|
+
* @returns The difference as a human-readable string, e.g., `2 years 1 month 9 days 18 hours 56 minutes ago`.
|
|
108
143
|
*/
|
|
109
|
-
fromNow(time?:
|
|
144
|
+
fromNow(level?: Exclude<TimeUnit, 'millisecond'>, withSuffixPrefix?: boolean, time?: number | string | Date | Chronos): string;
|
|
110
145
|
/**
|
|
111
146
|
* * Returns the number of full years between the input date and now.
|
|
112
147
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
113
148
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
114
149
|
*/
|
|
115
|
-
getRelativeYear(time?:
|
|
150
|
+
getRelativeYear(time?: number | string | Date | Chronos): number;
|
|
116
151
|
/**
|
|
117
152
|
* * Returns the number of full months between the input date and now.
|
|
118
153
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
119
154
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
120
155
|
*/
|
|
121
|
-
getRelativeMonth(time?:
|
|
156
|
+
getRelativeMonth(time?: number | string | Date | Chronos): number;
|
|
122
157
|
/**
|
|
123
158
|
* * Determines if the given date is today, tomorrow, yesterday or any relative day.
|
|
124
159
|
* @param date - The date to compare (Date object).
|
|
@@ -129,31 +164,31 @@ export declare class Chronos {
|
|
|
129
164
|
* - `1` if the date is tomorrow.
|
|
130
165
|
* - Other positive or negative numbers for other relative days (e.g., `-2` for two days ago, `2` for two days ahead).
|
|
131
166
|
*/
|
|
132
|
-
getRelativeDay(time?:
|
|
167
|
+
getRelativeDay(time?: number | string | Date | Chronos): number;
|
|
133
168
|
/**
|
|
134
169
|
* * Returns the number of full hours between the input date and now.
|
|
135
170
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
136
171
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
137
172
|
*/
|
|
138
|
-
getRelativeHour(time?:
|
|
173
|
+
getRelativeHour(time?: number | string | Date | Chronos): number;
|
|
139
174
|
/**
|
|
140
175
|
* * Returns the number of full minutes between the input date and now.
|
|
141
176
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
142
177
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
143
178
|
*/
|
|
144
|
-
getRelativeMinute(time?:
|
|
179
|
+
getRelativeMinute(time?: number | string | Date | Chronos): number;
|
|
145
180
|
/**
|
|
146
181
|
* * Returns the number of full seconds between the input date and now.
|
|
147
182
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
148
183
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
149
184
|
*/
|
|
150
|
-
getRelativeSecond(time?:
|
|
185
|
+
getRelativeSecond(time?: number | string | Date | Chronos): number;
|
|
151
186
|
/**
|
|
152
187
|
* * Returns the number of milliseconds between the input date and now.
|
|
153
188
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
154
189
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
155
190
|
*/
|
|
156
|
-
getRelativeMilliSecond(time?:
|
|
191
|
+
getRelativeMilliSecond(time?: number | string | Date | Chronos): number;
|
|
157
192
|
/**
|
|
158
193
|
* * Compares the stored date with now, returning the difference in the specified unit.
|
|
159
194
|
*
|
|
@@ -161,6 +196,57 @@ export declare class Chronos {
|
|
|
161
196
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
162
197
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
163
198
|
*/
|
|
164
|
-
compare(unit?: TimeUnit, time?:
|
|
199
|
+
compare(unit?: TimeUnit, time?: number | string | Date | Chronos): number;
|
|
200
|
+
/**
|
|
201
|
+
* * Returns a new Chronos instance at the start of a given unit.
|
|
202
|
+
* @param unit The unit to reset (e.g., year, month, day).
|
|
203
|
+
*/
|
|
204
|
+
startOf(unit: TimeUnit): Chronos;
|
|
205
|
+
/**
|
|
206
|
+
* * Returns a new Chronos instance at the end of a given unit.
|
|
207
|
+
* @param unit The unit to adjust (e.g., year, month, day).
|
|
208
|
+
*/
|
|
209
|
+
endOf(unit: TimeUnit): Chronos;
|
|
210
|
+
/**
|
|
211
|
+
* * Returns a new Chronos instance with the specified unit added.
|
|
212
|
+
* @param amount The amount to add (can be negative).
|
|
213
|
+
* @param unit The time unit to add.
|
|
214
|
+
*/
|
|
215
|
+
add(amount: number, unit: TimeUnit): Chronos;
|
|
216
|
+
/**
|
|
217
|
+
* * Gets the value of a specific time unit from the date.
|
|
218
|
+
* @param unit The unit to retrieve.
|
|
219
|
+
*/
|
|
220
|
+
get(unit: TimeUnit): number;
|
|
221
|
+
/**
|
|
222
|
+
* Returns a new Chronos instance with the specified unit set to the given value.
|
|
223
|
+
* @param unit The unit to modify.
|
|
224
|
+
* @param value The value to set for the unit.
|
|
225
|
+
*/
|
|
226
|
+
set(unit: TimeUnit, value: number): Chronos;
|
|
227
|
+
/**
|
|
228
|
+
* * Returns the difference between this and another date in the given unit.
|
|
229
|
+
* @param other The other date to compare.
|
|
230
|
+
* @param unit The unit in which to return the difference.
|
|
231
|
+
*/
|
|
232
|
+
diff(other: number | string | Date | Chronos, unit: TimeUnit): number;
|
|
233
|
+
/**
|
|
234
|
+
* * Checks if another date is the same as this one in a specific unit.
|
|
235
|
+
* @param other The other date to compare.
|
|
236
|
+
* @param unit The unit to compare.
|
|
237
|
+
*/
|
|
238
|
+
isSame(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* * Checks if this date is before another date in a specific unit.
|
|
241
|
+
* @param other The other date to compare.
|
|
242
|
+
* @param unit The unit to compare.
|
|
243
|
+
*/
|
|
244
|
+
isBefore(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* * Checks if this date is after another date in a specific unit.
|
|
247
|
+
* @param other The other date to compare.
|
|
248
|
+
* @param unit The unit to compare.
|
|
249
|
+
*/
|
|
250
|
+
isAfter(other: number | string | Date | Chronos, unit: TimeUnit): boolean;
|
|
165
251
|
}
|
|
166
252
|
//# sourceMappingURL=Chronos.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB,qBAAa,OAAO;;IAInB;;;;;;;;OAQG;gBACS,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO;IAOpD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAED;;;;OAIG;IACH,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAKnD,4EAA4E;IAC5E,MAAM,IAAI,MAAM;IAIhB,6EAA6E;IAC7E,OAAO,IAAI,MAAM;IAIjB,qDAAqD;IACrD,MAAM,IAAI,IAAI;IAId,mGAAmG;IACnG,QAAQ,IAAI,MAAM;IAIlB,wDAAwD;IACxD,WAAW,IAAI,MAAM;IAIrB,oFAAoF;IACpF,YAAY,IAAI,MAAM;IAItB,mDAAmD;IACnD,IAAI,IAAI,IAAI,IAAI,CAEf;IAED,oFAAoF;IACpF,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM;IAOtC;;;;;OAKG;IACH,MAAM,CAAC,KAAK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C;;;;OAIG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO;IA8BnD;;;OAGG;IACI,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM;IAmBlC;;;;OAIG;IACI,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IA6BlD;;;;OAIG;IACI,IAAI,CACV,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EACvC,IAAI,EAAE,QAAQ,GACZ,MAAM;IA0BT;;;;OAIG;IACI,MAAM,CACZ,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EACvC,IAAI,EAAE,QAAQ,GACZ,OAAO;IASV;;;;OAIG;IACI,QAAQ,CACd,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EACvC,IAAI,EAAE,QAAQ,GACZ,OAAO;IASV;;;;OAIG;IACI,OAAO,CACb,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EACvC,IAAI,EAAE,QAAQ,GACZ,OAAO;CAQV"}
|
package/dist/date/Chronos.js
CHANGED
|
@@ -31,6 +31,10 @@ export class Chronos {
|
|
|
31
31
|
return this.valueOf();
|
|
32
32
|
return this.toString();
|
|
33
33
|
}
|
|
34
|
+
/** * Clones and returns a new Chronos instance with the same date. */
|
|
35
|
+
clone() {
|
|
36
|
+
return new Chronos(this.#date);
|
|
37
|
+
}
|
|
34
38
|
/** * Enables JSON.stringify and console logging to show readable output. */
|
|
35
39
|
toJSON() {
|
|
36
40
|
return this.toISOString();
|
|
@@ -180,7 +184,7 @@ export class Chronos {
|
|
|
180
184
|
* * Formats the date into a custom string format (local time).
|
|
181
185
|
*
|
|
182
186
|
* @param format - The desired format (Default format is `dd, MMM DD, YYYY HH:mm:ss:mss` = `Sun, Apr 06, 2025 16:11:55:379`).
|
|
183
|
-
* @param useUTC - Optional `useUTC` to get the formatted time using UTC Offset, defaults to `false`.
|
|
187
|
+
* @param useUTC - Optional `useUTC` to get the formatted time using UTC Offset, defaults to `false`. Equivalent to `formatUTC()` method if set to `true`.
|
|
184
188
|
* @returns Formatted date string in desired format (in local time unless `useUTC` passed as `true`).
|
|
185
189
|
*/
|
|
186
190
|
format(format = 'dd, MMM DD, YYYY HH:mm:ss:mss', useUTC = false) {
|
|
@@ -195,6 +199,36 @@ export class Chronos {
|
|
|
195
199
|
formatUTC(format = 'dd, MMM DD, YYYY HH:mm:ss:mss') {
|
|
196
200
|
return this.#format(format, true);
|
|
197
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* * Adds seconds and returns a new immutable instance.
|
|
204
|
+
* @param seconds - Number of seconds to add.
|
|
205
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
206
|
+
*/
|
|
207
|
+
addSeconds(seconds) {
|
|
208
|
+
const newDate = new Date(this.#date);
|
|
209
|
+
newDate.setSeconds(newDate.getSeconds() + seconds);
|
|
210
|
+
return new Chronos(newDate);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* * Adds minutes and returns a new immutable instance.
|
|
214
|
+
* @param minutes - Number of minutes to add.
|
|
215
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
216
|
+
*/
|
|
217
|
+
addMinutes(minutes) {
|
|
218
|
+
const newDate = new Date(this.#date);
|
|
219
|
+
newDate.setMinutes(newDate.getMinutes() + minutes);
|
|
220
|
+
return new Chronos(newDate);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* * Adds hours and returns a new immutable instance.
|
|
224
|
+
* @param hours - Number of hours to add.
|
|
225
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
226
|
+
*/
|
|
227
|
+
addHours(hours) {
|
|
228
|
+
const newDate = new Date(this.#date);
|
|
229
|
+
newDate.setHours(newDate.getHours() + hours);
|
|
230
|
+
return new Chronos(newDate);
|
|
231
|
+
}
|
|
198
232
|
/**
|
|
199
233
|
* * Adds days and returns a new immutable instance.
|
|
200
234
|
* @param days - Number of days to add.
|
|
@@ -205,6 +239,26 @@ export class Chronos {
|
|
|
205
239
|
newDate.setDate(newDate.getDate() + days);
|
|
206
240
|
return new Chronos(newDate);
|
|
207
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* * Adds months and returns a new immutable instance.
|
|
244
|
+
* @param months - Number of months to add.
|
|
245
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
246
|
+
*/
|
|
247
|
+
addMonths(months) {
|
|
248
|
+
const newDate = new Date(this.#date);
|
|
249
|
+
newDate.setMonth(newDate.getMonth() + months);
|
|
250
|
+
return new Chronos(newDate);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* * Adds years and returns a new immutable instance.
|
|
254
|
+
* @param years - Number of years to add.
|
|
255
|
+
* @returns A new `Chronos` instance with the updated date.
|
|
256
|
+
*/
|
|
257
|
+
addYears(years) {
|
|
258
|
+
const newDate = new Date(this.#date);
|
|
259
|
+
newDate.setFullYear(newDate.getFullYear() + years);
|
|
260
|
+
return new Chronos(newDate);
|
|
261
|
+
}
|
|
208
262
|
/**
|
|
209
263
|
* * Subtracts days and returns a new immutable instance.
|
|
210
264
|
* @param days - Number of days to subtract.
|
|
@@ -254,11 +308,14 @@ export class Chronos {
|
|
|
254
308
|
return this.getRelativeDay() === -1;
|
|
255
309
|
}
|
|
256
310
|
/**
|
|
257
|
-
* * Returns full time difference from now (or specified time)
|
|
258
|
-
*
|
|
259
|
-
* @
|
|
311
|
+
* * Returns full time difference from now (or a specified time) down to a given level.
|
|
312
|
+
*
|
|
313
|
+
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `minute`.
|
|
314
|
+
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
315
|
+
* @param time An optional time value to compare with (`string`, `number`, `Date`, or `Chronos` instance). Defaults to `now`.
|
|
316
|
+
* @returns The difference as a human-readable string, e.g., `2 years 1 month 9 days 18 hours 56 minutes ago`.
|
|
260
317
|
*/
|
|
261
|
-
fromNow(time) {
|
|
318
|
+
fromNow(level = 'minute', withSuffixPrefix = true, time) {
|
|
262
319
|
const now = this.#toNewDate(time);
|
|
263
320
|
const target = this.#date;
|
|
264
321
|
const isFuture = target > now;
|
|
@@ -292,20 +349,46 @@ export class Chronos {
|
|
|
292
349
|
months += 12;
|
|
293
350
|
years--;
|
|
294
351
|
}
|
|
352
|
+
const unitOrder = [
|
|
353
|
+
'year',
|
|
354
|
+
'month',
|
|
355
|
+
'day',
|
|
356
|
+
'hour',
|
|
357
|
+
'minute',
|
|
358
|
+
'second',
|
|
359
|
+
];
|
|
360
|
+
const lvlIdx = unitOrder.indexOf(level);
|
|
295
361
|
const parts = [];
|
|
296
|
-
if (years > 0)
|
|
362
|
+
if (lvlIdx >= 0 && years > 0 && lvlIdx >= unitOrder.indexOf('year')) {
|
|
297
363
|
parts.push(`${years} year${years > 1 ? 's' : ''}`);
|
|
298
|
-
|
|
364
|
+
}
|
|
365
|
+
if (lvlIdx >= unitOrder.indexOf('month') && months > 0) {
|
|
299
366
|
parts.push(`${months} month${months > 1 ? 's' : ''}`);
|
|
300
|
-
|
|
367
|
+
}
|
|
368
|
+
if (lvlIdx >= unitOrder.indexOf('day') && days > 0) {
|
|
301
369
|
parts.push(`${days} day${days > 1 ? 's' : ''}`);
|
|
302
|
-
|
|
370
|
+
}
|
|
371
|
+
if (lvlIdx >= unitOrder.indexOf('hour') && hours > 0) {
|
|
303
372
|
parts.push(`${hours} hour${hours > 1 ? 's' : ''}`);
|
|
304
|
-
|
|
373
|
+
}
|
|
374
|
+
if (lvlIdx >= unitOrder.indexOf('minute') && minutes > 0) {
|
|
305
375
|
parts.push(`${minutes} minute${minutes > 1 ? 's' : ''}`);
|
|
306
|
-
|
|
376
|
+
}
|
|
377
|
+
if (lvlIdx >= unitOrder.indexOf('second') &&
|
|
378
|
+
(seconds > 0 || parts.length === 0)) {
|
|
307
379
|
parts.push(`${seconds} second${seconds !== 1 ? 's' : ''}`);
|
|
308
|
-
|
|
380
|
+
}
|
|
381
|
+
let prefix = '';
|
|
382
|
+
let suffix = '';
|
|
383
|
+
if (withSuffixPrefix) {
|
|
384
|
+
if (isFuture) {
|
|
385
|
+
prefix = 'in ';
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
suffix = ' ago';
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return `${prefix}${parts.join(' ')}${suffix}`;
|
|
309
392
|
}
|
|
310
393
|
/**
|
|
311
394
|
* * Returns the number of full years between the input date and now.
|
|
@@ -421,4 +504,185 @@ export class Chronos {
|
|
|
421
504
|
throw new Error(`Unsupported time unit: ${unit}`);
|
|
422
505
|
}
|
|
423
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* * Returns a new Chronos instance at the start of a given unit.
|
|
509
|
+
* @param unit The unit to reset (e.g., year, month, day).
|
|
510
|
+
*/
|
|
511
|
+
startOf(unit) {
|
|
512
|
+
const d = new Date(this.#date);
|
|
513
|
+
switch (unit) {
|
|
514
|
+
case 'year':
|
|
515
|
+
d.setMonth(0, 1);
|
|
516
|
+
d.setHours(0, 0, 0, 0);
|
|
517
|
+
break;
|
|
518
|
+
case 'month':
|
|
519
|
+
d.setDate(1);
|
|
520
|
+
d.setHours(0, 0, 0, 0);
|
|
521
|
+
break;
|
|
522
|
+
case 'day':
|
|
523
|
+
d.setHours(0, 0, 0, 0);
|
|
524
|
+
break;
|
|
525
|
+
case 'hour':
|
|
526
|
+
d.setMinutes(0, 0, 0);
|
|
527
|
+
break;
|
|
528
|
+
case 'minute':
|
|
529
|
+
d.setSeconds(0, 0);
|
|
530
|
+
break;
|
|
531
|
+
case 'second':
|
|
532
|
+
d.setMilliseconds(0);
|
|
533
|
+
break;
|
|
534
|
+
case 'millisecond':
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
return new Chronos(d);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* * Returns a new Chronos instance at the end of a given unit.
|
|
541
|
+
* @param unit The unit to adjust (e.g., year, month, day).
|
|
542
|
+
*/
|
|
543
|
+
endOf(unit) {
|
|
544
|
+
return this.startOf(unit).add(1, unit).add(-1, 'millisecond');
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* * Returns a new Chronos instance with the specified unit added.
|
|
548
|
+
* @param amount The amount to add (can be negative).
|
|
549
|
+
* @param unit The time unit to add.
|
|
550
|
+
*/
|
|
551
|
+
add(amount, unit) {
|
|
552
|
+
const d = new Date(this.#date);
|
|
553
|
+
switch (unit) {
|
|
554
|
+
case 'millisecond':
|
|
555
|
+
d.setMilliseconds(d.getMilliseconds() + amount);
|
|
556
|
+
break;
|
|
557
|
+
case 'second':
|
|
558
|
+
d.setSeconds(d.getSeconds() + amount);
|
|
559
|
+
break;
|
|
560
|
+
case 'minute':
|
|
561
|
+
d.setMinutes(d.getMinutes() + amount);
|
|
562
|
+
break;
|
|
563
|
+
case 'hour':
|
|
564
|
+
d.setHours(d.getHours() + amount);
|
|
565
|
+
break;
|
|
566
|
+
case 'day':
|
|
567
|
+
d.setDate(d.getDate() + amount);
|
|
568
|
+
break;
|
|
569
|
+
case 'month':
|
|
570
|
+
d.setMonth(d.getMonth() + amount);
|
|
571
|
+
break;
|
|
572
|
+
case 'year':
|
|
573
|
+
d.setFullYear(d.getFullYear() + amount);
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
return new Chronos(d);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* * Gets the value of a specific time unit from the date.
|
|
580
|
+
* @param unit The unit to retrieve.
|
|
581
|
+
*/
|
|
582
|
+
get(unit) {
|
|
583
|
+
switch (unit) {
|
|
584
|
+
case 'year':
|
|
585
|
+
return this.#date.getFullYear();
|
|
586
|
+
case 'month':
|
|
587
|
+
return this.#date.getMonth();
|
|
588
|
+
case 'day':
|
|
589
|
+
return this.#date.getDate();
|
|
590
|
+
case 'hour':
|
|
591
|
+
return this.#date.getHours();
|
|
592
|
+
case 'minute':
|
|
593
|
+
return this.#date.getMinutes();
|
|
594
|
+
case 'second':
|
|
595
|
+
return this.#date.getSeconds();
|
|
596
|
+
case 'millisecond':
|
|
597
|
+
return this.#date.getMilliseconds();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Returns a new Chronos instance with the specified unit set to the given value.
|
|
602
|
+
* @param unit The unit to modify.
|
|
603
|
+
* @param value The value to set for the unit.
|
|
604
|
+
*/
|
|
605
|
+
set(unit, value) {
|
|
606
|
+
const d = new Date(this.#date);
|
|
607
|
+
switch (unit) {
|
|
608
|
+
case 'year':
|
|
609
|
+
d.setFullYear(value);
|
|
610
|
+
break;
|
|
611
|
+
case 'month':
|
|
612
|
+
d.setMonth(value);
|
|
613
|
+
break;
|
|
614
|
+
case 'day':
|
|
615
|
+
d.setDate(value);
|
|
616
|
+
break;
|
|
617
|
+
case 'hour':
|
|
618
|
+
d.setHours(value);
|
|
619
|
+
break;
|
|
620
|
+
case 'minute':
|
|
621
|
+
d.setMinutes(value);
|
|
622
|
+
break;
|
|
623
|
+
case 'second':
|
|
624
|
+
d.setSeconds(value);
|
|
625
|
+
break;
|
|
626
|
+
case 'millisecond':
|
|
627
|
+
d.setMilliseconds(value);
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
return new Chronos(d);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* * Returns the difference between this and another date in the given unit.
|
|
634
|
+
* @param other The other date to compare.
|
|
635
|
+
* @param unit The unit in which to return the difference.
|
|
636
|
+
*/
|
|
637
|
+
diff(other, unit) {
|
|
638
|
+
const time = new Chronos(other);
|
|
639
|
+
const msDiff = this.#date.getTime() - time.toDate().getTime();
|
|
640
|
+
switch (unit) {
|
|
641
|
+
case 'millisecond':
|
|
642
|
+
return msDiff;
|
|
643
|
+
case 'second':
|
|
644
|
+
return msDiff / 1e3;
|
|
645
|
+
case 'minute':
|
|
646
|
+
return msDiff / 6e4;
|
|
647
|
+
case 'hour':
|
|
648
|
+
return msDiff / 3.6e6;
|
|
649
|
+
case 'day':
|
|
650
|
+
return msDiff / 8.64e7;
|
|
651
|
+
case 'month':
|
|
652
|
+
return ((this.get('year') - time.get('year')) * 12 +
|
|
653
|
+
(this.get('month') - time.get('month')));
|
|
654
|
+
case 'year':
|
|
655
|
+
return this.get('year') - time.get('year');
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* * Checks if another date is the same as this one in a specific unit.
|
|
660
|
+
* @param other The other date to compare.
|
|
661
|
+
* @param unit The unit to compare.
|
|
662
|
+
*/
|
|
663
|
+
isSame(other, unit) {
|
|
664
|
+
const time = new Chronos(other);
|
|
665
|
+
return (this.startOf(unit).toDate().getTime() ===
|
|
666
|
+
time.startOf(unit).toDate().getTime());
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* * Checks if this date is before another date in a specific unit.
|
|
670
|
+
* @param other The other date to compare.
|
|
671
|
+
* @param unit The unit to compare.
|
|
672
|
+
*/
|
|
673
|
+
isBefore(other, unit) {
|
|
674
|
+
const time = new Chronos(other);
|
|
675
|
+
return (this.startOf(unit).toDate().getTime() <
|
|
676
|
+
time.startOf(unit).toDate().getTime());
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* * Checks if this date is after another date in a specific unit.
|
|
680
|
+
* @param other The other date to compare.
|
|
681
|
+
* @param unit The unit to compare.
|
|
682
|
+
*/
|
|
683
|
+
isAfter(other, unit) {
|
|
684
|
+
const time = new Chronos(other);
|
|
685
|
+
return (this.startOf(unit).toDate().getTime() >
|
|
686
|
+
time.startOf(unit).toDate().getTime());
|
|
687
|
+
}
|
|
424
688
|
}
|
package/dist/date/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Chronos } from './Chronos';
|
|
1
2
|
import type { DATE_FORMATS, DAY_FORMATS, HOUR_FORMATS, MILLISECOND_FORMATS, MINUTE_FORMATS, MONTH_FORMATS, SECOND_FORMATS, TIME_FORMATS, TIME_ZONES, YEAR_FORMATS } from './constants';
|
|
2
3
|
/** - Minute in numeric string from `00` to `23` */
|
|
3
4
|
export type Hours = '00' | '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17' | '18' | '19' | '20' | '21' | '22' | '23';
|
|
@@ -47,6 +48,7 @@ export type Second = (typeof SECOND_FORMATS)[number];
|
|
|
47
48
|
export type Millisecond = (typeof MILLISECOND_FORMATS)[number];
|
|
48
49
|
export type TimeFormats = (typeof TIME_FORMATS)[number];
|
|
49
50
|
export type ChronosFormat = Year | Month | Day | Date | Hour | Minute | Second | Millisecond | TimeFormats;
|
|
51
|
+
export type ChronosDate = number | string | Date | Chronos;
|
|
50
52
|
export type TimeZone = keyof typeof TIME_ZONES;
|
|
51
53
|
export type PositiveUTCHour = '+00' | '+01' | '+02' | '+03' | '+04' | '+05' | '+06' | '+07' | '+08' | '+09' | '+10' | '+11' | '+12' | '+13' | '+14';
|
|
52
54
|
export type NegativeUTCHour = '-00' | '-01' | '-02' | '-03' | '-04' | '-05' | '-06' | '-07' | '-08' | '-09' | '-10' | '-11' | '-12' | '-13' | '-14';
|
package/dist/date/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/date/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,MAAM,aAAa,CAAC;AAErB,mDAAmD;AACnD,MAAM,MAAM,KAAK,GACd,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GAC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K,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAET,MAAM,MAAM,eAAe,GACxB,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAET,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG,MAAM,eAAe,GAAG,eAAe,IAAI,SAAS,EAAE,CAAC;AAE/E,uBAAuB;AACvB,MAAM,WAAW,aAAa;IAC7B,+GAA+G;IAC/G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { convertObjectValues } from './object/convert';
|
|
|
29
29
|
export { generateQueryParams, getQueryParams, updateQueryParam, } from './dom/query';
|
|
30
30
|
export { copyToClipboard, smoothScrollTo, toggleFullScreen } from './dom/utils';
|
|
31
31
|
export { getFromLocalStorage, getFromSessionStorage, removeFromLocalStorage, removeFromSessionStorage, saveToLocalStorage, saveToSessionStorage, } from './dom/storage';
|
|
32
|
-
export { convertArrayToString, debounceAction, isDeepEqual, throttleAction, } from './utils';
|
|
32
|
+
export { convertArrayToString, debounceAction, isDeepEqual, throttleAction, countClassMethods, } from './utils';
|
|
33
33
|
export { isBoolean, isFalsy, isInteger, isNonEmptyString, isNull, isNumber, isPositiveInteger, isPrimitive, isString, isSymbol, isTruthy, isUndefined, } from './guards/primitives';
|
|
34
34
|
export { isReturningPromise as doesReturnPromise, isArray, isArrayOfType, isValidArray as isArrayWithLength, isBigInt, isDate, isEmptyObject, isEmptyObject as isEmptyObjectGuard, isError, isFunction, isJSON, isJSON as isJSONObject, isMap, isNotEmptyObject, isObject, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp, isRegExp as isRegularExpression, isReturningPromise, isSet, isValidArray, isJSON as isValidJSON, isMap as isValidMap, isNotEmptyObject as isValidObject, isSet as isValidSet, } from './guards/non-primitives';
|
|
35
35
|
export { isBase64, isBrowser, isDateString, isEmail, isEmailArray, isEnvironment, isEnvironment as isExpectedNodeENV, isIPAddress, isNode, isEnvironment as isNodeENV, isEnvironment as isNodeEnvironment, isNumericString, isPhoneNumber, isURL, isUUID, isEmail as isValidEmail, isURL as isValidURL, } from './guards/specials';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,aAAa,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,IAAI,mBAAmB,GAC7C,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACN,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,IAAI,YAAY,EAClC,kBAAkB,IAAI,mBAAmB,EACzC,kBAAkB,EAClB,eAAe,EACf,UAAU,IAA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AAgB,EAChB,SAAS,EACT,QAAQ,EACR,QAAQ,IAAI,mBAAmB,EAC/B,kBAAkB,EAClB,KAAK,EACL,YAAY,EACZ,MAAM,IAAI,WAAW,EACrB,KAAK,IAAI,UAAU,EACnB,gBAAgB,IAAI,aAAa,EACjC,KAAK,IAAI,UAAU,GACnB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,IAAI,iBAAiB,EAClC,WAAW,EACX,MAAM,EACN,aAAa,IAAI,SAAS,EAC1B,aAAa,IAAI,iBAAiB,EAClC,eAAe,EACf,aAAa,EACb,KAAK,EACL,MAAM,EACN,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,GACnB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export { generateQueryParams, getQueryParams, updateQueryParam, } from './dom/qu
|
|
|
38
38
|
export { copyToClipboard, smoothScrollTo, toggleFullScreen } from './dom/utils';
|
|
39
39
|
export { getFromLocalStorage, getFromSessionStorage, removeFromLocalStorage, removeFromSessionStorage, saveToLocalStorage, saveToSessionStorage, } from './dom/storage';
|
|
40
40
|
// ! Other Utilities
|
|
41
|
-
export { convertArrayToString, debounceAction, isDeepEqual, throttleAction, } from './utils';
|
|
41
|
+
export { convertArrayToString, debounceAction, isDeepEqual, throttleAction, countClassMethods, } from './utils';
|
|
42
42
|
// ! Primitive Type Guards
|
|
43
43
|
export { isBoolean, isFalsy, isInteger, isNonEmptyString, isNull, isNumber, isPositiveInteger, isPrimitive, isString, isSymbol, isTruthy, isUndefined, } from './guards/primitives';
|
|
44
44
|
// ! Non-Primitive Type Guards
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -45,4 +45,11 @@ export declare const debounceAction: <T extends VoidFunction>(callback: T, delay
|
|
|
45
45
|
* window.addEventListener('resize', throttledResize);
|
|
46
46
|
*/
|
|
47
47
|
export declare const throttleAction: <T extends VoidFunction>(callback: T, delay?: number) => ThrottledFn<T>;
|
|
48
|
+
/**
|
|
49
|
+
* * Counts the number of instance methods defined on a class prototype.
|
|
50
|
+
*
|
|
51
|
+
* @param cls The class constructor (not an instance).
|
|
52
|
+
* @returns Number of methods directly defined on the class prototype.
|
|
53
|
+
*/
|
|
54
|
+
export declare function countClassMethods(cls: Function): number;
|
|
48
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAG,OA6B3C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAC9B,CAAC,EAAE,cACC,MAAM,KACf,MAKF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,YAC1C,CAAC,qBAET,SAAS,CAAC,CAAC,CAYb,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,YAC1C,CAAC,qBAET,WAAW,CAAC,CAAC,CAWf,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAG,OA6B3C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAC9B,CAAC,EAAE,cACC,MAAM,KACf,MAKF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,YAC1C,CAAC,qBAET,SAAS,CAAC,CAAC,CAYb,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,YAC1C,CAAC,qBAET,WAAW,CAAC,CAAC,CAWf,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAQvD"}
|
package/dist/utils/index.js
CHANGED
|
@@ -94,3 +94,18 @@ export const throttleAction = (callback, delay = 150) => {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* * Counts the number of instance methods defined on a class prototype.
|
|
99
|
+
*
|
|
100
|
+
* @param cls The class constructor (not an instance).
|
|
101
|
+
* @returns Number of methods directly defined on the class prototype.
|
|
102
|
+
*/
|
|
103
|
+
export function countClassMethods(cls) {
|
|
104
|
+
const prototype = cls.prototype;
|
|
105
|
+
return Object.getOwnPropertyNames(prototype).filter((name) => {
|
|
106
|
+
if (name === 'constructor')
|
|
107
|
+
return false;
|
|
108
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
109
|
+
return !!descriptor && typeof descriptor.value === 'function';
|
|
110
|
+
}).length;
|
|
111
|
+
}
|
package/package.json
CHANGED