@dereekb/date 13.0.7 → 13.2.0

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.
Files changed (40) hide show
  1. package/index.cjs.js +3526 -993
  2. package/index.esm.js +3515 -983
  3. package/package.json +5 -6
  4. package/src/lib/date/date.calendar.d.ts +63 -9
  5. package/src/lib/date/date.cell.d.ts +203 -104
  6. package/src/lib/date/date.cell.factory.d.ts +319 -86
  7. package/src/lib/date/date.cell.filter.d.ts +104 -2
  8. package/src/lib/date/date.cell.index.d.ts +202 -92
  9. package/src/lib/date/date.cell.schedule.d.ts +285 -102
  10. package/src/lib/date/date.cell.schedule.day.d.ts +13 -3
  11. package/src/lib/date/date.cell.validator.d.ts +17 -8
  12. package/src/lib/date/date.cell.week.d.ts +24 -3
  13. package/src/lib/date/date.d.ts +481 -54
  14. package/src/lib/date/date.day.d.ts +139 -49
  15. package/src/lib/date/date.duration.d.ts +49 -11
  16. package/src/lib/date/date.format.d.ts +355 -36
  17. package/src/lib/date/date.hashset.d.ts +11 -0
  18. package/src/lib/date/date.logical.d.ts +61 -3
  19. package/src/lib/date/date.range.d.ts +355 -77
  20. package/src/lib/date/date.range.string.d.ts +39 -0
  21. package/src/lib/date/date.range.timezone.d.ts +18 -6
  22. package/src/lib/date/date.round.d.ts +46 -1
  23. package/src/lib/date/date.rxjs.d.ts +29 -7
  24. package/src/lib/date/date.sort.d.ts +36 -9
  25. package/src/lib/date/date.time.d.ts +197 -26
  26. package/src/lib/date/date.time.limit.d.ts +67 -4
  27. package/src/lib/date/date.time.minute.d.ts +269 -30
  28. package/src/lib/date/date.timezone.d.ts +286 -70
  29. package/src/lib/date/date.unix.d.ts +3 -0
  30. package/src/lib/date/date.week.d.ts +115 -51
  31. package/src/lib/query/query.builder.d.ts +91 -0
  32. package/src/lib/query/query.builder.mongo.d.ts +50 -0
  33. package/src/lib/query/query.filter.d.ts +29 -2
  34. package/src/lib/query/query.request.d.ts +16 -0
  35. package/src/lib/rrule/date.recurrence.d.ts +66 -22
  36. package/src/lib/rrule/date.rrule.d.ts +131 -8
  37. package/src/lib/rrule/date.rrule.extension.d.ts +50 -9
  38. package/src/lib/rrule/date.rrule.parse.d.ts +85 -2
  39. package/src/lib/timezone/timezone.d.ts +102 -2
  40. package/src/lib/timezone/timezone.validator.d.ts +9 -4
@@ -1,14 +1,17 @@
1
1
  import { type MapFunction, type Maybe, type Milliseconds, type TimezoneString, type ISO8601DayString, type YearNumber, type MapSameFunction, type Hours, type Minutes, type LogicalDate } from '@dereekb/util';
2
2
  import { type DateRange, type TransformDateRangeDatesFunction } from './date.range';
3
3
  /**
4
- * Inherited from the RRule library where RRule only deals with UTC date/times, dates going into it must always be in UTC.
5
- *
6
- * We use this "weird" date when transforming an instance (11AM in Los Angeles) into a UTC date that says the same thing,
7
- * 11AM UTC.
4
+ * A Date whose UTC components represent "wall-clock" time in an arbitrary timezone.
8
5
  *
9
- * BaseDateAsUTC lets us simplify time changes and printing time strings by removing the concept of timezones, as we can now assume 2AM is always "2AM".
6
+ * Inherited from the RRule library where RRule only deals with UTC date/times, dates going into it must always be in UTC.
7
+ * We strip the timezone concept entirely: if it's 11 AM in Los Angeles, the BaseDateAsUTC reads 11:00 UTC.
8
+ * This lets us perform date math (start-of-day, add-hours, etc.) without worrying about DST or offset changes,
9
+ * then convert back to a real timezone-aware date when needed via {@link DateTimezoneUtcNormalInstance.baseDateToTargetDate}.
10
10
  *
11
- * When using base dates, we can target any timezone after performing date conversions without worrying about things such as daylight savings, etc.
11
+ * Three date "spaces" exist in this module:
12
+ * - **base** — wall-clock time encoded as UTC (`BaseDateAsUTC`). Safe for arithmetic.
13
+ * - **target** — a real instant in the configured timezone.
14
+ * - **system** — a real instant in the host machine's local timezone.
12
15
  */
