@dereekb/date 13.4.0 → 13.4.1

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.
@@ -63,6 +63,7 @@ export interface ValidDateFromTimestringResult extends Required<DateFromTimestri
63
63
  * guaranteeing that `raw` and `result` are defined.
64
64
  *
65
65
  * @param result - The parse result to check.
66
+ * @returns `true` if the result is valid, narrowing the type to {@link ValidDateFromTimestringResult}.
66
67
  *
67
68
  * @example
68
69
  * ```ts
@@ -99,6 +100,7 @@ export declare class DateTimeUtilityInstance {
99
100
  *
100
101
  * @param date - The date to check. Defaults to now.
101
102
  * @param timezone - Overrides the instance's configured timezone for this call.
103
+ * @returns {@link TimeAM.AM} or {@link TimeAM.PM} depending on the time of day.
102
104
  *
103
105
  * @example
104
106
  * ```ts
@@ -112,6 +114,7 @@ export declare class DateTimeUtilityInstance {
112
114
  *
113
115
  * @param date - The date to format.
114
116
  * @param timezone - Overrides the instance's configured timezone for this call.
117
+ * @returns The formatted time string (e.g., "1:30PM").
115
118
  *
116
119
  * @example
117
120
  * ```ts
@@ -163,6 +166,8 @@ export declare class DateTimeUtilityInstance {
163
166
  /**
164
167
  * Creates a {@link DateTimeUtilityInstance} configured for UTC.
165
168
  *
169
+ * @returns A new {@link DateTimeUtilityInstance} using the UTC timezone.
170
+ *
166
171
  * @example
167
172
  * ```ts
168
173
  * const utcInstance = dateTimeInstanceUtc();
@@ -175,6 +180,7 @@ export declare function dateTimeInstanceUtc(): DateTimeUtilityInstance;
175
180
  * Defaults to UTC when no timezone is provided.
176
181
  *
177
182
  * @param timezone - The IANA timezone identifier (e.g., 'America/New_York').
183
+ * @returns A new {@link DateTimeUtilityInstance} for the specified timezone.
178
184
  *
179
185
  * @example
180
186
  * ```ts
@@ -188,6 +194,7 @@ export declare function dateTimeInstance(timezone?: Maybe<TimezoneString>): Date
188
194
  *
189
195
  * @param date - The date to check. Defaults to now.
190
196
  * @param timezone - The IANA timezone to evaluate in. Defaults to UTC.
197
+ * @returns {@link TimeAM.AM} or {@link TimeAM.PM} depending on the time of day.
191
198
  *
192
199
  * @example
193
200
  * ```ts
@@ -203,6 +210,7 @@ export declare function getTimeAM(date?: Date, timezone?: Maybe<TimezoneString>)
203
210
  * unlike {@link toReadableTimeString} which defaults to UTC.
204
211
  *
205
212
  * @param date - The date to format.
213
+ * @returns The formatted time string in the system's local timezone.
206
214
  *
207
215
  * @example
208
216
  * ```ts
@@ -215,6 +223,7 @@ export declare function toLocalReadableTimeString(date: Date): ReadableTimeStrin
215
223
  *
216
224
  * @param date - The date to format.
217
225
  * @param timezone - The IANA timezone to format in. Defaults to UTC.
226
+ * @returns The formatted time string (e.g., "10:30AM").
218
227
  *
219
228
  * @example
220
229
  * ```ts
@@ -229,6 +238,7 @@ export declare function toReadableTimeString(date: Date, timezone?: Maybe<Timezo
229
238
  *
230
239
  * @param input - A time string such as "1:30PM", "13:30", or "1PM".
231
240
  * @param config - Optional configuration specifying the timezone and reference date.
241
+ * @returns The parsed time string result, or `undefined` if parsing failed.
232
242
  *
233
243
  * @example
234
244
  * ```ts
@@ -246,6 +256,7 @@ export declare function parseReadableTimeString(input: ReadableTimeString, confi
246
256
  *
247
257
  * @param input - A time string such as "1:30PM" or "13:30".
248
258
  * @param config - Optional configuration specifying the timezone and reference date.
259
+ * @returns The resolved date, or `undefined` if the input could not be parsed.
249
260
  *
250
261
  * @example
251
262
  * ```ts
@@ -257,6 +268,7 @@ export declare function readableTimeStringToDate(input: ReadableTimeString, conf
257
268
  * Creates a {@link LimitDateTimeInstance} for clamping and constraining dates to a configured range.
258
269
  *
259
270
  * @param config - The limit configuration specifying min/max bounds, future requirements, etc.
271
+ * @returns A new {@link LimitDateTimeInstance} configured with the given bounds.
260
272
  *
261
273
  * @example
262
274
  * ```ts
@@ -78,6 +78,8 @@ export declare class LimitDateTimeInstance {
78
78
  * const limiter = new LimitDateTimeInstance({ limits: { isFuture: true } });
79
79
  * const range = limiter.dateRange(); // { start: <now>, end: undefined }
80
80
  * ```
81
+ *
82
+ * @returns A partial {@link DateRange} with `start` and/or `end` derived from the limits.
81
83
  */
82
84
  dateRange(): Partial<DateRange>;
83
85
  /**
@@ -85,6 +87,7 @@ export declare class LimitDateTimeInstance {
85
87
  * like "now" or relative future offsets to resolve against the given moment.
86
88
  *
87
89
  * @param instant - The reference point in time for resolving dynamic limits.
90
+ * @returns A partial {@link DateRange} resolved against the given instant.
88
91
  */
89
92
  dateRangeForInstant(instant: Date): {
90
93
  start: Date | undefined;
@@ -103,6 +106,8 @@ export declare class LimitDateTimeInstance {
103
106
  * });
104
107
  * const safe = limiter.clamp(new Date()); // at least 30 minutes from now
105
108
  * ```
109
+ *
110
+ * @returns The clamped date within the allowed range.
106
111
  */
107
112
  clamp(date: Date): Date;
108
113
  /**
@@ -117,6 +122,8 @@ export declare class LimitDateTimeInstance {
117
122
  * const clamped = limiter.clampDateRange({ start: pastDate, end: futureDate });
118
123
  * // clamped.start will be at least now
119
124
  * ```
125
+ *
126
+ * @returns The date range clamped to the allowed limits.
120
127
  */
121
128
  clampDateRange(dateRange: DateRange): DateRange;
122
129
  }
@@ -133,5 +140,7 @@ export declare class LimitDateTimeInstance {
133
140
  * });
134
141
  * const clamped = limiter.clamp(someDate);
135
142
  * ```
143
+ *
144
+ * @returns A new {@link LimitDateTimeInstance}.
136
145
  */
137
146
  export declare function limitDateTimeInstance(config: LimitDateTimeConfig): LimitDateTimeInstance;
@@ -121,6 +121,8 @@ export declare class DateTimeMinuteInstance {
121
121
  set step(step: Minutes);
122
122
  /**
123
123
  * Returns the LimitDateTimeInstance. This does not take the schedule into consideration.
124
+ *
125
+ * @returns The underlying {@link LimitDateTimeInstance}.
124
126
  */
125
127
  get limitInstance(): LimitDateTimeInstance;
126
128
  /**
@@ -140,6 +142,8 @@ export declare class DateTimeMinuteInstance {
140
142
  * // true if June 15 is a weekday and overlaps the limit range
141
143
  * instance.dateDayContainsValidDateValue(new Date('2024-06-15'));
142
144
  * ```
145
+ *
146
+ * @returns `true` if the day contains at least one valid date/time value.
143
147
  */
144
148
  dateDayContainsValidDateValue(date: Date): boolean;
145
149
  /**
@@ -157,6 +161,8 @@ export declare class DateTimeMinuteInstance {
157
161
  *
158
162
  * instance.isInValidRange(new Date('2024-06-15T10:00:00')); // true if a weekday
159
163
  * ```
164
+ *
165
+ * @returns `true` if the date is within the min/max limits and on a scheduled day.
160
166
  */
161
167
  isInValidRange(date?: Date): boolean;
162
168
  /**
@@ -174,6 +180,8 @@ export declare class DateTimeMinuteInstance {
174
180
  *
175
181
  * instance.isValid(new Date('2099-03-15T10:00:00')); // true if all constraints pass
176
182
  * ```
183
+ *
184
+ * @returns `true` if the date passes all configured constraints.
177
185
  */
178
186
  isValid(date?: Date): boolean;
179
187
  /**
@@ -192,6 +200,8 @@ export declare class DateTimeMinuteInstance {
192
200
  * // status.isAfterMinimum === false (before min)
193
201
  * // status.inFuture === false (if date is in the past)
194
202
  * ```
203
+ *
204
+ * @returns A {@link DateTimeMinuteDateStatus} snapshot for the given date.
195
205
  */
196
206
  getStatus(date?: Date): DateTimeMinuteDateStatus;
197
207
  /**
@@ -208,6 +218,8 @@ export declare class DateTimeMinuteInstance {
208
218
  *
209
219
  * instance.dateIsInSchedule(new Date('2024-06-15')); // true (Saturday = false)
210
220
  * ```
221
+ *
222
+ * @returns `true` if the date is on a scheduled day or no schedule is configured.
211
223
  */
212
224
  dateIsInSchedule(date?: Date): boolean;
213
225
  /**
@@ -227,6 +239,8 @@ export declare class DateTimeMinuteInstance {
227
239
  * instance.round({ roundToSteps: true }); // 2024-06-15T09:00:00
228
240
  * instance.round({ roundToSteps: true, roundToBound: true }); // clamped to min if below
229
241
  * ```
242
+ *
243
+ * @returns The rounded (and optionally clamped) date.
230
244
  */
231
245
  round(round: RoundDateTimeMinute): Date;
232
246
  /**
@@ -245,6 +259,8 @@ export declare class DateTimeMinuteInstance {
245
259
  *
246
260
  * instance.clamp(new Date('2024-05-25')); // clamped to min, then nearest weekday
247
261
  * ```
262
+ *
263
+ * @returns The date clamped to both the limits and the schedule.
248
264
  */
249
265
  clamp(date?: Date, maxClampDistance?: Days): Date;
250
266
  /**
@@ -260,6 +276,8 @@ export declare class DateTimeMinuteInstance {
260
276
  *
261
277
  * instance.clampToLimit(new Date('2025-03-01')); // returns max (2024-12-31)
262
278
  * ```
279
+ *
280
+ * @returns The date clamped to the configured min/max limits.
263
281
  */
264
282
  clampToLimit(date?: Date): Date;
265
283
  /**
@@ -279,6 +297,8 @@ export declare class DateTimeMinuteInstance {
279
297
  * // If June 15, 2024 is a Saturday, returns the next Monday
280
298
  * instance.clampToSchedule(new Date('2024-06-15'));
281
299
  * ```
300
+ *
301
+ * @returns The nearest valid scheduled date, or the input date if already valid or no schedule is configured.
282
302
  */
283
303
  clampToSchedule(date?: Date, maxClampDistance?: Days): Date;
284
304
  /**
@@ -299,6 +319,8 @@ export declare class DateTimeMinuteInstance {
299
319
  * // Find the next weekday after a Saturday
300
320
  * instance.findNextAvailableDayInSchedule(new Date('2024-06-15'), 'future');
301
321
  * ```
322
+ *
323
+ * @returns The next valid schedule date, or `undefined` if none found within the max distance.
302
324
  */
303
325
  findNextAvailableDayInSchedule(date: DateCellScheduleDateFilterInput, direction: DateRelativeDirection, maxDistance?: Days): Maybe<Date>;
304
326
  /**
@@ -316,6 +338,8 @@ export declare class DateTimeMinuteInstance {
316
338
  * instance.isInSchedule(new Date('2024-06-17')); // true (Monday)
317
339
  * instance.isInSchedule(new Date('2024-06-16')); // false (Sunday)
318
340
  * ```
341
+ *
342
+ * @returns `true` if the date is on a scheduled day or no schedule is configured.
319
343
  */
320
344
  isInSchedule(date: DateCellScheduleDateFilterInput): boolean;
321
345
  protected _takeBoundedDate(date?: Date): Date;
@@ -338,6 +362,8 @@ export declare class DateTimeMinuteInstance {
338
362
  *
339
363
  * isValid(new Date('2024-06-17T10:00:00')); // true if future weekday after min
340
364
  * ```
365
+ *
366
+ * @returns A decision function that returns `true` for valid dates.
341
367
  */
342
368
  export declare function dateTimeMinuteDecisionFunction(config: DateTimeMinuteConfig): DecisionFunction<Date>;
343
369
  /**
@@ -366,5 +392,7 @@ export declare function dateTimeMinuteDecisionFunction(config: DateTimeMinuteCon
366
392
  * // true only if both 00:00 and 23:59 on June 15 pass all constraints
367
393
  * isFullDayValid(new Date('2024-06-15'));
368
394
  * ```
395
+ *
396
+ * @returns A decision function that returns `true` for valid days.
369
397
  */
370
398
  export declare function dateTimeMinuteWholeDayDecisionFunction(config: DateTimeMinuteConfig, startAndEndOfDayMustBeValid?: boolean): DecisionFunction<Date>;
@@ -57,6 +57,9 @@ export interface DateTimezoneConversionConfig {
57
57
  * isValidDateTimezoneConversionConfig({ timezone: 'America/Chicago' }); // true
58
58
  * isValidDateTimezoneConversionConfig({}); // false
59
59
  * ```
60
+ *
61
+ * @param input - the conversion config to validate
62
+ * @returns true if the config has at least one meaningful conversion property set
60
63
  */
61
64
  export declare function isValidDateTimezoneConversionConfig(input: DateTimezoneConversionConfig): boolean;
62
65
  /**
@@ -74,6 +77,10 @@ export type DateTimezoneConversionConfigUseSystemTimezone = {
74
77
  * isSameDateTimezoneConversionConfig({ timezone: 'UTC' }, { timezone: undefined }); // true
75
78
  * isSameDateTimezoneConversionConfig({ useSystemTimezone: true }, { timezone: 'America/Denver' }); // false
76
79
  * ```
80
+ *
81
+ * @param a - first conversion config to compare
82
+ * @param b - second conversion config to compare
83
+ * @returns true if both configs are logically equivalent
77
84
  */
78
85
  export declare function isSameDateTimezoneConversionConfig(a: DateTimezoneConversionConfig, b: DateTimezoneConversionConfig): boolean;
79
86
  /**
@@ -91,6 +98,7 @@ export declare function isSameDateTimezoneConversionConfig(a: DateTimezoneConver
91
98
  * ```
92
99
  *
93
100
  * @param date - required to determine the correct offset for that instant (DST-aware)
101
+ * @returns the system timezone UTC offset in milliseconds
94
102
  */
95
103
  export declare function getCurrentSystemOffsetInMs(date: Date): Milliseconds;
96
104
  /**
@@ -103,6 +111,7 @@ export declare function getCurrentSystemOffsetInMs(date: Date): Milliseconds;
103
111
  * ```
104
112
  *
105
113
  * @param date - required to determine the correct offset for that instant (DST-aware)
114
+ * @returns the system timezone UTC offset truncated to whole hours
106
115
  */
107
116
  export declare function getCurrentSystemOffsetInHours(date: Date): Hours;
108
117
  /**
@@ -118,6 +127,7 @@ export declare function getCurrentSystemOffsetInHours(date: Date): Hours;
118
127
  * ```
119
128
  *
120
129
  * @param date - required to determine the correct offset for that instant (DST-aware)
130
+ * @returns the system timezone UTC offset in minutes
121
131
  */
122
132
  export declare function getCurrentSystemOffsetInMinutes(date: Date): Minutes;
123
133
  /**
@@ -137,6 +147,7 @@ export declare function getCurrentSystemOffsetInMinutes(date: Date): Minutes;
137
147
  *
138
148
  * @param timezone - IANA timezone string (e.g. 'America/New_York')
139
149
  * @param date - the instant to evaluate, since DST may shift the offset
150
+ * @returns the UTC offset for the given timezone at the given instant, in milliseconds
140
151
  */
141
152
  export declare function calculateTimezoneOffset(timezone: TimezoneString, date: Date): Milliseconds;
142
153
  export type DateTimezoneConversionTarget = 'target' | 'base' | 'system';
@@ -194,6 +205,15 @@ export type DateTimezoneConversionMap<T = number> = {
194
205
  [key: string]: T;
195
206
  };
196
207
  export type DateTimezoneConversionFunction<T> = MapFunction<Milliseconds, T>;
208
+ /**
209
+ * Calculates offset values for every pair of conversion targets (target, base, system)
210
+ * and returns them as a keyed map (e.g. `'target-base'`, `'base-system'`).
211
+ *
212
+ * @param date - the reference date used to compute offsets
213
+ * @param converter - the converter instance providing offset calculations
214
+ * @param map - optional mapping function applied to each raw millisecond offset
215
+ * @returns a map of conversion-pair keys to their computed offset values
216
+ */
197
217
  export declare function calculateAllConversions<T = number>(date: Date, converter: DateTimezoneBaseDateConverter, map?: DateTimezoneConversionFunction<T>): DateTimezoneConversionMap<T>;
198
218
  export type DateTimezoneUtcNormalInstanceInput = Maybe<TimezoneString> | DateTimezoneConversionConfig;
199
219
  export type DateTimezoneUtcNormalInstanceTransformType = 'targetDateToBaseDate' | 'targetDateToSystemDate' | 'baseDateToTargetDate' | 'baseDateToSystemDate' | 'systemDateToTargetDate' | 'systemDateToBaseDate';
@@ -205,8 +225,32 @@ export type DateTimezoneUtcNormalInstanceTransformType = 'targetDateToBaseDate'
205
225
  * inverseDateTimezoneUtcNormalInstanceTransformType('targetDateToBaseDate'); // 'baseDateToTargetDate'
206
226
  * inverseDateTimezoneUtcNormalInstanceTransformType('systemDateToTargetDate'); // 'targetDateToSystemDate'
207
227
  * ```
228
+ *
229
+ * @param input - the transform type to invert
230
+ * @returns the inverse transform type for round-trip conversion
208
231
  */
209
232
  export declare function inverseDateTimezoneUtcNormalInstanceTransformType(input: DateTimezoneUtcNormalInstanceTransformType): DateTimezoneUtcNormalInstanceTransformType;
233
+ /**
234
+ * Configuration for {@link DateTimezoneUtcNormalInstance.safeMirroredConvertDate}.
235
+ */
236
+ export interface SafeMirroredConvertDateConfig {
237
+ /**
238
+ * The base date. Should have been derived from the originalContextDate using convertDate().
239
+ */
240
+ readonly baseDate: BaseDateAsUTC;
241
+ /**
242
+ * Original date used to derive the baseDate.
243
+ */
244
+ readonly originalContextDate: Date;
245
+ /**
246
+ * The "type" of date the originalContextDate is.
247
+ */
248
+ readonly contextType: DateTimezoneConversionTarget;
249
+ /**
250
+ * Whether to apply safe DST correction. Defaults to true.
251
+ */
252
+ readonly safeConvert?: boolean;
253
+ }
210
254
  /**
211
255
  * Central class for converting dates between the three date spaces (base, target, system).
212
256
  *
@@ -244,11 +288,10 @@ export declare class DateTimezoneUtcNormalInstance implements DateTimezoneBaseDa
244
288
  * For example, when daylight savings changed on November 3, 2024 the offset returned was 5 but to get back to the original an offset of 6 was required.
245
289
  * This is where some contextual data was not being used. This function uses that contextual data to make sure the reverse will be consistent.
246
290
  *
247
- * @param baseDate The base date. Should have been derived from the originalContextDate using the convertDate() function
248
- * @param originalContextDate Original date used to derive the baseDate.
249
- * @param fromOrTo the "type" of date the originalContextDate is
291
+ * @param config - configuration for the safe mirrored conversion
292
+ * @returns the converted date and the DST offset adjustment applied
250
293
  */
251
- safeMirroredConvertDate(baseDate: BaseDateAsUTC, originalContextDate: Date, contextType: DateTimezoneConversionTarget, safeConvert?: boolean): {
294
+ safeMirroredConvertDate(config: SafeMirroredConvertDateConfig): {
252
295
  date: Date;
253
296
  daylightSavingsOffset: number;
254
297
  };
@@ -277,46 +320,50 @@ export declare class DateTimezoneUtcNormalInstance implements DateTimezoneBaseDa
277
320
  /**
278
321
  * Returns true if the input is midnight in the target timezone.
279
322
  *
280
- * @param date
323
+ * @param date - the date to check
324
+ * @returns true if the date is at the start of the day in the target timezone
281
325
  */
282
326
  isStartOfDayInTargetTimezone(date: Date): boolean;
283
327
  /**
284
328
  * Start of the given day in the target timezone.
285
329
  *
286
- * @param date The input is treated as an instant in time.
330
+ * @param date - the input is treated as an instant in time
331
+ * @returns the start-of-day date in the target timezone
287
332
  */
288
333
  startOfDayInTargetTimezone(date?: Date | ISO8601DayString): Date;
289
334
  /**
290
335
  * Start of the given day in UTC.
291
336
  *
292
- * @param date
337
+ * @param date - the date or ISO8601 day string to get the start of day for
338
+ * @returns the start of the day as a BaseDateAsUTC
293
339
  */
294
340
  startOfDayInBaseDate(date?: Date | ISO8601DayString): BaseDateAsUTC;
295
341
  /**
296
342
  * End of the given day in UTC.
297
343
  *
298
- * @param date
299
- * @returns
344
+ * @param date - the date or ISO8601 day string to get the end of day for
345
+ * @returns the end of the day as a BaseDateAsUTC (23:59:59.999)
300
346
  */
301
347
  endOfDayInBaseDate(date?: Date | ISO8601DayString): BaseDateAsUTC;
302
348
  /**
303
349
  * Start of the given day for the system.
304
350
  *
305
- * @param date
306
- * @returns
351
+ * @param date - the date or ISO8601 day string to get the start of day for
352
+ * @returns the start of the day in the system timezone
307
353
  */
308
354
  startOfDayInSystemDate(date?: Date | ISO8601DayString): Date;
309
355
  /**
310
356
  * End of the given day for the system.
311
357
  *
312
- * @param date
313
- * @returns
358
+ * @param date - the date or ISO8601 day string to get the end of day for
359
+ * @returns the end of the day in the system timezone
314
360
  */
315
361
  endOfDayInSystemDate(date?: Date | ISO8601DayString): Date;
316
362
  /**
317
- * Whether or not the system experiences daylight savings for the given year.
363
+ * Whether or not the target timezone experiences daylight savings for the given year.
318
364
  *
319
- * @param year
365
+ * @param year - the year to check, as a Date or number; defaults to the current year
366
+ * @returns true if the target timezone has different offsets in January and July
320
367
  */
321
368
  targetTimezoneExperiencesDaylightSavings(year?: Date | YearNumber): boolean;
322
369
  /**
@@ -351,6 +398,8 @@ export type DateTimezoneUtcNormalFunctionInput = DateTimezoneUtcNormalInstanceIn
351
398
  * const same = dateTimezoneUtcNormal(denver); // same reference
352
399
  * ```
353
400
  *
401
+ * @param config - timezone input: an existing instance, timezone string, millisecond offset, or config object
402
+ * @returns a DateTimezoneUtcNormalInstance for the given input
354
403
  * @throws Error if the input type is not recognized
355
404
  */
356
405
  export declare function dateTimezoneUtcNormal(config: DateTimezoneUtcNormalFunctionInput): DateTimezoneUtcNormalInstance;
@@ -370,6 +419,8 @@ export declare const UTC_DATE_TIMEZONE_UTC_NORMAL_INSTANCE: DateTimezoneUtcNorma
370
419
  *
371
420
  * Prefer this over constructing a new instance when you need system-timezone conversions,
372
421
  * as the singleton avoids unnecessary allocations.
422
+ *
423
+ * @returns the shared system-timezone DateTimezoneUtcNormalInstance singleton
373
424
  */
374
425
  export declare function systemDateTimezoneUtcNormal(): DateTimezoneUtcNormalInstance;
375
426
  /**
@@ -385,6 +436,10 @@ export declare function systemDateTimezoneUtcNormal(): DateTimezoneUtcNormalInst
385
436
  * const target = baseDateToTargetDate(base, 'America/Denver');
386
437
  * // target is 2024-06-15T14:00:00.000-06:00 (2PM MDT)
387
438
  * ```
439
+ *
440
+ * @param date - the BaseDateAsUTC to convert
441
+ * @param timezone - the target IANA timezone string
442
+ * @returns a real instant in the specified timezone
388
443
  */
389
444
  export declare function baseDateToTargetDate(date: Date, timezone: Maybe<TimezoneString>): Date;
390
445
  /**
@@ -400,32 +455,51 @@ export declare function baseDateToTargetDate(date: Date, timezone: Maybe<Timezon
400
455
  * const base = targetDateToBaseDate(target, 'America/Denver');
401
456
  * // base is 2024-06-15T14:00:00.000Z — wall-clock 2PM preserved as UTC
402
457
  * ```
458
+ *
459
+ * @param date - the target-timezone date to convert
460
+ * @param timezone - the IANA timezone the date is expressed in
461
+ * @returns a BaseDateAsUTC with wall-clock time preserved as UTC
403
462
  */
404
463
  export declare function targetDateToBaseDate(date: Date, timezone: Maybe<TimezoneString>): Date;
405
464
  /**
406
465
  * Converts a {@link BaseDateAsUTC} to a target date in the system's local timezone
407
466
  * using the shared system-timezone instance.
467
+ *
468
+ * @param date - the BaseDateAsUTC to convert
469
+ * @returns the date converted to the system's local timezone
408
470
  */
409
471
  export declare function systemBaseDateToNormalDate(date: Date): BaseDateAsUTC;
410
472
  /**
411
473
  * Converts a target date in the system's local timezone back to a {@link BaseDateAsUTC}
412
474
  * using the shared system-timezone instance.
475
+ *
476
+ * @param date - the system-timezone target date to convert back to base
477
+ * @returns the corresponding BaseDateAsUTC
413
478
  */
414
479
  export declare function systemNormalDateToBaseDate(date: BaseDateAsUTC): Date;
415
480
  /**
416
481
  * Returns the millisecond offset needed to convert a {@link BaseDateAsUTC} to a target date
417
482
  * in the system's local timezone.
483
+ *
484
+ * @param date - the date to compute the offset for
485
+ * @returns the offset in milliseconds
418
486
  */
419
487
  export declare function systemBaseDateToNormalDateOffset(date: Date): Milliseconds;
420
488
  /**
421
489
  * Returns the millisecond offset needed to convert a target date in the system's
422
490
  * local timezone back to a {@link BaseDateAsUTC}.
491
+ *
492
+ * @param date - the date to compute the offset for
493
+ * @returns the offset in milliseconds
423
494
  */
424
495
  export declare function systemNormalDateToBaseDateOffset(date: Date): Milliseconds;
425
496
  /**
426
497
  * Returns whether the system's local timezone observes daylight saving time in the given year.
427
498
  *
428
499
  * Compares the offset on January 1 and July 1; if they differ, DST is in effect for part of the year.
500
+ *
501
+ * @param year - the year to check, as a Date
502
+ * @returns true if the system timezone observes DST in the given year
429
503
  */
430
504
  export declare function systemExperiencesDaylightSavings(year: Date): boolean;
431
505
  /**
@@ -450,7 +524,9 @@ export type TransformDateInTimezoneNormalFunction = ((date: Date, transform: Map
450
524
  * const result = fn(someDate, (d) => startOfDay(d));
451
525
  * ```
452
526
  *
527
+ * @param timezoneInput - timezone configuration for the conversion
453
528
  * @param transformType - defaults to `'systemDateToTargetDate'`
529
+ * @returns a function that transforms dates within the specified timezone normalization
454
530
  */
455
531
  export declare function transformDateInTimezoneNormalFunction(timezoneInput: DateTimezoneUtcNormalFunctionInput, transformType?: DateTimezoneUtcNormalInstanceTransformType): TransformDateInTimezoneNormalFunction;
456
532
  /**
@@ -465,7 +541,9 @@ export type TransformDateRangeToTimezoneFunction = TransformDateRangeDatesFuncti
465
541
  * Creates a {@link TransformDateRangeToTimezoneFunction} that converts both dates in
466
542
  * a {@link DateRange} using the specified transform type.
467
543
  *
544
+ * @param timezoneInput - timezone configuration for the conversion
468
545
  * @param transformType - defaults to `'systemDateToTargetDate'`
546
+ * @returns a function that converts DateRange dates using the specified transform
469
547
  */
470
548
  export declare function transformDateRangeToTimezoneFunction(timezoneInput: DateTimezoneUtcNormalFunctionInput, transformType?: DateTimezoneUtcNormalInstanceTransformType): TransformDateRangeToTimezoneFunction;
471
549
  /**
@@ -481,7 +559,9 @@ export type TransformDateRangeInTimezoneNormalFunction = ((dateRange: DateRange,
481
559
  * Creates a {@link TransformDateRangeInTimezoneNormalFunction} that converts a date range
482
560
  * into the specified date space, applies a user-provided range transformation, then converts back.
483
561
  *
562
+ * @param timezoneInput - timezone configuration for the conversion
484
563
  * @param transformType - defaults to `'systemDateToTargetDate'`
564
+ * @returns a function that transforms date ranges within the specified timezone normalization
485
565
  */
486
566
  export declare function transformDateRangeInTimezoneNormalFunction(timezoneInput: DateTimezoneUtcNormalFunctionInput, transformType?: DateTimezoneUtcNormalInstanceTransformType): TransformDateRangeInTimezoneNormalFunction;
487
567
  /**
@@ -498,6 +578,9 @@ export type StartOfDayInTimezoneDayStringFactory = (day: ISO8601DayString) => Da
498
578
  * const midnight = startOfDayInDenver('2024-06-15');
499
579
  * // midnight is 2024-06-15T06:00:00.000Z (midnight MDT = 6AM UTC)
500
580
  * ```
581
+ *
582
+ * @param timezone - timezone configuration to bind the factory to
583
+ * @returns a factory that converts ISO8601 day strings to start-of-day dates
501
584
  */
502
585
  export declare function startOfDayInTimezoneDayStringFactory(timezone?: DateTimezoneUtcNormalFunctionInput): StartOfDayInTimezoneDayStringFactory;
503
586
  /**
@@ -509,6 +592,10 @@ export declare function startOfDayInTimezoneDayStringFactory(timezone?: DateTime
509
592
  * ```ts
510
593
  * const midnight = startOfDayInTimezoneFromISO8601DayString('2024-06-15', 'America/Denver');
511
594
  * ```
595
+ *
596
+ * @param day - the ISO8601 day string to parse
597
+ * @param timezone - timezone configuration for the start-of-day calculation
598
+ * @returns the start-of-day instant in the given timezone
512
599
  */
513
600
  export declare function startOfDayInTimezoneFromISO8601DayString(day: ISO8601DayString, timezone?: DateTimezoneUtcNormalFunctionInput): Date;
514
601
  export interface SetOnDateWithTimezoneNormalFunctionInput {
@@ -582,6 +669,9 @@ export type SetOnDateWithTimezoneNormalFunction = ((input: SetOnDateWithTimezone
582
669
  * const result = setOnDate({ date: someDate, hours: 14, minutes: 30, inputType: 'target' });
583
670
  * // result is someDate with hours set to 14:30 in Denver time
584
671
  * ```
672
+ *
673
+ * @param timezone - the timezone configuration to bind to
674
+ * @returns a function that sets hours/minutes on dates in the given timezone
585
675
  */
586
676
  export declare function setOnDateWithTimezoneNormalFunction(timezone: DateTimezoneUtcNormalFunctionInput): SetOnDateWithTimezoneNormalFunction;
587
677
  /**
@@ -591,6 +681,7 @@ export declare function setOnDateWithTimezoneNormalFunction(timezone: DateTimezo
591
681
  *
592
682
  * @param input - the date whose day is preserved
593
683
  * @param timezone - the timezone context for the hour/minute interpretation
684
+ * @returns the input date with hours and minutes set to the current time in the given timezone
594
685
  */
595
686
  export declare function copyHoursAndMinutesFromNowWithTimezoneNormal(input: Date, timezone: DateTimezoneUtcNormalFunctionInput): Date;
596
687
  /**
@@ -610,5 +701,6 @@ export declare function copyHoursAndMinutesFromNowWithTimezoneNormal(input: Date
610
701
  * @param input - the date whose day is preserved
611
702
  * @param copyFrom - the date (or `'now'`) whose hours/minutes are copied
612
703
  * @param timezone - the timezone context for interpreting both dates
704
+ * @returns the input date with hours and minutes copied from the source
613
705
  */
614
706
  export declare function copyHoursAndMinutesFromDateWithTimezoneNormal(input: Date, copyFrom: LogicalDate, timezone: DateTimezoneUtcNormalFunctionInput): Date;
@@ -118,6 +118,9 @@ export declare function yearWeekCodeDateTimezoneInstance(input: YearWeekCodeDate
118
118
  /**
119
119
  * Computes the {@link YearWeekCode} from a Date (using system timezone) or from explicit year and week values.
120
120
  *
121
+ * @param date - the date to compute the week code for
122
+ * @returns the encoded year+week code
123
+ *
121
124
  * @example
122
125
  * ```ts
123
126
  * yearWeekCode(new Date('2024-04-15')); // 202416
@@ -158,6 +161,7 @@ export declare function yearWeekCodeForDateRange(dateRange: DateRange): YearWeek
158
161
  *
159
162
  * @param dateRange - the range to compute week codes for
160
163
  * @param dateRangeTimezone - the timezone context for accurate week boundary calculation
164
+ * @returns an array of YearWeekCode values covering the range
161
165
  */
162
166
  export declare function yearWeekCodeForDateRangeInTimezone(dateRange: DateRange, dateRangeTimezone: YearWeekCodeDateTimezoneInput): YearWeekCode[];
163
167
  /**
@@ -175,6 +179,7 @@ export type YearWeekCodeForCalendarMonthFactory = (date: Date) => YearWeekCode[]
175
179
  * Returns all {@link YearWeekCode} values for the calendar month containing the given date, using the system timezone.
176
180
  *
177
181
  * @param date - a date within the target month
182
+ * @returns an array of YearWeekCode values for the month
178
183
  */
179
184
  export declare function yearWeekCodeForCalendarMonth(date: Date): YearWeekCode[];
180
185
  /**
@@ -4,7 +4,6 @@ export * from './date.cell.index';
4
4
  export * from './date.cell.schedule';
5
5
  export * from './date.cell.schedule.day';
6
6
  export * from './date.cell';
7
- export * from './date.cell.validator';
8
7
  export * from './date.cell.week';
9
8
  export * from './date.calendar';
10
9
  export * from './date.duration';
@@ -5,11 +5,17 @@ import { type DateQueryBuilder } from './query.builder';
5
5
  * used by {@link makeMongoDBLikeDateQueryBuilder} to produce query filters.
6
6
  */
7
7
  export interface TimeFieldsNameSet {
8
- /** Field name storing the start (or combined start+end) timestamp. */
8
+ /**
9
+ * Field name storing the start (or combined start+end) timestamp.
10
+ */
9
11
  start: string;
10
- /** Field name storing the end timestamp. Ignored when `singleFieldForStartAndEnd` is true. */
12
+ /**
13
+ * Field name storing the end timestamp. Ignored when `singleFieldForStartAndEnd` is true.
14
+ */
11
15
  end?: string;
12
- /** When true, a single field represents both start and end so range bounds are merged. */
16
+ /**
17
+ * When true, a single field represents both start and end so range bounds are merged.
18
+ */
13
19
  singleFieldForStartAndEnd?: boolean;
14
20
  }
15
21
  /**