@dereekb/util 13.11.3 → 13.11.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.
@@ -33,11 +33,22 @@ export type ISO8601DateString = string;
33
33
  * Regular expression for validating ISO8601 date strings.
34
34
  *
35
35
  * TODO(FUTURE): Need to improve to support negative years.
36
+ *
37
+ * @dbxUtil
38
+ * @dbxUtilCategory date
39
+ * @dbxUtilKind const
40
+ * @dbxUtilTags date, iso8601, regex, string, validate
41
+ * @dbxUtilRelated is-iso8601-date-string, iso8601-day-string-regex
36
42
  */
37
43
  export declare const ISO_8601_DATE_STRING_REGEX: RegExp;
38
44
  /**
39
45
  * Determines if a string is a valid ISO8601 date string.
40
46
  *
47
+ * @dbxUtil
48
+ * @dbxUtilCategory date
49
+ * @dbxUtilTags date, iso8601, string, predicate, validate
50
+ * @dbxUtilRelated is-iso8601-day-string, is-utc-date-string, iso-8601-date-string-regex
51
+ *
41
52
  * @param input - The string to test
42
53
  * @returns True if the input is a valid ISO8601 date string
43
54
  */
@@ -58,11 +69,22 @@ export type UTCDateString = string;
58
69
  * Sat, 03 Feb 2001 04:05:06 GMT
59
70
  * Tue, 14 Mar 2023 12:34:56 UTC
60
71
  * Wed, 25 May 2024 20:45:07 EST
72
+ *
73
+ * @dbxUtil
74
+ * @dbxUtilCategory date
75
+ * @dbxUtilKind const
76
+ * @dbxUtilTags date, utc, regex, string, validate
77
+ * @dbxUtilRelated is-utc-date-string
61
78
  */
62
79
  export declare const UTC_DATE_STRING_REGEX: RegExp;
63
80
  /**
64
81
  * Determines if a string is a valid UTC date string.
65
82
  *
83
+ * @dbxUtil
84
+ * @dbxUtilCategory date
85
+ * @dbxUtilTags date, utc, string, predicate, validate
86
+ * @dbxUtilRelated is-iso8601-date-string, utc-date-string-regex
87
+ *
66
88
  * @param input - The string to test
67
89
  * @returns True if the input is a valid UTC date string
68
90
  */