13
16
  export type BaseDateAsUTC = Date;
14
17
  /**
@@ -44,10 +47,16 @@ export interface DateTimezoneConversionConfig {
44
47
  noConversion?: true;
45
48
  }
46
49
  /**
47
- * Returns true if any DateTimezoneConversionConfig configuration value is provided.
50
+ * Returns true if the config contains at least one meaningful conversion setting
51
+ * (useSystemTimezone, timezone, timezoneOffset, or noConversion).
48
52
  *
49
- * @param input
50
- * @returns
53
+ * Useful for guarding against empty/default configs before creating a converter instance.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * isValidDateTimezoneConversionConfig({ timezone: 'America/Chicago' }); // true
58
+ * isValidDateTimezoneConversionConfig({}); // false
59
+ * ```
51
60
  */
52
61
  export declare function isValidDateTimezoneConversionConfig(input: DateTimezoneConversionConfig): boolean;
53
62
  /**
@@ -57,87 +66,128 @@ export type DateTimezoneConversionConfigUseSystemTimezone = {
57
66
  readonly useSystemTimezone: true;
58
67
  };
59
68
  /**
60
- * Returns true if both inputs are considered equivalent.
69
+ * Compares two configs for logical equivalence, accounting for the fact that
70
+ * `undefined` timezone and `'UTC'` timezone are treated as the same value.
61
71
  *
62
- * @param a
63
- * @param b
64
- * @returns
72
+ * @example
73
+ * ```ts
74
+ * isSameDateTimezoneConversionConfig({ timezone: 'UTC' }, { timezone: undefined }); // true
75
+ * isSameDateTimezoneConversionConfig({ useSystemTimezone: true }, { timezone: 'America/Denver' }); // false
76
+ * ```
65
77
  */
66
78
  export declare function isSameDateTimezoneConversionConfig(a: DateTimezoneConversionConfig, b: DateTimezoneConversionConfig): boolean;
67
79
  /**
68
- * Returns the current offset in milliseconds.
80
+ * Returns the system timezone's UTC offset for the given date, in milliseconds.
81
+ *
82
+ * Sign matches the UTC convention: UTC-6 returns a negative value (-21600000).
83
+ * The date parameter is required because DST may change the offset throughout the year.
69
84
  *
70
- * The offset corresponds positively with the UTC offset, so UTC-6 is negative 6 hours, in milliseconds.
85
+ * Uses native `getTimezoneOffset()` to avoid a DST edge case in date-fns-tz's `toZonedTime`.
71
86
  *
72
- * @param date Date is required to get the correct offset for the given date.
73
- * @returns
87
+ * @example
88
+ * ```ts
89
+ * // On a system in UTC-6 (no DST)
90
+ * getCurrentSystemOffsetInMs(new Date('2024-06-15T12:00:00Z')); // -21600000
91
+ * ```
92
+ *
93
+ * @param date - required to determine the correct offset for that instant (DST-aware)
74
94
  */
75
95
  export declare function getCurrentSystemOffsetInMs(date: Date): Milliseconds;
76
96
  /**
77
- * Returns the current system time offset in hours.
97
+ * Returns the system timezone's UTC offset for the given date, truncated to whole hours.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // On a system in UTC-6
102
+ * getCurrentSystemOffsetInHours(new Date('2024-06-15T12:00:00Z')); // -6
103
+ * ```
78
104
  *
79
- * @param date
80
- * @returns
105
+ * @param date - required to determine the correct offset for that instant (DST-aware)
81
106
  */
