nhb-toolbox 3.9.50 → 3.9.60
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 +127 -89
- package/dist/date/Chronos.d.ts.map +1 -1
- package/dist/date/Chronos.js +163 -99
- package/dist/date/chronos-fn.d.ts +4 -2
- package/dist/date/chronos-fn.d.ts.map +1 -1
- package/dist/date/chronos-fn.js +4 -2
- package/dist/date/constants.d.ts +3 -1
- package/dist/date/constants.d.ts.map +1 -1
- package/dist/date/constants.js +9 -0
- package/dist/date/types.d.ts +16 -0
- package/dist/date/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/date/Chronos.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LocaleCode } from '../number/types';
|
|
2
2
|
import { ORIGIN } from './constants';
|
|
3
|
-
import type { ChronosInput, ChronosMethods, ChronosObject, FormatOptions, StrictFormat, TimeUnit, TimeZone, UTCOffSet } from './types';
|
|
3
|
+
import type { ChronosInput, ChronosMethods, ChronosObject, DayPart, DayPartConfig, FormatOptions, StrictFormat, TimeUnit, TimeZone, UTCOffSet } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* * Creates a new immutable `Chronos` instance.
|
|
6
6
|
*
|
|
@@ -126,42 +126,34 @@ export declare class Chronos {
|
|
|
126
126
|
get unix(): number;
|
|
127
127
|
/** Gets the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
128
128
|
get timestamp(): number;
|
|
129
|
-
/** @
|
|
129
|
+
/** @instance Returns a debug-friendly string for `console.log` or `util.inspect`. */
|
|
130
130
|
inspect(): string;
|
|
131
|
-
/** @
|
|
131
|
+
/** @instance Clones and returns a new Chronos instance with the same date. */
|
|
132
132
|
clone(): Chronos;
|
|
133
|
-
/** @
|
|
133
|
+
/** @instance Enables JSON.stringify and console logging to show readable output. */
|
|
134
134
|
toJSON(): string;
|
|
135
|
-
/** @
|
|
135
|
+
/** @instance Enables arithmetic and comparison operations (e.g., +new Chronos()). */
|
|
136
136
|
valueOf(): number;
|
|
137
|
-
/** @
|
|
137
|
+
/** @instance Gets the native `Date` instance (read-only). */
|
|
138
138
|
toDate(): Date;
|
|
139
|
-
/** @
|
|
139
|
+
/** @instance Returns a string representation of a date. The format of the string depends on the locale. */
|
|
140
140
|
toString(): string;
|
|
141
|
-
/** @
|
|
141
|
+
/** @instance Returns ISO string with local time zone offset */
|
|
142
142
|
toLocalISOString(): string;
|
|
143
|
-
/** @
|
|
143
|
+
/** @instance Returns a date as a string value in ISO format. */
|
|
144
144
|
toISOString(): string;
|
|
145
145
|
/**
|
|
146
|
-
* @
|
|
146
|
+
* @instance Wrapper over native `toLocaleString`
|
|
147
147
|
* @description Converts a date and time to a string by using the current or specified locale.
|
|
148
148
|
*
|
|
149
149
|
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
|
|
150
150
|
* @param options An object that contains one or more properties that specify comparison options.
|
|
151
151
|
*/
|
|
152
152
|
toLocaleString(locale?: LocaleCode | Intl.Locale | (LocaleCode | Intl.Locale)[], options?: Intl.DateTimeFormatOptions): string;
|
|
153
|
-
/** @
|
|
153
|
+
/** @instance Returns the time value in milliseconds since midnight, January 1, 1970 UTC. */
|
|
154
154
|
getTimeStamp(): number;
|
|
155
155
|
/**
|
|
156
|
-
* @
|
|
157
|
-
* @description Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
158
|
-
*
|
|
159
|
-
* @param options - Configure format string and whether to format using utc offset.
|
|
160
|
-
* @returns Formatted date string in desired format.
|
|
161
|
-
*/
|
|
162
|
-
today(options?: FormatOptions): string;
|
|
163
|
-
/**
|
|
164
|
-
* @public @instance Formats the date into a custom string format (local time).
|
|
156
|
+
* @instance Formats the date into a custom string format (local time).
|
|
165
157
|
*
|
|
166
158
|
* @param format - The desired format (Default format is `dd, mmm DD, YYYY HH:mm:ss:mss` = `Sun, Apr 06, 2025 16:11:55:379`).
|
|
167
159
|
* @param useUTC - Optional `useUTC` to get the formatted time using UTC Offset, defaults to `false`. Equivalent to `formatUTC()` method if set to `true`.
|
|
@@ -169,7 +161,7 @@ export declare class Chronos {
|
|
|
169
161
|
*/
|
|
170
162
|
format(format?: string, useUTC?: boolean): string;
|
|
171
163
|
/**
|
|
172
|
-
* @
|
|
164
|
+
* @instance Formats the date into a strict custom string format (local time).
|
|
173
165
|
* @description Select from `21,000+` pre-defined formats.
|
|
174
166
|
*
|
|
175
167
|
* @param format - The desired format (Default format is `dd, mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`).
|
|
@@ -178,94 +170,94 @@ export declare class Chronos {
|
|
|
178
170
|
*/
|
|
179
171
|
formatStrict(format?: StrictFormat, useUTC?: boolean): string;
|
|
180
172
|
/**
|
|
181
|
-
* @
|
|
173
|
+
* @instance Formats the date into a custom string format (UTC time).
|
|
182
174
|
*
|
|
183
175
|
* @param format - The desired format (Default format is `dd, mmm DD, YYYY HH:mm:ss:mss` = `Sun, Apr 06, 2025 16:11:55:379`).
|
|
184
176
|
* @returns Formatted date string in desired format (UTC time).
|
|
185
177
|
*/
|
|
186
178
|
formatUTC(format?: string): string;
|
|
187
179
|
/**
|
|
188
|
-
* @
|
|
180
|
+
* @instance Adds seconds and returns a new immutable instance.
|
|
189
181
|
* @param seconds - Number of seconds to add.
|
|
190
182
|
* @returns A new `Chronos` instance with the updated date.
|
|
191
183
|
*/
|
|
192
184
|
addSeconds(seconds: number): Chronos;
|
|
193
185
|
/**
|
|
194
|
-
* @
|
|
186
|
+
* @instance Adds minutes and returns a new immutable instance.
|
|
195
187
|
* @param minutes - Number of minutes to add.
|
|
196
188
|
* @returns A new `Chronos` instance with the updated date.
|
|
197
189
|
*/
|
|
198
190
|
addMinutes(minutes: number): Chronos;
|
|
199
191
|
/**
|
|
200
|
-
* @
|
|
192
|
+
* @instance Adds hours and returns a new immutable instance.
|
|
201
193
|
* @param hours - Number of hours to add.
|
|
202
194
|
* @returns A new `Chronos` instance with the updated date.
|
|
203
195
|
*/
|
|
204
196
|
addHours(hours: number): Chronos;
|
|
205
197
|
/**
|
|
206
|
-
* @
|
|
198
|
+
* @instance Adds days and returns a new immutable instance.
|
|
207
199
|
* @param days - Number of days to add.
|
|
208
200
|
* @returns A new `Chronos` instance with the updated date.
|
|
209
201
|
*/
|
|
210
202
|
addDays(days: number): Chronos;
|
|
211
203
|
/**
|
|
212
|
-
* @
|
|
204
|
+
* @instance Adds weeks and returns a new immutable instance.
|
|
213
205
|
* @param weeks - Number of weeks to add.
|
|
214
206
|
* @returns A new `Chronos` instance with the updated date.
|
|
215
207
|
*/
|
|
216
208
|
addWeeks(weeks: number): Chronos;
|
|
217
209
|
/**
|
|
218
|
-
* @
|
|
210
|
+
* @instance Adds months and returns a new immutable instance.
|
|
219
211
|
* @param months - Number of months to add.
|
|
220
212
|
* @returns A new `Chronos` instance with the updated date.
|
|
221
213
|
*/
|
|
222
214
|
addMonths(months: number): Chronos;
|
|
223
215
|
/**
|
|
224
|
-
* @
|
|
216
|
+
* @instance Adds years and returns a new immutable instance.
|
|
225
217
|
* @param years - Number of years to add.
|
|
226
218
|
* @returns A new `Chronos` instance with the updated date.
|
|
227
219
|
*/
|
|
228
220
|
addYears(years: number): Chronos;
|
|
229
221
|
/**
|
|
230
|
-
* @
|
|
222
|
+
* @instance Create a new instance of `Chronos` in the specified timezone.
|
|
231
223
|
*
|
|
232
224
|
* @param zone - Standard timezone abbreviation (e.g., 'IST', 'UTC', 'EST') or UTC Offset in `UTC-01:30` format.
|
|
233
225
|
* @returns A new instance of `Chronos` with time in the given timezone. Invalid input sets time-zone to `UTC`.
|
|
234
226
|
*/
|
|
235
227
|
timeZone(zone: TimeZone | UTCOffSet): Chronos;
|
|
236
228
|
/**
|
|
237
|
-
* @
|
|
229
|
+
* @instance Checks if the year is a leap year.
|
|
238
230
|
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
239
231
|
* - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
|
|
240
232
|
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
241
233
|
*/
|
|
242
234
|
isLeapYear(): boolean;
|
|
243
|
-
/** @
|
|
235
|
+
/** @instance Checks if the current date is today. */
|
|
244
236
|
isToday(): boolean;
|
|
245
|
-
/** @
|
|
237
|
+
/** @instance Checks if the current date is tomorrow. */
|
|
246
238
|
isTomorrow(): boolean;
|
|
247
|
-
/** @
|
|
239
|
+
/** @instance Checks if the current date is yesterday. */
|
|
248
240
|
isYesterday(): boolean;
|
|
249
241
|
/**
|
|
250
|
-
* @
|
|
242
|
+
* @instance Checks if another date is the same as this one in a specific unit.
|
|
251
243
|
* @param other The other date to compare.
|
|
252
244
|
* @param unit The unit to compare.
|
|
253
245
|
*/
|
|
254
246
|
isSame(other: ChronosInput, unit: TimeUnit): boolean;
|
|
255
247
|
/**
|
|
256
|
-
* @
|
|
248
|
+
* @instance Checks if this date is before another date in a specific unit.
|
|
257
249
|
* @param other The other date to compare.
|
|
258
250
|
* @param unit The unit to compare.
|
|
259
251
|
*/
|
|
260
252
|
isBefore(other: ChronosInput, unit: TimeUnit): boolean;
|
|
261
253
|
/**
|
|
262
|
-
* @
|
|
254
|
+
* @instance Checks if this date is after another date in a specific unit.
|
|
263
255
|
* @param other The other date to compare.
|
|
264
256
|
* @param unit The unit to compare.
|
|
265
257
|
*/
|
|
266
258
|
isAfter(other: ChronosInput, unit: TimeUnit): boolean;
|
|
267
259
|
/**
|
|
268
|
-
* @
|
|
260
|
+
* @instance Checks if the current date is between the given start and end dates.
|
|
269
261
|
*
|
|
270
262
|
* @param start - The start of the range.
|
|
271
263
|
* @param end - The end of the range.
|
|
@@ -278,10 +270,10 @@ export declare class Chronos {
|
|
|
278
270
|
* @returns `true` if the current date is within the specified range based on the `inclusive` mode.
|
|
279
271
|
*/
|
|
280
272
|
isBetween(start: ChronosInput, end: ChronosInput, inclusive?: '[]' | '[)' | '(]' | '()'): boolean;
|
|
281
|
-
/** @
|
|
273
|
+
/** @instance Checks if currently in DST */
|
|
282
274
|
isDST(): boolean;
|
|
283
275
|
/**
|
|
284
|
-
* @
|
|
276
|
+
* @instance Returns full time difference from now (or a specified time) down to a given level.
|
|
285
277
|
*
|
|
286
278
|
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `minute`.
|
|
287
279
|
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
@@ -290,19 +282,53 @@ export declare class Chronos {
|
|
|
290
282
|
*/
|
|
291
283
|
fromNow(level?: Exclude<TimeUnit, 'millisecond'>, withSuffixPrefix?: boolean, time?: ChronosInput): string;
|
|
292
284
|
/**
|
|
293
|
-
*
|
|
285
|
+
* * Returns the part of day (`'midnight', 'lateNight', 'night', 'morning', 'afternoon', 'evening'`) based on the current hour.
|
|
286
|
+
*
|
|
287
|
+
* *Supports both normal and wraparound (overnight) ranges.*
|
|
288
|
+
*
|
|
289
|
+
* @param config - Optional custom hour ranges for each part of day.
|
|
290
|
+
* Each range must be a tuple of strings as `[startHour, endHour]` in 24-hour format (e.g., `['06', '11']`).
|
|
291
|
+
* Supports wraparound ranges like `['22', '04']` that cross midnight.
|
|
292
|
+
*
|
|
293
|
+
* **Default Ranges:**
|
|
294
|
+
* - night: ['21', '23']
|
|
295
|
+
* - midnight: ['00', '01']
|
|
296
|
+
* - lateNight: ['02', '04']
|
|
297
|
+
* - morning: ['05', '11']
|
|
298
|
+
* - afternoon: ['12', '16']
|
|
299
|
+
* - evening: ['17', '20']
|
|
300
|
+
*
|
|
301
|
+
* @returns The current part of the day as a string.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* chronosInstance.getPartOfDay(); // e.g., 'morning'
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* // Example with custom ranges
|
|
308
|
+
* chronosInstance.getPartOfDay({
|
|
309
|
+
* night: ['22', '04'],
|
|
310
|
+
* morning: ['05', '11'],
|
|
311
|
+
* afternoon: ['12', '16'],
|
|
312
|
+
* evening: ['17', '21'],
|
|
313
|
+
* lateNight: ['01', '03'],
|
|
314
|
+
* midnight: ['00', '00'],
|
|
315
|
+
* });
|
|
316
|
+
*/
|
|
317
|
+
getPartOfDay(config?: Partial<DayPartConfig>): DayPart;
|
|
318
|
+
/**
|
|
319
|
+
* @instance Returns the number of full years between the input date and now.
|
|
294
320
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
295
321
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
296
322
|
*/
|
|
297
323
|
getRelativeYear(time?: ChronosInput): number;
|
|
298
324
|
/**
|
|
299
|
-
* @
|
|
325
|
+
* @instance Returns the number of full months between the input date and now.
|
|
300
326
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
301
327
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
302
328
|
*/
|
|
303
329
|
getRelativeMonth(time?: ChronosInput): number;
|
|
304
330
|
/**
|
|
305
|
-
* @
|
|
331
|
+
* @instance Determines if the given date is today, tomorrow, yesterday or any relative day.
|
|
306
332
|
* @param date - The date to compare (Date object).
|
|
307
333
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
308
334
|
* @returns
|
|
@@ -313,37 +339,37 @@ export declare class Chronos {
|
|
|
313
339
|
*/
|
|
314
340
|
getRelativeDay(time?: ChronosInput): number;
|
|
315
341
|
/**
|
|
316
|
-
* @
|
|
342
|
+
* @instance Determines how many full weeks apart the input date is from the `Chronos` instance.
|
|
317
343
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
318
344
|
* @returns Difference in weeks; negative if past, positive if future.
|
|
319
345
|
*/
|
|
320
346
|
getRelativeWeek(time?: ChronosInput): number;
|
|
321
347
|
/**
|
|
322
|
-
* @
|
|
348
|
+
* @instance Returns the number of full hours between the input date and now.
|
|
323
349
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
324
350
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
325
351
|
*/
|
|
326
352
|
getRelativeHour(time?: ChronosInput): number;
|
|
327
353
|
/**
|
|
328
|
-
* @
|
|
354
|
+
* @instance Returns the number of full minutes between the input date and now.
|
|
329
355
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
330
356
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
331
357
|
*/
|
|
332
358
|
getRelativeMinute(time?: ChronosInput): number;
|
|
333
359
|
/**
|
|
334
|
-
* @
|
|
360
|
+
* @instance Returns the number of full seconds between the input date and now.
|
|
335
361
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
336
362
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
337
363
|
*/
|
|
338
364
|
getRelativeSecond(time?: ChronosInput): number;
|
|
339
365
|
/**
|
|
340
|
-
* @
|
|
366
|
+
* @instance Returns the number of milliseconds between the input date and now.
|
|
341
367
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
342
368
|
* @returns The difference in number, negative is `Chronos` time is a past time else positive.
|
|
343
369
|
*/
|
|
344
370
|
getRelativeMilliSecond(time?: ChronosInput): number;
|
|
345
371
|
/**
|
|
346
|
-
* @
|
|
372
|
+
* @instance Compares the stored date with now, returning the difference in the specified unit.
|
|
347
373
|
*
|
|
348
374
|
* @param unit The time unit to compare by. Defaults to 'minute'.
|
|
349
375
|
* @param time Optional time to compare with the `Chronos` date/time.
|
|
@@ -351,53 +377,53 @@ export declare class Chronos {
|
|
|
351
377
|
*/
|
|
352
378
|
compare(unit?: TimeUnit, time?: ChronosInput): number;
|
|
353
379
|
/**
|
|
354
|
-
* @
|
|
380
|
+
* @instance Returns a new Chronos instance at the start of a given unit.
|
|
355
381
|
* @param unit The unit to reset (e.g., year, month, day).
|
|
356
382
|
*/
|
|
357
383
|
startOf(unit: TimeUnit): Chronos;
|
|
358
384
|
/**
|
|
359
|
-
* @
|
|
385
|
+
* @instance Returns a new Chronos instance at the end of a given unit.
|
|
360
386
|
* @param unit The unit to adjust (e.g., year, month, day).
|
|
361
387
|
*/
|
|
362
388
|
endOf(unit: TimeUnit): Chronos;
|
|
363
389
|
/**
|
|
364
|
-
* @
|
|
390
|
+
* @instance Returns a new Chronos instance with the specified unit added.
|
|
365
391
|
* @param amount The amount to add (can be negative).
|
|
366
392
|
* @param unit The time unit to add.
|
|
367
393
|
*/
|
|
368
394
|
add(amount: number, unit: TimeUnit): Chronos;
|
|
369
395
|
/**
|
|
370
|
-
* @
|
|
396
|
+
* @instance Returns a new Chronos instance with the specified unit subtracted.
|
|
371
397
|
* @param amount The amount to subtract (can be negative).
|
|
372
398
|
* @param unit The time unit to add.
|
|
373
399
|
*/
|
|
374
400
|
subtract(amount: number, unit: TimeUnit): Chronos;
|
|
375
401
|
/**
|
|
376
|
-
* @
|
|
402
|
+
* @instance Gets the value of a specific time unit from the date.
|
|
377
403
|
* @param unit The unit to retrieve.
|
|
378
404
|
*/
|
|
379
405
|
get(unit: TimeUnit): number;
|
|
380
406
|
/**
|
|
381
|
-
* @
|
|
407
|
+
* @instance Returns a new Chronos instance with the specified unit set to the given value.
|
|
382
408
|
* @param unit The unit to modify.
|
|
383
409
|
* @param value The value to set for the unit.
|
|
384
410
|
*/
|
|
385
411
|
set(unit: TimeUnit, value: number): Chronos;
|
|
386
412
|
/**
|
|
387
|
-
* @
|
|
413
|
+
* @instance Returns the difference between this and another date in the given unit.
|
|
388
414
|
* @param other The other date to compare.
|
|
389
415
|
* @param unit The unit in which to return the difference.
|
|
390
416
|
*/
|
|
391
417
|
diff(other: ChronosInput, unit: TimeUnit): number;
|
|
392
418
|
/**
|
|
393
|
-
* @
|
|
419
|
+
* @instance Returns a human-readable relative calendar time like "Today at 3:00 PM"
|
|
394
420
|
* @param baseDate Optional base date to compare with.
|
|
395
421
|
*/
|
|
396
422
|
calendar(baseDate?: ChronosInput): string;
|
|
397
|
-
/** @
|
|
423
|
+
/** @instance Returns a short human-readable string like "2h ago", "in 5m" */
|
|
398
424
|
fromNowShort(): string;
|
|
399
425
|
/**
|
|
400
|
-
* @
|
|
426
|
+
* @instance Sets the date to the Monday of the specified ISO week number within the current year.
|
|
401
427
|
* This method assumes ISO week logic, where week 1 is the week containing January 4th.
|
|
402
428
|
*
|
|
403
429
|
* @param week The ISO week number (1–53) to set the date to.
|
|
@@ -405,41 +431,28 @@ export declare class Chronos {
|
|
|
405
431
|
*/
|
|
406
432
|
setWeek(week: number): Chronos;
|
|
407
433
|
/**
|
|
408
|
-
* @
|
|
434
|
+
* @instance Calculates the ISO week number of the year.
|
|
409
435
|
* @returns Week number (1-53).
|
|
410
436
|
*/
|
|
411
437
|
getWeek(): number;
|
|
412
|
-
/** @
|
|
438
|
+
/** @instance Returns ISO week year */
|
|
413
439
|
getWeekYear(): number;
|
|
414
|
-
/** @
|
|
440
|
+
/** @instance Returns day of year (1 - 366) */
|
|
415
441
|
getDayOfYear(): number;
|
|
416
|
-
/** @
|
|
442
|
+
/** @instance Returns number of days in current month */
|
|
417
443
|
daysInMonth(): number;
|
|
418
|
-
/** @
|
|
444
|
+
/** @instance Converts to object with all date unit parts */
|
|
419
445
|
toObject(): ChronosObject;
|
|
420
|
-
/** @
|
|
446
|
+
/** @instance Converts to array with all date unit parts */
|
|
421
447
|
toArray(): any[];
|
|
422
|
-
/** @
|
|
448
|
+
/** @instance Returns offset like +06:00 */
|
|
423
449
|
getUTCOffset(): string;
|
|
424
|
-
/** @
|
|
450
|
+
/** @instance Returns new Chronos instance in UTC */
|
|
425
451
|
toUTC(): Chronos;
|
|
426
|
-
/** @
|
|
452
|
+
/** @instance Returns new Chronos instance in local time */
|
|
427
453
|
toLocal(): Chronos;
|
|
428
454
|
/**
|
|
429
|
-
* @
|
|
430
|
-
* * Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
431
|
-
* @param options - Configure format string and whether to format using utc offset.
|
|
432
|
-
* @returns Formatted date string in desired format.
|
|
433
|
-
*/
|
|
434
|
-
static today(options?: FormatOptions): string;
|
|
435
|
-
/**
|
|
436
|
-
* @public @static Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
437
|
-
* * It basically calls `Date.now()`.
|
|
438
|
-
* @returns The number of milliseconds elapsed since the Unix epoch.
|
|
439
|
-
*/
|
|
440
|
-
static now(): number;
|
|
441
|
-
/**
|
|
442
|
-
* @public @static Parses a date string with a given format (partial support)
|
|
455
|
+
* @static Parses a date string with a given format (partial support)
|
|
443
456
|
*
|
|
444
457
|
* * **Supported format tokens**:
|
|
445
458
|
* - `YYYY`: Full year (e.g., 2023)
|
|
@@ -463,22 +476,47 @@ export declare class Chronos {
|
|
|
463
476
|
*/
|
|
464
477
|
static parse(dateStr: string, format: string): Chronos;
|
|
465
478
|
/**
|
|
466
|
-
* @
|
|
479
|
+
* @static Returns the current date and time in a specified format in local time.
|
|
480
|
+
* * Default format is dd, `mmm DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
|
|
481
|
+
* @param options - Configure format string and whether to format using utc offset.
|
|
482
|
+
* @returns Formatted date string in desired format.
|
|
483
|
+
*/
|
|
484
|
+
static today(options?: FormatOptions): string;
|
|
485
|
+
/**
|
|
486
|
+
* @static Returns a new `Chronos` instance representing yesterday's date.
|
|
487
|
+
*
|
|
488
|
+
* @returns A `Chronos` instance for the previous calendar day.
|
|
489
|
+
*/
|
|
490
|
+
static yesterday(): Chronos;
|
|
491
|
+
/**
|
|
492
|
+
* @static Returns a new `Chronos` instance representing tomorrow's date.
|
|
493
|
+
*
|
|
494
|
+
* @returns A `Chronos` instance for the next calendar day.
|
|
495
|
+
*/
|
|
496
|
+
static tomorrow(): Chronos;
|
|
497
|
+
/**
|
|
498
|
+
* @static Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
499
|
+
* * It basically calls `Date.now()`.
|
|
500
|
+
* @returns The number of milliseconds elapsed since the Unix epoch.
|
|
501
|
+
*/
|
|
502
|
+
static now(): number;
|
|
503
|
+
/**
|
|
504
|
+
* @static Creates UTC Chronos
|
|
467
505
|
* @param dateLike Date input to create utc time.
|
|
468
506
|
*/
|
|
469
507
|
static utc(dateLike: ChronosInput): Chronos;
|
|
470
508
|
/**
|
|
471
|
-
* @
|
|
509
|
+
* @static Returns earliest Chronos
|
|
472
510
|
* @param dates Date inputs.
|
|
473
511
|
*/
|
|
474
512
|
static min(...dates: ChronosInput[]): Chronos;
|
|
475
513
|
/**
|
|
476
|
-
* @
|
|
514
|
+
* @static Returns latest Chronos
|
|
477
515
|
* @param dates Date inputs.
|
|
478
516
|
*/
|
|
479
517
|
static max(...dates: ChronosInput[]): Chronos;
|
|
480
518
|
/**
|
|
481
|
-
* @
|
|
519
|
+
* @static Checks if the year in the date string or year (from 0 - 9999) is a leap year.
|
|
482
520
|
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
483
521
|
* - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
|
|
484
522
|
*
|
|
@@ -494,7 +532,7 @@ export declare class Chronos {
|
|
|
494
532
|
*/
|
|
495
533
|
static isLeapYear(date: ChronosInput): boolean;
|
|
496
534
|
/**
|
|
497
|
-
* @
|
|
535
|
+
* @static Checks if the given value is a valid `Date` object.
|
|
498
536
|
* - A value is considered valid if it is an instance of the built-in `Date` class.
|
|
499
537
|
* - This does not check whether the date itself is valid (e.g., `new Date('invalid')`).
|
|
500
538
|
* @param value - The value to test.
|
|
@@ -502,7 +540,7 @@ export declare class Chronos {
|
|
|
502
540
|
*/
|
|
503
541
|
static isValidDate(value: unknown): value is Date;
|
|
504
542
|
/**
|
|
505
|
-
* @
|
|
543
|
+
* @static Checks if the given value is a valid date string.
|
|
506
544
|
* - A value is considered a valid date string if it is a string and can be parsed by `Date.parse()`.
|
|
507
545
|
* - This uses the native JavaScript date parser internally.
|
|
508
546
|
* @param value - The value to test.
|
|
@@ -510,7 +548,7 @@ export declare class Chronos {
|
|
|
510
548
|
*/
|
|
511
549
|
static isDateString(value: unknown): value is string;
|
|
512
550
|
/**
|
|
513
|
-
* @
|
|
551
|
+
* @static Checks if the given value is an instance of `Chronos`.
|
|
514
552
|
* - Useful for verifying Chronos objects in type guards or validations.
|
|
515
553
|
* @param value - The value to test.
|
|
516
554
|
* @returns `true` if the value is an instance of `Chronos`, otherwise `false`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,
|
|
1
|
+
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAIN,MAAM,EAIN,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,EACP,aAAa,EACb,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAO;;IAGnB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;;IAGH;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE,IAAI;IAEvB;;;;;;OAMG;gBACS,KAAK,EAAE,OAAO;IAE1B;;;;;;;;;;;;OAYG;gBAEF,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAA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