@@ -104,6 +126,11 @@ export interface TimezoneStringRef {
104
126
  /**
105
127
  * Returns true only if the inputs have the same timezone, or both do not have a timezone set.
106
128
  *
129
+ * @dbxUtil
130
+ * @dbxUtilCategory date
131
+ * @dbxUtilTags date, timezone, compare, equal, predicate
132
+ * @dbxUtilRelated is-considered-utc-timezone-string
133
+ *
107
134
  * @param a - First object that may contain a timezone reference
108
135
  * @param b - Second object that may contain a timezone reference
109
136
  * @returns True if both objects have the same timezone or neither has a timezone set
@@ -111,6 +138,12 @@ export interface TimezoneStringRef {
111
138
  export declare function hasSameTimezone(a: Maybe<Partial<TimezoneStringRef>>, b: Maybe<Partial<TimezoneStringRef>>): boolean;
112
139
  /**
113
140
  * Constant for the UTC timezone string, "UTC".
141
+ *
142
+ * @dbxUtil
143
+ * @dbxUtilCategory date
144
+ * @dbxUtilKind const
145
+ * @dbxUtilTags date, timezone, utc, string, constant
146
+ * @dbxUtilRelated is-considered-utc-timezone-string
114
147
  */
115
148
  export declare const UTC_TIMEZONE_STRING = "UTC";
116
149
  /**
@@ -121,6 +154,11 @@ export type UTCTimezoneAbbreviation = typeof UTC_TIMEZONE_STRING;
121
154
  * Determines whether the input timezone string is considered UTC.
122
155
  * Returns true for null, undefined, or the string 'UTC'.
123
156
  *
157
+ * @dbxUtil
158
+ * @dbxUtilCategory date
159
+ * @dbxUtilTags date, timezone, utc, predicate
160
+ * @dbxUtilRelated has-same-timezone, utc-timezone-string
161
+ *
124
162
  * @param timezone - The timezone string to check
125
163
  * @returns True if the timezone is considered UTC
126
164
  */
@@ -153,10 +191,22 @@ export type ISO8601DayString = string;
153
191
  export type DateOrDayString = Date | ISO8601DayString;
154
192
  /**
155
193
  * Regex for an ISO8601DayString.
194
+ *
195
+ * @dbxUtil
196
+ * @dbxUtilCategory date
197
+ * @dbxUtilKind const
198
+ * @dbxUtilTags date, iso8601, day, regex, string, validate
199
+ * @dbxUtilRelated is-iso8601-day-string, iso8601-day-string-start-regex
156
200
  */
157
201
  export declare const ISO8601_DAY_STRING_REGEX: RegExp;
158
202
  /**
159
203
  * Regex for a string that starts as an ISO8601DayString.
204
+ *
205
+ * @dbxUtil
206
+ * @dbxUtilCategory date
207
+ * @dbxUtilKind const
208
+ * @dbxUtilTags date, iso8601, day, regex, prefix
209
+ * @dbxUtilRelated is-iso8601-day-string-start, iso8601-day-string-regex
160
210
  */
161
211
  export declare const ISO8601_DAY_STRING_START_REGEX: RegExp;
162
212
  /**
@@ -164,6 +214,11 @@ export declare const ISO8601_DAY_STRING_START_REGEX: RegExp;
164
214
  *
165
215
  * I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
166
216
  *
217
+ * @dbxUtil
218
+ * @dbxUtilCategory date
219
+ * @dbxUtilTags date, utc, start-of-day, day, normalize
220
+ * @dbxUtilRelated start-of-day-for-system-date-in-utc, parse-iso8601-day-string-to-utc-date
221
+ *
167
222
  * @param date - The date to get the start of day for
168
223
  * @returns A new Date set to midnight UTC of the input date's UTC day
169
224
  */
@@ -173,6 +228,11 @@ export declare function startOfDayForUTCDateInUTC(date: Date): Date;
173
228
  *
174
229
  * I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
175
230
  *
231
+ * @dbxUtil
232
+ * @dbxUtilCategory date
233
+ * @dbxUtilTags date, utc, start-of-day, system, local
234
+ * @dbxUtilRelated start-of-day-for-utc-date-in-utc
235
+ *
176
236
  * @param date - The date to get the start of local day for
177
237
  * @returns A new Date set to midnight UTC of the input date's local day
178
238
  */
@@ -180,6 +240,11 @@ export declare function startOfDayForSystemDateInUTC(date: Date): Date;
180
240
  /**
181
241
  * Parses an ISO8601DayString (YYYY-MM-DD) to a UTC Date at midnight.
182
242
  *
243
+ * @dbxUtil
244
+ * @dbxUtilCategory date
245
+ * @dbxUtilTags date, iso8601, day, parse, utc, convert
246
+ * @dbxUtilRelated is-iso8601-day-string, start-of-day-for-utc-date-in-utc
247
+ *
183
248
  * @param inputDateString - The ISO8601 day string to parse (e.g., '2022-01-15')
184
249
  * @returns A Date object set to midnight UTC on the specified day
185
250
  */
@@ -187,6 +252,11 @@ export declare function parseISO8601DayStringToUTCDate(inputDateString: ISO8601D
187
252
  /**
188
253
  * Determines if a string is a valid ISO8601 day string (YYYY-MM-DD format).
189
254
  *
255
+ * @dbxUtil
256
+ * @dbxUtilCategory date
257
+ * @dbxUtilTags date, iso8601, day, string, predicate, validate
258
+ * @dbxUtilRelated is-iso8601-day-string-start, parse-iso8601-day-string-to-utc-date, iso8601-day-string-regex
259
+ *
190
260
  * @param input - The string to test
191
261
  * @returns True if the input is a valid ISO8601 day string
192
262
  */
@@ -194,6 +264,11 @@ export declare function isISO8601DayString(input: string): input is ISO8601DaySt
194
264
  /**
195
265
  * Determines if a string starts with a valid ISO8601 day string pattern (YYYY-MM-DD).
196
266
  *
267
+ * @dbxUtil
268
+ * @dbxUtilCategory date
269
+ * @dbxUtilTags date, iso8601, day, string, predicate, prefix
270
+ * @dbxUtilRelated is-iso8601-day-string, iso8601-day-string-start-regex
271
+ *
197
272
  * @param input - The string to test
198
273
  * @returns True if the input starts with a valid ISO8601 day string pattern
199
274
  */
@@ -208,11 +283,22 @@ export declare function isISO8601DayStringStart(input: string): input is ISO8601
208
283
  export type MonthDaySlashDate = string;
209
284
  /**
210
285
  * Regex for a MonthDaySlashDate.
286
+ *
287
+ * @dbxUtil
288
+ * @dbxUtilCategory date
289
+ * @dbxUtilKind const
290
+ * @dbxUtilTags date, slash, month, day, regex, string, validate
291
+ * @dbxUtilRelated is-month-day-slash-date
211
292
  */
212
293
  export declare const MONTH_DAY_SLASH_DATE_STRING_REGEX: RegExp;
213
294
  /**
214
295
  * Determines if a string is a valid Month/Day/Year slash date format.
215
296
  *
297
+ * @dbxUtil
298
+ * @dbxUtilCategory date
299
+ * @dbxUtilTags date, slash, month, day, string, predicate, validate
300
+ * @dbxUtilRelated month-day-slash-date-to-date-string, month-day-slash-date-string-regex
301
+ *
216
302
  * @param input - The string to test
217
303
  * @returns True if the input is a valid Month/Day/Year slash date
218
304
  */
@@ -222,6 +308,11 @@ export declare function isMonthDaySlashDate(input: string): input is MonthDaySla
222
308
  * Handles single digit months and days by adding leading zeros.
223
309
  * If year is only 2 digits, prepends '20' to make a 4-digit year.
224
310
  *
311
+ * @dbxUtil
312
+ * @dbxUtilCategory date
313
+ * @dbxUtilTags date, slash, day, string, convert, parse
314
+ * @dbxUtilRelated is-month-day-slash-date
315
+ *
225
316
  * @param slashDate - The slash date string to convert (e.g., '1/1/20' or '11/15/2022')
226
317
  * @returns An ISO8601 formatted day string (YYYY-MM-DD)
227
318
  */
@@ -243,6 +334,11 @@ export type DateOrUnixDateTimeMillisecondsNumber = Date | UnixDateTimeMillisecon
243
334
  /**
244
335
  * Converts a Date object or unix timestamp (in milliseconds) to a Date object.
245
336
  *
337
+ * @dbxUtil
338
+ * @dbxUtilCategory date
339
+ * @dbxUtilTags date, milliseconds, unix, convert, normalize
340
+ * @dbxUtilRelated unix-milliseconds-number-to-date, date-or-milliseconds-to-date
341
+ *
246
342
  * @param input - Date object or unix timestamp (in milliseconds) to convert
247
343
  * @returns Date object if input is valid. Returns null/undefined if input is null/undefined
248
344
  */
@@ -252,6 +348,11 @@ export declare function dateFromDateOrTimeMillisecondsNumber(input: Maybe<DateOr
252
348
  /**
253
349
  * Converts a unix timestamp number to a Date object.
254
350
  *
351
+ * @dbxUtil
352
+ * @dbxUtilCategory date
353
+ * @dbxUtilTags date, milliseconds, unix, convert, parse
354
+ * @dbxUtilRelated date-from-date-or-time-milliseconds-number, unix-date-time-seconds-number-to-date
355
+ *
255
356
  * @param dateTimeNumber - Unix timestamp number to convert
256
357
  * @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined
257
358
  */
@@ -276,6 +377,11 @@ export type DateOrMilliseconds = Date | Milliseconds;
276
377
  *
277
378
  * If the input is a number of milliseconds, it is added to the current date.
278
379
  *
380
+ * @dbxUtil
381
+ * @dbxUtilCategory date
382
+ * @dbxUtilTags date, milliseconds, convert, normalize, offset
383
+ * @dbxUtilRelated add-milliseconds, date-from-date-or-time-milliseconds-number
384
+ *
279
385
  * @param dateOrMilliseconds - The date or milliseconds to convert to a Date.
280
386
  * @param now - The current date to use when adding milliseconds. Defaults to the current time.
281
387
  * @returns The Date representation of the input.
@@ -319,50 +425,132 @@ export type Hours = number;
319
425
  export type Days = number;
320
426
  /**
321
427
  * Number of days in a year (ignoring leap years, which are 366 days).
428
+ *
429
+ * @dbxUtil
430
+ * @dbxUtilCategory date
431
+ * @dbxUtilKind const
432
+ * @dbxUtilTags date, day, year, duration, constant
433
+ * @dbxUtilRelated days-in-week
322
434
  */
323
435
  export declare const DAYS_IN_YEAR: Days;
324
436
  /**
325
437
  * Number of hours in a day.
438
+ *
439
+ * @dbxUtil
440
+ * @dbxUtilCategory date
441
+ * @dbxUtilKind const
442
+ * @dbxUtilTags date, hour, day, duration, constant
443
+ * @dbxUtilRelated minutes-in-day, ms-in-day
326
444
  */
327
445
  export declare const HOURS_IN_DAY: Hours;
328
446
  /**
329
447
  * Number of seconds in a minute.
448
+ *
449
+ * @dbxUtil
450
+ * @dbxUtilCategory date
451
+ * @dbxUtilKind const
452
+ * @dbxUtilTags date, second, minute, duration, constant
453
+ * @dbxUtilRelated seconds-in-hour, ms-in-second
330
454
  */
331
455
  export declare const SECONDS_IN_MINUTE: Seconds;
332
456
  /**
333
457
  * Number of minutes in a day.
458
+ *
459
+ * @dbxUtil
460
+ * @dbxUtilCategory date
461
+ * @dbxUtilKind const
462
+ * @dbxUtilTags date, minute, day, duration, constant
463
+ * @dbxUtilRelated hours-in-day, minutes-in-hour
334
464
  */
335
465
  export declare const MINUTES_IN_DAY: Minutes;
336
466
  /**
337
467
  * Number of minutes in an hour.
468
+ *
469
+ * @dbxUtil
470
+ * @dbxUtilCategory date
471
+ * @dbxUtilKind const
472
+ * @dbxUtilTags date, minute, hour, duration, constant
473
+ * @dbxUtilRelated minutes-in-day, seconds-in-minute
338
474
  */
339
475
  export declare const MINUTES_IN_HOUR: Minutes;
340
476
  /**
341
477
  * Number of seconds in an hour.
478
+ *
479
+ * @dbxUtil
480
+ * @dbxUtilCategory date
481
+ * @dbxUtilKind const
482
+ * @dbxUtilTags date, second, hour, duration, constant
483
+ * @dbxUtilRelated seconds-in-minute, minutes-in-hour
342
484
  */
343
485
  export declare const SECONDS_IN_HOUR: Minutes;
344
486
  /**
345
487
  * Number of milliseconds in a second.
488
+ *
489
+ * @dbxUtil
490
+ * @dbxUtilCategory date
491
+ * @dbxUtilKind const
492
+ * @dbxUtilTags date, milliseconds, second, duration, constant
493
+ * @dbxUtilRelated ms-in-minute, seconds-in-minute
346
494
  */
347
495
  export declare const MS_IN_SECOND: Milliseconds;
348
496
  /**
349
497
  * Number of milliseconds in a minute.
498
+ *
499
+ * @dbxUtil
500
+ * @dbxUtilCategory date
501
+ * @dbxUtilKind const
502
+ * @dbxUtilTags date, milliseconds, minute, duration, constant
503
+ * @dbxUtilRelated ms-in-second, ms-in-hour
350
504
  */
351
505
  export declare const MS_IN_MINUTE: Milliseconds;
352
506
  /**
353
507
  * Number of milliseconds in an hour.
508
+ *
509
+ * @dbxUtil
510
+ * @dbxUtilCategory date
511
+ * @dbxUtilKind const
512
+ * @dbxUtilTags date, milliseconds, hour, duration, constant
513
+ * @dbxUtilRelated ms-in-minute, ms-in-day
354
514
  */
355
515
  export declare const MS_IN_HOUR: Milliseconds;
356
516
  /**
357
517
  * Number of milliseconds in a day.
518
+ *
519
+ * @dbxUtil
520
+ * @dbxUtilCategory date
521
+ * @dbxUtilKind const
522
+ * @dbxUtilTags date, milliseconds, day, duration, constant
523
+ * @dbxUtilRelated ms-in-hour, ms-in-week, hours-in-day
358
524
  */
359
525
  export declare const MS_IN_DAY: Milliseconds;
526
+ /**
527
+ * Number of seconds in a day.
528
+ *
529
+ * @dbxUtil
530
+ * @dbxUtilCategory date
531
+ * @dbxUtilKind const
532
+ * @dbxUtilTags date, seconds, day, duration, constant
533
+ * @dbxUtilRelated seconds-in-hour, seconds-in-week
534
+ */
535
+ export declare const SECONDS_IN_DAY: Seconds;
360
536
  /**
361
537
  * Number of days in a week.
538
+ *
539
+ * @dbxUtil
540
+ * @dbxUtilCategory date
541
+ * @dbxUtilKind const
542
+ * @dbxUtilTags date, day, week, duration, constant
543
+ * @dbxUtilRelated ms-in-week, days-in-year
362
544
  */
363
545
  export declare const DAYS_IN_WEEK: Days;
364
546
  /**
365
547
  * Number of milliseconds in a week.
548
+ *
549
+ * @dbxUtil
550
+ * @dbxUtilCategory date
551
+ * @dbxUtilKind const
552
+ * @dbxUtilTags date, milliseconds, week, duration, constant
553
+ * @dbxUtilRelated ms-in-day, days-in-week
366
554
  */
367
555
  export declare const MS_IN_WEEK: Milliseconds;
368
556
  /**
@@ -396,6 +584,11 @@ export type DateMonth = number;
396
584
  *
397
585
  * Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
398
586
  *
587
+ * @dbxUtil
588
+ * @dbxUtilCategory date
589
+ * @dbxUtilTags date, month, year, accessor, system, local
590
+ * @dbxUtilRelated month-of-year-from-date-month, month-of-year-from-utc-date
591
+ *
399
592
  * @param date - The date to extract the month from
400
593
  * @returns The month of year as a number from 1-12
401
594
  */
@@ -405,6 +598,11 @@ export declare function monthOfYearFromDate(date: Date): MonthOfYear;
405
598
  *
406
599
  * Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
407
600
  *
601
+ * @dbxUtil
602
+ * @dbxUtilCategory date
603
+ * @dbxUtilTags date, month, year, accessor, utc
604
+ * @dbxUtilRelated month-of-year-from-date, month-of-year-from-date-month
605
+ *
408
606
  * @param date - The date to extract the month from
409
607
  * @returns The month of year as a number from 1-12
410
608
  */
@@ -412,6 +610,11 @@ export declare function monthOfYearFromUTCDate(date: Date): MonthOfYear;
412
610
  /**
413
611
  * Converts a JavaScript Date month (0-11) to a MonthOfYear (1-12).
414
612
  *
613
+ * @dbxUtil
614
+ * @dbxUtilCategory date
615
+ * @dbxUtilTags date, month, year, convert, javascript
616
+ * @dbxUtilRelated make-date-month-for-month-of-year, month-of-year-from-date
617
+ *
415
618
  * @param dateMonth - JavaScript Date month (0-11)
416
619
  * @returns The month of year as a number from 1-12
417
620
  */
@@ -422,7 +625,7 @@ export declare function monthOfYearFromDateMonth(dateMonth: DateMonth): MonthOfY
422
625
  * @dbxUtil
423
626
  * @dbxUtilCategory date
424
627
  * @dbxUtilTags date, month, convert, javascript
425
- * @dbxUtilRelated month-of-year-from-date-month
628
+ * @dbxUtilRelated month-of-year-from-date-month, month-of-year-from-date
426
629
  *
427
630
  * @param monthOfYear - Month of year (1-12)
428
631
  * @returns JavaScript Date month (0-11)
@@ -445,6 +648,11 @@ export type DateRelativeState = DateRelativeDirection | 'present';
445
648
  * Returns true if the value is a Date object.
446
649
  * Uses both instanceof and Object.prototype.toString for reliable type checking.
447
650
  *
651
+ * @dbxUtil
652
+ * @dbxUtilCategory date
653
+ * @dbxUtilTags date, predicate, type-guard, validate
654
+ * @dbxUtilRelated is-equal-date, is-past
655
+ *
448
656
  * @param value - The value to check
449
657
  * @returns True if the value is a Date object
450
658
  */
@@ -453,6 +661,11 @@ export declare function isDate(value: unknown): value is Date;
453
661
  * Returns true if the two input dates represent the same point in time.
454
662
  * Compares the timestamp values rather than the object references.
455
663
  *
664
+ * @dbxUtil
665
+ * @dbxUtilCategory date
666
+ * @dbxUtilTags date, equal, compare, predicate
667
+ * @dbxUtilRelated is-date, is-past
668
+ *
456
669
  * @param a - First date to compare
457
670
  * @param b - Second date to compare
458
671
  * @returns True if the dates represent the same point in time
@@ -461,6 +674,11 @@ export declare function isEqualDate(a: Date, b: Date): boolean;
461
674
  /**
462
675
  * Returns true if the input date is in the past relative to the current time.
463
676
  *
677
+ * @dbxUtil
678
+ * @dbxUtilCategory date
679
+ * @dbxUtilTags date, past, compare, predicate, time
680
+ * @dbxUtilRelated is-equal-date, is-date
681
+ *
464
682
  * @param input - The date to check
465
683
  * @returns True if the date is in the past
466
684
  */
@@ -469,6 +687,11 @@ export declare function isPast(input: Date): boolean;
469
687
  * Adds milliseconds to the input date, returning a new Date object.
470
688
  * If no date is input, then returns the input unchanged.
471
689
  *
690
+ * @dbxUtil
691
+ * @dbxUtilCategory date
692
+ * @dbxUtilTags date, milliseconds, add, offset, time
693
+ * @dbxUtilRelated date-or-milliseconds-to-date, ms-in-second
694
+ *
472
695
  * @param input - The date to add milliseconds to
473
696
  * @param ms - The number of milliseconds to add (defaults to 0 if null or undefined)
474
697
  * @returns A new Date with the added milliseconds, or the original input if not a Date
package/test/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "13.11.3",
3
+ "version": "13.11.4",
4
4
  "peerDependencies": {
5
- "@dereekb/util": "13.11.3",
5
+ "@dereekb/util": "13.11.4",
6
6
  "make-error": "^1.3.6"
7
7
  },
8
8
  "exports": {