82
107
  export declare function getCurrentSystemOffsetInHours(date: Date): Hours;
83
108
  /**
84
- * Returns the system offset for the input date, in minutes.
109
+ * Returns the system timezone's UTC offset for the given date, in minutes.
110
+ *
111
+ * Sign matches the UTC convention: UTC-6 returns -360. Useful for timezones with
112
+ * non-hour offsets (e.g. UTC+5:30 returns 330).
85
113
  *
86
- * The offset corresponds positively with the UTC offset, so UTC-6 is negative 6 hours, in milliseconds.
114
+ * @example
115
+ * ```ts
116
+ * // On a system in UTC-6
117
+ * getCurrentSystemOffsetInMinutes(new Date('2024-06-15T12:00:00Z')); // -360
118
+ * ```
87
119
  *
88
- * @param date
89
- * @returns
120
+ * @param date - required to determine the correct offset for that instant (DST-aware)
90
121
  */
91
122
  export declare function getCurrentSystemOffsetInMinutes(date: Date): Minutes;
92
123
  /**
93
- * Returns the timezone offset in milliseconds.
124
+ * Computes the UTC offset for any IANA timezone at a given instant, in milliseconds.
94
125
  *
95
- * This is preferential to Date.getTimezoneOffset() or date-fns's getTimezoneOffset() as those are currently wrong for the first
96
- * two hours when daylight savings changes.
126
+ * Preferred over `Date.getTimezoneOffset()` and date-fns-tz's `getTimezoneOffset()` because both
127
+ * return incorrect values during the first two hours after a DST transition.
128
+ * See: https://github.com/marnusw/date-fns-tz/issues/227
97
129
  *
98
- * I.E. GMT-5 = -5 hours (in milliseconds)
130
+ * Sign matches the UTC convention: GMT-5 returns -18000000.
99
131
  *
100
- * @param timezone
101
- * @param date
102
- * @returns
132
+ * @example
133
+ * ```ts
134
+ * calculateTimezoneOffset('America/Chicago', new Date('2024-06-15T12:00:00Z')); // -18000000 (UTC-5 CDT)
135
+ * calculateTimezoneOffset('UTC', new Date()); // 0
136
+ * ```
137
+ *
138
+ * @param timezone - IANA timezone string (e.g. 'America/New_York')
139
+ * @param date - the instant to evaluate, since DST may shift the offset
103
140
  */
104
141
  export declare function calculateTimezoneOffset(timezone: TimezoneString, date: Date): Milliseconds;
105
142
  export type DateTimezoneConversionTarget = 'target' | 'base' | 'system';
106
143
  export type DateTimezoneOffsetFunction = (date: Date, from: DateTimezoneConversionTarget, to: DateTimezoneConversionTarget) => Milliseconds;
144
+ /**
145
+ * Provides bidirectional conversions between the three date spaces: base, target, and system.
146
+ *
147
+ * See {@link BaseDateAsUTC} for an explanation of these spaces.
148
+ */
107
149
  export interface DateTimezoneBaseDateConverter {
150
+ /**
151
+ * Returns the offset in milliseconds required to convert a date from one space to another.
152
+ */
108
153
  getCurrentOffset: DateTimezoneOffsetFunction;
109
154
  /**
110
- * Converts the given date into a date relative to the UTC's date by
111
- * adding the timezone offset for the current timezone.
155
+ * Strips the target timezone offset, encoding the wall-clock time as a {@link BaseDateAsUTC}.
112
156
  *
113
- * This is generally used for cases where you are dealing with conversational strings, such as "2AM today". By using the base UTC date,
114
- * as 2PM we can get "2PM" in UTC, then convert back using baseDateToTargetDate avoid timezone conversion issues and other headaches.
157
+ * Useful when you need to do date math (start-of-day, add-hours, etc.) without DST interference,
158
+ * then convert back via {@link baseDateToTargetDate}.
115
159
  *
116
- * For example, if it is 2PM in the input time, the resulting time will be 2PM UTC.
160
+ * For example, if it is 2PM in the target timezone, the result will be 2PM UTC:
117
161
  * - Input: 2021-08-16T14:00:00.000-06:00
118
162
  * - Output: 2021-08-16T14:00:00.000Z
119
- *
120
- * @param date
121
- * @param addOffset
122
163
  */
123
164
  targetDateToBaseDate(date: Date): Date;
124
165
  /**
125
- * Converts the given date into a date relative to the system's date.
166
+ * Re-interprets a target-timezone date as an instant in the system's local timezone.
126
167
  *
127
- * This is available for cases where the system uses Date's internal functionality (and therefore the system's timezone),
128
- * and conversions need to be done to/from the system time to the target timezone.
168
+ * Needed when interfacing with browser/Node APIs that implicitly use the system timezone,
169
+ * such as `startOfDay()` from date-fns.
129
170
  *
130
- * For example, if it is 2PM in the input time, the resulting time will be 2PM in the current system time.
171
+ * For example, 2PM target becomes 2PM in the system timezone:
131
172
  * - Input: 2021-08-16T14:00:00.000-06:00
132
173
  * - Output: 2021-08-16T14:00:00.000+02:00
133
- *
134
- * @param date
135
- * @param addOffset
136
174
  */
137
175
  targetDateToSystemDate(date: Date): Date;
176
+ /**
177
+ * Applies the target timezone offset to a {@link BaseDateAsUTC}, producing a real instant in the target timezone.
178
+ */
138
179
  baseDateToTargetDate(date: Date): Date;
180
+ /**
181
+ * Converts a {@link BaseDateAsUTC} to the system's local timezone.
182
+ */
139
183
  baseDateToSystemDate(date: Date): Date;
184
+ /**
185
+ * Converts a system-local date to the target timezone.
186
+ */
140
187
  systemDateToTargetDate(date: Date): Date;
188
+ /**
189
+ * Converts a system-local date to a {@link BaseDateAsUTC}.
190
+ */
141
191
  systemDateToBaseDate(date: Date): Date;
142
192
  }
143
193
  export type DateTimezoneConversionMap<T = number> = {
@@ -147,11 +197,34 @@ export type DateTimezoneConversionFunction<T> = MapFunction<Milliseconds, T>;
147
197
  export declare function calculateAllConversions<T = number>(date: Date, converter: DateTimezoneBaseDateConverter, map?: DateTimezoneConversionFunction<T>): DateTimezoneConversionMap<T>;
148
198
  export type DateTimezoneUtcNormalInstanceInput = Maybe<TimezoneString> | DateTimezoneConversionConfig;
149
199
  export type DateTimezoneUtcNormalInstanceTransformType = 'targetDateToBaseDate' | 'targetDateToSystemDate' | 'baseDateToTargetDate' | 'baseDateToSystemDate' | 'systemDateToTargetDate' | 'systemDateToBaseDate';
200
+ /**
201
+ * Returns the reverse transform type, so a round-trip conversion can be performed.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * inverseDateTimezoneUtcNormalInstanceTransformType('targetDateToBaseDate'); // 'baseDateToTargetDate'
206
+ * inverseDateTimezoneUtcNormalInstanceTransformType('systemDateToTargetDate'); // 'targetDateToSystemDate'
207
+ * ```
208
+ */
150
209
  export declare function inverseDateTimezoneUtcNormalInstanceTransformType(input: DateTimezoneUtcNormalInstanceTransformType): DateTimezoneUtcNormalInstanceTransformType;
151
210
  /**
152
- * Used for converting Dates to/from a UTC "base date" to a "normal date".
211
+ * Central class for converting dates between the three date spaces (base, target, system).
212
+ *
213
+ * Wraps a timezone configuration and provides all conversion methods. Instances are typically
214
+ * created via the {@link dateTimezoneUtcNormal} factory or by passing a config/timezone string
215
+ * to the constructor.
153
216
  *
154
- * This can generally be used for converting from/to the target offset as well.
217
+ * @example
218
+ * ```ts
219
+ * const normal = new DateTimezoneUtcNormalInstance('America/Denver');
220
+ *
221
+ * // Convert a target-timezone date to a BaseDateAsUTC for safe arithmetic
222
+ * const base = normal.targetDateToBaseDate(new Date('2024-06-15T14:00:00-06:00'));
223
+ * // base reads 14:00 UTC — the wall-clock time is preserved
224
+ *
225
+ * // Convert back when done
226
+ * const target = normal.baseDateToTargetDate(base);
227
+ * ```
155
228
  */
156
229
  export declare class DateTimezoneUtcNormalInstance implements DateTimezoneBaseDateConverter {
157
230
  readonly config: DateTimezoneConversionConfig;
@@ -257,63 +330,185 @@ export declare class DateTimezoneUtcNormalInstance implements DateTimezoneBaseDa
257
330
  transformDateRangeInTimezoneNormalFunction(transform?: DateTimezoneUtcNormalInstanceTransformType): TransformDateRangeInTimezoneNormalFunction;
258
331
  }
259
332
  export type DateTimezoneUtcNormalFunctionInput = DateTimezoneUtcNormalInstanceInput | DateTimezoneUtcNormalInstance | TimezoneString | Milliseconds;
333
+ /**
334
+ * Factory that creates or passes through a {@link DateTimezoneUtcNormalInstance}.
335
+ *
336
+ * Accepts a wide range of inputs for convenience: an existing instance (returned as-is),
337
+ * a timezone string, a raw millisecond offset, or a full config object.
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * // From IANA timezone string
342
+ * const denver = dateTimezoneUtcNormal('America/Denver');
343
+ *
344
+ * // From millisecond offset (UTC-6)
345
+ * const utcMinus6 = dateTimezoneUtcNormal(-6 * 60 * 60 * 1000);
346
+ *
347
+ * // From config object
348
+ * const system = dateTimezoneUtcNormal({ useSystemTimezone: true });
349
+ *
350
+ * // Pass-through if already an instance
351
+ * const same = dateTimezoneUtcNormal(denver); // same reference
352
+ * ```
353
+ *
354
+ * @throws Error if the input type is not recognized
355
+ */
260
356
  export declare function dateTimezoneUtcNormal(config: DateTimezoneUtcNormalFunctionInput): DateTimezoneUtcNormalInstance;
261
357
  /**
262
- * Default DateTimezoneUtcNormalInstance configured with useSystemTimezone=true
358
+ * Singleton instance that converts between the host system's local timezone and base/target spaces.
359
+ *
360
+ * Uses `useSystemTimezone: true`, so offsets adjust automatically if the system timezone changes (e.g. DST).
263
361
  */
264
362
  export declare const SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE: DateTimezoneUtcNormalInstance;
265
363
  /**
266
- * Default DateTimezoneUtcNormalInstance configured with useSystemTimezone=true
364
+ * Singleton instance configured for UTC. All conversions are identity (offset is always 0),
365
+ * making it a safe no-op converter for code paths that require a {@link DateTimezoneUtcNormalInstance}.
267
366
  */
268
367
  export declare const UTC_DATE_TIMEZONE_UTC_NORMAL_INSTANCE: DateTimezoneUtcNormalInstance;
269
368
  /**
270
- * Returns a DateTimezoneUtcNormalInstance configured with useSystemTimezone=true.
369
+ * Returns the shared {@link SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE} singleton.
271
370
  *
272
- * @returns
371
+ * Prefer this over constructing a new instance when you need system-timezone conversions,
372
+ * as the singleton avoids unnecessary allocations.
273
373
  */
274
374
  export declare function systemDateTimezoneUtcNormal(): DateTimezoneUtcNormalInstance;
375
+ /**
376
+ * Convenience function that applies the timezone offset to a {@link BaseDateAsUTC},
377
+ * producing a real instant in the specified timezone.
378
+ *
379
+ * Creates a temporary {@link DateTimezoneUtcNormalInstance} internally; prefer
380
+ * reusing an instance if calling this in a loop.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * const base = new Date('2024-06-15T14:00:00.000Z'); // wall-clock 2PM
385
+ * const target = baseDateToTargetDate(base, 'America/Denver');
386
+ * // target is 2024-06-15T14:00:00.000-06:00 (2PM MDT)
387
+ * ```
388
+ */
275
389
  export declare function baseDateToTargetDate(date: Date, timezone: Maybe<TimezoneString>): Date;
390
+ /**
391
+ * Convenience function that strips the timezone offset from a target-timezone date,
392
+ * producing a {@link BaseDateAsUTC} whose UTC components match the original wall-clock time.
393
+ *
394
+ * Creates a temporary {@link DateTimezoneUtcNormalInstance} internally; prefer
395
+ * reusing an instance if calling this in a loop.
396
+ *
397
+ * @example
398
+ * ```ts
399
+ * const target = new Date('2024-06-15T14:00:00.000-06:00'); // 2PM MDT
400
+ * const base = targetDateToBaseDate(target, 'America/Denver');
401
+ * // base is 2024-06-15T14:00:00.000Z — wall-clock 2PM preserved as UTC
402
+ * ```
403
+ */
276
404
  export declare function targetDateToBaseDate(date: Date, timezone: Maybe<TimezoneString>): Date;
405
+ /**
406
+ * Converts a {@link BaseDateAsUTC} to a target date in the system's local timezone
407
+ * using the shared system-timezone instance.
408
+ */
277
409
  export declare function systemBaseDateToNormalDate(date: Date): BaseDateAsUTC;
410
+ /**
411
+ * Converts a target date in the system's local timezone back to a {@link BaseDateAsUTC}
412
+ * using the shared system-timezone instance.
413
+ */
278
414
  export declare function systemNormalDateToBaseDate(date: BaseDateAsUTC): Date;
415
+ /**
416
+ * Returns the millisecond offset needed to convert a {@link BaseDateAsUTC} to a target date
417
+ * in the system's local timezone.
418
+ */
279
419
  export declare function systemBaseDateToNormalDateOffset(date: Date): Milliseconds;
420
+ /**
421
+ * Returns the millisecond offset needed to convert a target date in the system's
422
+ * local timezone back to a {@link BaseDateAsUTC}.
423
+ */
280
424
  export declare function systemNormalDateToBaseDateOffset(date: Date): Milliseconds;
425
+ /**
426
+ * Returns whether the system's local timezone observes daylight saving time in the given year.
427
+ *
428
+ * Compares the offset on January 1 and July 1; if they differ, DST is in effect for part of the year.
429
+ */
281
430
  export declare function systemExperiencesDaylightSavings(year: Date): boolean;
282
431
  /**
283
- * Transforms the date using a specific DateTimezoneUtcNormalInstanceTransformType type, processes a transformation in that normal, then reverses the result back to the original timezone.
432
+ * Converts a date into a target date space, applies a transformation, then converts the result back.
433
+ *
434
+ * This pattern lets you use date-fns functions (startOfDay, addHours, etc.) as if the date were in
435
+ * the target timezone, without timezone/DST artifacts.
284
436
  */
285
437
  export type TransformDateInTimezoneNormalFunction = ((date: Date, transform: MapSameFunction<Date>) => Date) & {
286
438
  readonly _timezoneInstance: DateTimezoneUtcNormalInstance;
287
439
  readonly _transformType: DateTimezoneUtcNormalInstanceTransformType;
288
440
  };
441
+ /**
442
+ * Creates a {@link TransformDateInTimezoneNormalFunction} that converts a date into the
443
+ * specified date space, applies a user-provided transformation, then converts back.
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * const fn = transformDateInTimezoneNormalFunction('America/Denver', 'systemDateToTargetDate');
448
+ *
449
+ * // Get start-of-day in Denver, even if the system is in a different timezone
450
+ * const result = fn(someDate, (d) => startOfDay(d));
451
+ * ```
452
+ *
453
+ * @param transformType - defaults to `'systemDateToTargetDate'`
454
+ */
289
455
  export declare function transformDateInTimezoneNormalFunction(timezoneInput: DateTimezoneUtcNormalFunctionInput, transformType?: DateTimezoneUtcNormalInstanceTransformType): TransformDateInTimezoneNormalFunction;
290
456
  /**
291
- * Transforms the start and end dates in a date range to a specific timezone
457
+ * Converts the start and end dates of a {@link DateRange} to a specific timezone,
458
+ * retaining a reference to the instance and transform type used.
292
459
  */
293
460
  export type TransformDateRangeToTimezoneFunction = TransformDateRangeDatesFunction & {
294
461
  readonly _timezoneInstance: DateTimezoneUtcNormalInstance;
295
462
  readonly _transformType: DateTimezoneUtcNormalInstanceTransformType;
296
463
  };
464
+ /**
465
+ * Creates a {@link TransformDateRangeToTimezoneFunction} that converts both dates in
466
+ * a {@link DateRange} using the specified transform type.
467
+ *
468
+ * @param transformType - defaults to `'systemDateToTargetDate'`
469
+ */
297
470
  export declare function transformDateRangeToTimezoneFunction(timezoneInput: DateTimezoneUtcNormalFunctionInput, transformType?: DateTimezoneUtcNormalInstanceTransformType): TransformDateRangeToTimezoneFunction;
298
471
  /**
299
- * Transforms the start and end dates in a date range using a specific DateTimezoneUtcNormalInstanceTransformType type, processes a transformation in that normal, then reverses the result back to the original timezone.
472
+ * Like {@link TransformDateInTimezoneNormalFunction} but operates on a {@link DateRange}.
473
+ *
474
+ * Converts the range into the target date space, applies a range transformation, then converts back.
300
475
  */
301
476
  export type TransformDateRangeInTimezoneNormalFunction = ((dateRange: DateRange, transform: TransformDateRangeDatesFunction) => DateRange) & {
302
477
  readonly _timezoneInstance: DateTimezoneUtcNormalInstance;
303
478
  readonly _transformType: DateTimezoneUtcNormalInstanceTransformType;
304
479
  };
480
+ /**
481
+ * Creates a {@link TransformDateRangeInTimezoneNormalFunction} that converts a date range
482
+ * into the specified date space, applies a user-provided range transformation, then converts back.
483
+ *
484
+ * @param transformType - defaults to `'systemDateToTargetDate'`
485
+ */
305
486
  export declare function transformDateRangeInTimezoneNormalFunction(timezoneInput: DateTimezoneUtcNormalFunctionInput, transformType?: DateTimezoneUtcNormalInstanceTransformType): TransformDateRangeInTimezoneNormalFunction;
306
487
  /**
307
- * Parses the input day to the start of the day in the given timezone.
488
+ * Parses an {@link ISO8601DayString} (e.g. `'2024-06-15'`) and returns the start-of-day
489
+ * instant in the configured timezone.
308
490
  */
309
491
  export type StartOfDayInTimezoneDayStringFactory = (day: ISO8601DayString) => Date;
492
+ /**
493
+ * Creates a {@link StartOfDayInTimezoneDayStringFactory} bound to the given timezone.
494
+ *
495
+ * @example
496
+ * ```ts
497
+ * const startOfDayInDenver = startOfDayInTimezoneDayStringFactory('America/Denver');
498
+ * const midnight = startOfDayInDenver('2024-06-15');
499
+ * // midnight is 2024-06-15T06:00:00.000Z (midnight MDT = 6AM UTC)
500
+ * ```
501
+ */
310
502
  export declare function startOfDayInTimezoneDayStringFactory(timezone?: DateTimezoneUtcNormalFunctionInput): StartOfDayInTimezoneDayStringFactory;
311
503
  /**
312
- * Loads the start of the day in the given timezone.
504
+ * One-shot convenience that parses an {@link ISO8601DayString} and returns the start-of-day
505
+ * instant in the given timezone. Creates a temporary instance internally; prefer
506
+ * {@link startOfDayInTimezoneDayStringFactory} when processing multiple days.
313
507
  *
314
- * @param day
315
- * @param timezone
316
- * @returns
508
+ * @example
509
+ * ```ts
510
+ * const midnight = startOfDayInTimezoneFromISO8601DayString('2024-06-15', 'America/Denver');
511
+ * ```
317
512
  */
318
513
  export declare function startOfDayInTimezoneFromISO8601DayString(day: ISO8601DayString, timezone?: DateTimezoneUtcNormalFunctionInput): Date;
319
514
  export interface SetOnDateWithTimezoneNormalFunctionInput {
@@ -375,24 +570,45 @@ export type SetOnDateWithTimezoneNormalFunction = ((input: SetOnDateWithTimezone
375
570
  readonly _timezoneInstance: DateTimezoneUtcNormalInstance;
376
571
  };
377
572
  /**
378
- * Creates a new SetONDateFunction using the input
573
+ * Creates a {@link SetOnDateWithTimezoneNormalFunction} bound to the given timezone.
574
+ *
575
+ * The returned function sets hours/minutes on a date while correctly handling
576
+ * timezone conversions and DST boundaries. It converts the input to base date space,
577
+ * applies the hour/minute changes, then converts back to the requested output space.
578
+ *
579
+ * @example
580
+ * ```ts
581
+ * const setOnDate = setOnDateWithTimezoneNormalFunction('America/Denver');
582
+ * const result = setOnDate({ date: someDate, hours: 14, minutes: 30, inputType: 'target' });
583
+ * // result is someDate with hours set to 14:30 in Denver time
584
+ * ```
379
585
  */
380
586
  export declare function setOnDateWithTimezoneNormalFunction(timezone: DateTimezoneUtcNormalFunctionInput): SetOnDateWithTimezoneNormalFunction;
381
587
  /**
382
- * Convenience function for calling copyHoursAndMinutesFromDatesWithTimezoneNormal() with now.
588
+ * Copies the current wall-clock hours and minutes (from "now") onto the input date,
589
+ * respecting the given timezone. Shorthand for calling
590
+ * {@link copyHoursAndMinutesFromDateWithTimezoneNormal} with `'now'`.
383
591
  *
384
- * @param input
385
- * @param timezone
386
- * @returns
592
+ * @param input - the date whose day is preserved
593
+ * @param timezone - the timezone context for the hour/minute interpretation
387
594
  */
388
595
  export declare function copyHoursAndMinutesFromNowWithTimezoneNormal(input: Date, timezone: DateTimezoneUtcNormalFunctionInput): Date;
389
596
  /**
390
- * Converts the two input dates, which are dates in the same timezone/normal instead of the current system, using the input DateTimezoneUtcNormalFunctionInput.
597
+ * Copies hours and minutes from `copyFrom` onto `input`, where both dates are interpreted
598
+ * in the target timezone. Internally converts to base date space, applies the copy, and converts back.
391
599
  *
392
- * This converts the dates to the system timezone normal, copies the values, then back to the original timezone normal.
600
+ * @example
601
+ * ```ts
602
+ * // Set the time on a Denver date to match another Denver date's time
603
+ * const result = copyHoursAndMinutesFromDateWithTimezoneNormal(
604
+ * targetDate,
605
+ * sourceDate,
606
+ * 'America/Denver'
607
+ * );
608
+ * ```
393
609
  *
394
- * @param input
395
- * @param copyFrom
396
- * @param timezone
610
+ * @param input - the date whose day is preserved
611
+ * @param copyFrom - the date (or `'now'`) whose hours/minutes are copied
612
+ * @param timezone - the timezone context for interpreting both dates
397
613
  */
398
614
  export declare function copyHoursAndMinutesFromDateWithTimezoneNormal(input: Date, copyFrom: LogicalDate, timezone: DateTimezoneUtcNormalFunctionInput): Date;
@@ -1 +1,4 @@
1
+ /**
2
+ * Re-exports Unix timestamp conversion utilities from @dereekb/util for use within the date package.
3
+ */
1
4
  export { unixDateTimeSecondsNumberFromDateOrTimeNumber, unixDateTimeSecondsNumberForNow, unixDateTimeSecondsNumberFromDate, dateFromDateOrTimeMillisecondsNumber, unixDateTimeSecondsNumberToDate } from '@dereekb/util';