@dereekb/date 13.0.7 → 13.1.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.
- package/index.cjs.js +3526 -993
- package/index.esm.js +3515 -983
- package/package.json +5 -6
- package/src/lib/date/date.calendar.d.ts +63 -9
- package/src/lib/date/date.cell.d.ts +203 -104
- package/src/lib/date/date.cell.factory.d.ts +319 -86
- package/src/lib/date/date.cell.filter.d.ts +104 -2
- package/src/lib/date/date.cell.index.d.ts +202 -92
- package/src/lib/date/date.cell.schedule.d.ts +285 -102
- package/src/lib/date/date.cell.schedule.day.d.ts +13 -3
- package/src/lib/date/date.cell.validator.d.ts +6 -8
- package/src/lib/date/date.cell.week.d.ts +24 -3
- package/src/lib/date/date.d.ts +481 -54
- package/src/lib/date/date.day.d.ts +139 -49
- package/src/lib/date/date.duration.d.ts +49 -11
- package/src/lib/date/date.format.d.ts +355 -36
- package/src/lib/date/date.hashset.d.ts +11 -0
- package/src/lib/date/date.logical.d.ts +61 -3
- package/src/lib/date/date.range.d.ts +355 -77
- package/src/lib/date/date.range.string.d.ts +39 -0
- package/src/lib/date/date.range.timezone.d.ts +18 -6
- package/src/lib/date/date.round.d.ts +46 -1
- package/src/lib/date/date.rxjs.d.ts +29 -7
- package/src/lib/date/date.sort.d.ts +36 -9
- package/src/lib/date/date.time.d.ts +197 -26
- package/src/lib/date/date.time.limit.d.ts +67 -4
- package/src/lib/date/date.time.minute.d.ts +269 -30
- package/src/lib/date/date.timezone.d.ts +286 -70
- package/src/lib/date/date.unix.d.ts +3 -0
- package/src/lib/date/date.week.d.ts +115 -51
- package/src/lib/query/query.builder.d.ts +91 -0
- package/src/lib/query/query.builder.mongo.d.ts +50 -0
- package/src/lib/query/query.filter.d.ts +29 -2
- package/src/lib/query/query.request.d.ts +16 -0
- package/src/lib/rrule/date.recurrence.d.ts +66 -22
- package/src/lib/rrule/date.rrule.d.ts +131 -8
- package/src/lib/rrule/date.rrule.extension.d.ts +50 -9
- package/src/lib/rrule/date.rrule.parse.d.ts +85 -2
- package/src/lib/timezone/timezone.d.ts +102 -2
- package/src/lib/timezone/timezone.validator.d.ts +9 -4
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/date",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/rxjs": "13.0
|
|
6
|
-
"@dereekb/util": "13.0
|
|
5
|
+
"@dereekb/rxjs": "13.1.0",
|
|
6
|
+
"@dereekb/util": "13.1.0",
|
|
7
7
|
"@vvo/tzdb": "^6.0.0",
|
|
8
|
-
"
|
|
9
|
-
"class-validator": "^0.15.1",
|
|
8
|
+
"arktype": "^2.2.0",
|
|
10
9
|
"date-fns": "^4.0.0",
|
|
11
10
|
"date-fns-tz": "^3.2.0",
|
|
12
11
|
"rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",
|
|
@@ -14,7 +13,7 @@
|
|
|
14
13
|
},
|
|
15
14
|
"dependencies": {},
|
|
16
15
|
"devDependencies": {
|
|
17
|
-
"@dereekb/rxjs": "13.0
|
|
16
|
+
"@dereekb/rxjs": "13.1.0"
|
|
18
17
|
},
|
|
19
18
|
"exports": {
|
|
20
19
|
"./package.json": "./package.json",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ISO8601DayString } from '@dereekb/util';
|
|
2
|
-
import { DateDurationSpan } from './date.duration';
|
|
2
|
+
import { type DateDurationSpan } from './date.duration';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Distinguishes between time-based calendar events and all-day/multi-day events.
|
|
5
5
|
*/
|
|
6
6
|
export declare enum CalendarDateType {
|
|
7
7
|
/**
|
|
@@ -14,18 +14,23 @@ export declare enum CalendarDateType {
|
|
|
14
14
|
DAYS = "days"
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* A calendar entry that combines a {@link DateDurationSpan} with a {@link CalendarDateType} to distinguish
|
|
18
|
+
* between timed events and all-day/multi-day events.
|
|
18
19
|
*/
|
|
19
20
|
export interface CalendarDate extends DateDurationSpan {
|
|
20
21
|
type: CalendarDateType;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* ArkType schema for {@link CalendarDate}.
|
|
25
|
+
*/
|
|
26
|
+
export declare const calendarDateType: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
27
|
+
startsAt: Date;
|
|
28
|
+
duration: number;
|
|
26
29
|
type: CalendarDateType;
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
}, {}>;
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for creating calendar dates with timezone handling.
|
|
33
|
+
*/
|
|
29
34
|
export interface CalendarDateConfig {
|
|
30
35
|
/**
|
|
31
36
|
* The timezone to generate the calendar day on.
|
|
@@ -36,7 +41,56 @@ export interface CalendarDateConfig {
|
|
|
36
41
|
*/
|
|
37
42
|
timezone?: string | false;
|
|
38
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a {@link CalendarDate} from a day string and optional multi-day span.
|
|
46
|
+
*/
|
|
39
47
|
export type CalendarDateFactory = (day: ISO8601DayString, days?: number) => CalendarDate;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a {@link CalendarDateFactory} that produces all-day calendar events with timezone-aware start times.
|
|
50
|
+
*
|
|
51
|
+
* The factory converts an ISO 8601 day string to a UTC date, then applies timezone normalization
|
|
52
|
+
* so the resulting `startsAt` represents the correct moment for the target timezone.
|
|
53
|
+
*
|
|
54
|
+
* @param config - optional timezone configuration
|
|
55
|
+
* @returns a factory function that creates CalendarDate objects
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const factory = calendarDateFactory({ timezone: 'America/Denver' });
|
|
60
|
+
* const event = factory('2024-01-15', 3);
|
|
61
|
+
* // event.type === CalendarDateType.DAYS
|
|
62
|
+
* // event.duration === daysToMinutes(3)
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
40
65
|
export declare function calendarDateFactory(config?: CalendarDateConfig): CalendarDateFactory;
|
|
66
|
+
/**
|
|
67
|
+
* Convenience function that creates a single all-day {@link CalendarDate} with optional timezone.
|
|
68
|
+
*
|
|
69
|
+
* Shorthand for creating a factory and immediately invoking it.
|
|
70
|
+
*
|
|
71
|
+
* @param day - ISO 8601 day string (e.g. '2024-01-15')
|
|
72
|
+
* @param days - number of days the event spans
|
|
73
|
+
* @param timezone - IANA timezone string, false for UTC, or undefined for system timezone
|
|
74
|
+
* @returns a CalendarDate with type DAYS
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const event = calendarDate('2024-01-15', 1, 'America/Denver');
|
|
79
|
+
* // event.type === CalendarDateType.DAYS
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
41
82
|
export declare function calendarDate(day: ISO8601DayString, days?: number, timezone?: string | false): CalendarDate;
|
|
83
|
+
/**
|
|
84
|
+
* Wraps an existing {@link DateDurationSpan} as a time-based {@link CalendarDate}.
|
|
85
|
+
*
|
|
86
|
+
* @param dateDurationSpan - the duration span to wrap
|
|
87
|
+
* @returns a CalendarDate with type TIME
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const span: DateDurationSpan = { startsAt: new Date(), duration: 60 };
|
|
92
|
+
* const event = calendarDateForDateDurationSpan(span);
|
|
93
|
+
* // event.type === CalendarDateType.TIME
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
42
96
|
export declare function calendarDateForDateDurationSpan(dateDurationSpan: DateDurationSpan): CalendarDate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type IndexRef, type Maybe, type TimezoneString, type Minutes, type FractionalHour, type TimezoneStringRef, type ISO8601DayString } from '@dereekb/util';
|
|
2
2
|
import { type DateRange, type DateRangeDayDistanceInput } from './date.range';
|
|
3
|
-
import { DateDurationSpan } from './date.duration';
|
|
3
|
+
import { type DateDurationSpan } from './date.duration';
|
|
4
4
|
import { type DateTimezoneUtcNormalFunctionInput, type DateTimezoneUtcNormalInstance } from './date.timezone';
|
|
5
5
|
/**
|
|
6
6
|
* Index from 0 of which day this block represents.
|
|
@@ -11,9 +11,18 @@ import { type DateTimezoneUtcNormalFunctionInput, type DateTimezoneUtcNormalInst
|
|
|
11
11
|
*/
|
|
12
12
|
export type DateCellIndex = number;
|
|
13
13
|
/**
|
|
14
|
-
* Returns true if the index is a non-negative integer.
|
|
14
|
+
* Returns true if the index is a non-negative integer, which is required for valid date cell indexing.
|
|
15
15
|
*
|
|
16
|
-
* @param input
|
|
16
|
+
* @param input - the index to validate
|
|
17
|
+
* @returns whether the input is a valid date cell index (>= 0 and an integer)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* isValidDateCellIndex(0); // true
|
|
22
|
+
* isValidDateCellIndex(5); // true
|
|
23
|
+
* isValidDateCellIndex(-1); // false
|
|
24
|
+
* isValidDateCellIndex(0.5); // false
|
|
25
|
+
* ```
|
|
17
26
|
*/
|
|
18
27
|
export declare function isValidDateCellIndex(input: DateCellIndex): boolean;
|
|
19
28
|
/**
|
|
@@ -32,15 +41,23 @@ export interface DateCellIndexDatePair extends Readonly<IndexRef> {
|
|
|
32
41
|
export interface DateCell extends IndexRef {
|
|
33
42
|
i: DateCellIndex;
|
|
34
43
|
}
|
|
35
|
-
export declare class DateCell {
|
|
36
|
-
i: DateCellIndex;
|
|
37
|
-
constructor(template?: DateCell);
|
|
38
|
-
}
|
|
39
44
|
/**
|
|
40
|
-
*
|
|
45
|
+
* ArkType schema for {@link DateCell}.
|
|
46
|
+
*/
|
|
47
|
+
export declare const dateCellType: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
48
|
+
i: number;
|
|
49
|
+
}, {}>;
|
|
50
|
+
/**
|
|
51
|
+
* Normalizes a number or {@link DateCell} to a DateCell object.
|
|
52
|
+
*
|
|
53
|
+
* @param dateCellOrIndex - a numeric index or existing DateCell
|
|
54
|
+
* @returns a DateCell object with the `i` property set
|
|
41
55
|
*
|
|
42
|
-
* @
|
|
43
|
-
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* dateCell(3); // { i: 3 }
|
|
59
|
+
* dateCell({ i: 3 }); // { i: 3 } (returned as-is)
|
|
60
|
+
* ```
|
|
44
61
|
*/
|
|
45
62
|
export declare function dateCell(dateCellOrIndex: DateCellIndex | DateCell): DateCell;
|
|
46
63
|
/**
|
|
@@ -73,10 +90,18 @@ export interface DateCellTimingStartsAtForStartOfDayInput {
|
|
|
73
90
|
readonly timezone?: TimezoneString;
|
|
74
91
|
}
|
|
75
92
|
/**
|
|
76
|
-
* Creates a
|
|
93
|
+
* Creates a {@link DateCellTimingStartsAt} positioned at the start of the current day in the given timezone.
|
|
94
|
+
*
|
|
95
|
+
* Useful for initializing a timing range that begins "today" in a particular timezone.
|
|
77
96
|
*
|
|
78
|
-
* @param now
|
|
79
|
-
* @returns
|
|
97
|
+
* @param input - optional timezone and "now" override
|
|
98
|
+
* @returns a DateCellTimingStartsAt with startsAt at midnight and the resolved timezone
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const timing = dateCellTimingStartsAtForStartOfDay({ timezone: 'America/Denver' });
|
|
103
|
+
* // timing.startsAt is midnight today in Denver, timing.timezone === 'America/Denver'
|
|
104
|
+
* ```
|
|
80
105
|
*/
|
|
81
106
|
export declare function dateCellTimingStartsAtForStartOfDay(input?: DateCellTimingStartsAtForStartOfDayInput): DateCellTimingStartsAt;
|
|
82
107
|
/**
|
|
@@ -108,11 +133,15 @@ export interface DateCellTimingDateRange extends DateRange, TimezoneStringRef {
|
|
|
108
133
|
* A DateCellTimingDateRange, but the start time is the startsAt time for the first event.
|
|
109
134
|
*/
|
|
110
135
|
export type DateCellTimingEventRange = DateCellTimingDateRange;
|
|
111
|
-
|
|
136
|
+
/**
|
|
137
|
+
* ArkType schema for {@link DateCellTiming}.
|
|
138
|
+
*/
|
|
139
|
+
export declare const dateCellTimingType: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
140
|
+
startsAt: Date;
|
|
141
|
+
duration: number;
|
|
112
142
|
end: Date;
|
|
113
|
-
timezone:
|
|
114
|
-
|
|
115
|
-
}
|
|
143
|
+
timezone: string;
|
|
144
|
+
}, {}>;
|
|
116
145
|
/**
|
|
117
146
|
* Reference to a DateCellTiming
|
|
118
147
|
*/
|
|
@@ -137,12 +166,19 @@ export type DateCellTimingRangeInput = DateRangeDayDistanceInput | DateRange | n
|
|
|
137
166
|
*/
|
|
138
167
|
export type DateCellTimingTimezoneInput = Omit<DateTimezoneUtcNormalFunctionInput, 'number'>;
|
|
139
168
|
/**
|
|
140
|
-
* Creates a DateTimezoneUtcNormalInstance from the input
|
|
169
|
+
* Creates a {@link DateTimezoneUtcNormalInstance} from the input, guaranteeing that a timezone string is configured.
|
|
170
|
+
*
|
|
171
|
+
* Falls back to the system timezone if no input is provided.
|
|
141
172
|
*
|
|
142
|
-
*
|
|
173
|
+
* @param timezoneInput - timezone configuration or undefined for system timezone
|
|
174
|
+
* @returns a DateTimezoneUtcNormalInstance with a guaranteed configured timezone
|
|
175
|
+
* @throws {Error} When the timezone cannot be resolved to a known timezone string.
|
|
143
176
|
*
|
|
144
|
-
* @
|
|
145
|
-
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const instance = dateCellTimingTimezoneNormalInstance('America/Denver');
|
|
180
|
+
* instance.configuredTimezoneString; // 'America/Denver'
|
|
181
|
+
* ```
|
|
146
182
|
*/
|
|
147
183
|
export declare function dateCellTimingTimezoneNormalInstance(timezoneInput?: DateCellTimingTimezoneInput): DateTimezoneUtcNormalInstance;
|
|
148
184
|
/**
|
|
@@ -155,10 +191,17 @@ export interface FullDateCellTiming extends DateCellTiming, DateCellTimingDateRa
|
|
|
155
191
|
*/
|
|
156
192
|
export type FullDateCellTimingStart = Pick<FullDateCellTiming, 'start'>;
|
|
157
193
|
/**
|
|
158
|
-
*
|
|
194
|
+
* Derives a {@link FullDateCellTiming} from a {@link DateCellTiming} by computing the `start` date (midnight in the timing's timezone).
|
|
159
195
|
*
|
|
160
|
-
* @param timing
|
|
161
|
-
* @returns
|
|
196
|
+
* @param timing - the base timing to expand
|
|
197
|
+
* @returns the timing with the `start` field populated
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const timing: DateCellTiming = { startsAt, end, duration: 60, timezone: 'America/Denver' };
|
|
202
|
+
* const full = fullDateCellTiming(timing);
|
|
203
|
+
* // full.start is midnight for the startsAt day in Denver
|
|
204
|
+
* ```
|
|
162
205
|
*/
|
|
163
206
|
export declare function fullDateCellTiming(timing: DateCellTiming): FullDateCellTiming;
|
|
164
207
|
export interface FullDateCellTimingTimezonePair {
|
|
@@ -166,17 +209,25 @@ export interface FullDateCellTimingTimezonePair {
|
|
|
166
209
|
readonly normalInstance: DateTimezoneUtcNormalInstance;
|
|
167
210
|
}
|
|
168
211
|
/**
|
|
169
|
-
* Creates a FullDateCellTimingTimezonePair
|
|
212
|
+
* Creates a {@link FullDateCellTimingTimezonePair} containing both the expanded timing and the timezone normal instance.
|
|
170
213
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
214
|
+
* Useful when both the full timing and the timezone conversion utilities are needed together.
|
|
215
|
+
*
|
|
216
|
+
* @param timing - the base timing to expand
|
|
217
|
+
* @returns the full timing paired with its timezone normal instance
|
|
173
218
|
*/
|
|
174
219
|
export declare function fullDateCellTimingTimezonePair(timing: DateCellTiming): FullDateCellTimingTimezonePair;
|
|
175
220
|
/**
|
|
176
|
-
*
|
|
221
|
+
* Validates that a date has zero minutes, seconds, and milliseconds, which is required for a valid DateCellTiming start date (midnight in the target timezone).
|
|
177
222
|
*
|
|
178
|
-
* @param date
|
|
179
|
-
* @returns
|
|
223
|
+
* @param date - the start date to validate
|
|
224
|
+
* @returns whether the date is at a valid hour boundary
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* isValidDateCellTimingStartDate(new Date('2024-01-01T06:00:00.000Z')); // true
|
|
229
|
+
* isValidDateCellTimingStartDate(new Date('2024-01-01T06:30:00.000Z')); // false
|
|
230
|
+
* ```
|
|
180
231
|
*/
|
|
181
232
|
export declare function isValidDateCellTimingStartDate(date: Date): boolean;
|
|
182
233
|
/**
|
|
@@ -199,16 +250,17 @@ export interface DateCellTimingStartPair {
|
|
|
199
250
|
readonly normalInstance: DateTimezoneUtcNormalInstance;
|
|
200
251
|
}
|
|
201
252
|
/**
|
|
202
|
-
*
|
|
253
|
+
* Computes the start-of-day date for a timing and returns it paired with the timezone normal instance.
|
|
203
254
|
*
|
|
204
|
-
* @param timing
|
|
205
|
-
* @returns
|
|
255
|
+
* @param timing - timing with startsAt and timezone
|
|
256
|
+
* @returns the midnight start date and the timezone normal instance used to compute it
|
|
206
257
|
*/
|
|
207
258
|
export declare function dateCellTimingStartPair(timing: DateCellTimingStartsAt): DateCellTimingStartPair;
|
|
208
259
|
/**
|
|
209
|
-
*
|
|
260
|
+
* Computes the start-of-day (midnight) date for a {@link DateCellTimingStartsAt} in its configured timezone.
|
|
210
261
|
*
|
|
211
|
-
*
|
|
262
|
+
* @param timing - timing with startsAt and timezone
|
|
263
|
+
* @returns the midnight Date for the timing's first day in its timezone
|
|
212
264
|
*/
|
|
213
265
|
export declare function dateCellTimingStart(timing: DateCellTimingStartsAt): Date;
|
|
214
266
|
/**
|
|
@@ -224,70 +276,77 @@ export type DateCellTimingEventStartsAt = Pick<DateCellTiming, 'startsAt'>;
|
|
|
224
276
|
*/
|
|
225
277
|
export type DateCellTimingEvent = Pick<DateCellTiming, 'startsAt' | 'duration'>;
|
|
226
278
|
/**
|
|
227
|
-
*
|
|
279
|
+
* Null-safe equality check for two {@link DateCellTimingStartsAtEndRange} values, comparing timezone, startsAt, and end.
|
|
228
280
|
*
|
|
229
|
-
* @param a
|
|
230
|
-
* @param b
|
|
281
|
+
* @param a - first range
|
|
282
|
+
* @param b - second range
|
|
283
|
+
* @returns whether the two ranges are equivalent
|
|
231
284
|
*/
|
|
232
285
|
export declare function isSameDateCellTimingEventStartsAtEndRange(a: Maybe<DateCellTimingStartsAtEndRange>, b: Maybe<DateCellTimingStartsAtEndRange>): boolean;
|
|
233
286
|
/**
|
|
234
|
-
*
|
|
287
|
+
* Null-safe equality check for two {@link DateCellTiming} values, comparing duration and the starts-at/end range.
|
|
235
288
|
*
|
|
236
|
-
* @param a
|
|
237
|
-
* @param b
|
|
289
|
+
* @param a - first timing
|
|
290
|
+
* @param b - second timing
|
|
291
|
+
* @returns whether the two timings are equivalent
|
|
238
292
|
*/
|
|
239
293
|
export declare function isSameDateCellTiming(a: Maybe<DateCellTiming>, b: Maybe<DateCellTiming>): boolean;
|
|
240
294
|
/**
|
|
241
|
-
*
|
|
295
|
+
* Strict equality check for {@link FullDateCellTiming} values, including the derived `start` date.
|
|
242
296
|
*
|
|
243
|
-
* In most cases
|
|
297
|
+
* In most cases {@link isSameDateCellTiming} is sufficient since `start` is derived from `startsAt`.
|
|
244
298
|
*
|
|
245
|
-
* @param a
|
|
246
|
-
* @param b
|
|
247
|
-
* @returns
|
|
299
|
+
* @param a - first full timing
|
|
300
|
+
* @param b - second full timing
|
|
301
|
+
* @returns whether all fields are exactly equal
|
|
248
302
|
*/
|
|
249
303
|
export declare function isSameFullDateCellTiming(a: Maybe<FullDateCellTiming>, b: Maybe<FullDateCellTiming>): boolean;
|
|
250
304
|
/**
|
|
251
|
-
*
|
|
305
|
+
* Type guard that checks whether the input has the shape of a {@link DateCellTiming} (startsAt, end, timezone, duration).
|
|
252
306
|
*
|
|
253
|
-
* Does not
|
|
307
|
+
* Does not validate correctness (e.g. end after start). Use {@link isValidDateCellTiming} for validation.
|
|
254
308
|
*
|
|
255
|
-
* @param input
|
|
309
|
+
* @param input - value to check
|
|
310
|
+
* @returns whether the input matches the DateCellTiming shape
|
|
256
311
|
*/
|
|
257
312
|
export declare function isDateCellTiming(input: unknown): input is DateCellTiming;
|
|
258
313
|
/**
|
|
259
|
-
*
|
|
314
|
+
* Type guard that checks whether the input has the shape of a {@link FullDateCellTiming} (includes `start` field plus all DateCellTiming fields).
|
|
260
315
|
*
|
|
261
|
-
* Does not
|
|
316
|
+
* Does not validate correctness. Use {@link isValidFullDateCellTiming} for validation.
|
|
262
317
|
*
|
|
263
|
-
* @param input
|
|
318
|
+
* @param input - value to check
|
|
319
|
+
* @returns whether the input matches the FullDateCellTiming shape
|
|
264
320
|
*/
|
|
265
321
|
export declare function isFullDateCellTiming(input: unknown): input is FullDateCellTiming;
|
|
266
322
|
/**
|
|
267
|
-
*
|
|
323
|
+
* Derives a {@link DateCellTimingDateRange} from a timing, using midnight in the timing's timezone as the start and the event's end time as the end.
|
|
268
324
|
*
|
|
269
|
-
* @param timing
|
|
270
|
-
* @returns
|
|
325
|
+
* @param timing - timing with startsAt, end, and timezone
|
|
326
|
+
* @returns a date range spanning from midnight of the first day to the end of the last event
|
|
271
327
|
*/
|
|
272
328
|
export declare function dateCellTimingDateRange(timing: DateCellTimingStartsAtEndRange): DateCellTimingDateRange;
|
|
273
329
|
/**
|
|
274
|
-
* Returns
|
|
330
|
+
* Returns a {@link DateCellTimingEventRange} spanning from the first event's startsAt to the last event's end time.
|
|
275
331
|
*
|
|
276
|
-
* @
|
|
277
|
-
*
|
|
332
|
+
* Unlike {@link dateCellTimingDateRange}, the start is the event time rather than midnight.
|
|
333
|
+
*
|
|
334
|
+
* @param timing - timing with startsAt, end, and timezone
|
|
335
|
+
* @returns the event range
|
|
278
336
|
*/
|
|
279
337
|
export declare function dateCellTimingEventRange(timing: Pick<DateCellTiming, 'startsAt' | 'end' | 'timezone'>): DateCellTimingEventRange;
|
|
280
338
|
/**
|
|
281
|
-
* Returns the
|
|
339
|
+
* Returns the date range of the first event only (from startsAt to startsAt + duration).
|
|
282
340
|
*
|
|
283
|
-
* @param timing
|
|
284
|
-
* @returns
|
|
341
|
+
* @param timing - timing to extract the first event from
|
|
342
|
+
* @returns date range of the first event
|
|
285
343
|
*/
|
|
286
344
|
export declare function getDateCellTimingFirstEventDateRange(timing: DateCellTimingStartsAtEndRange): DateRange;
|
|
287
345
|
/**
|
|
288
|
-
*
|
|
346
|
+
* Converts a timing's duration from minutes to fractional hours.
|
|
289
347
|
*
|
|
290
|
-
* @param timing
|
|
348
|
+
* @param timing - timing with a duration in minutes
|
|
349
|
+
* @returns the duration expressed as fractional hours (e.g. 90 minutes = 1.5)
|
|
291
350
|
*/
|
|
292
351
|
export declare function getDateCellTimingHoursInEvent(timing: Pick<DateCellTiming, 'duration'>): FractionalHour;
|
|
293
352
|
/**
|
|
@@ -299,32 +358,36 @@ export type UpdateDateCellTimingToTimezoneFunction = (<T extends DateCellTimingS
|
|
|
299
358
|
readonly _timezone: TimezoneString;
|
|
300
359
|
};
|
|
301
360
|
/**
|
|
302
|
-
* Creates a
|
|
361
|
+
* Creates a function that updates a timing's timezone and recalculates the `start` date, while preserving the original `startsAt` instant.
|
|
362
|
+
*
|
|
363
|
+
* The event occurs at the same absolute moment in time, but is now associated with a different timezone.
|
|
303
364
|
*
|
|
304
|
-
* @param
|
|
305
|
-
* @returns
|
|
365
|
+
* @param timezone - the new IANA timezone to apply
|
|
366
|
+
* @returns a function that updates timings to the new timezone
|
|
306
367
|
*/
|
|
307
368
|
export declare function updateDateCellTimingToTimezoneFunction(timezone: TimezoneString): UpdateDateCellTimingToTimezoneFunction;
|
|
308
369
|
/**
|
|
309
|
-
*
|
|
370
|
+
* Updates the timing's timezone to the system timezone while preserving the absolute startsAt instant.
|
|
310
371
|
*
|
|
311
|
-
* @param timing
|
|
312
|
-
* @returns
|
|
372
|
+
* @param timing - timing to update
|
|
373
|
+
* @returns the timing with the system timezone applied
|
|
313
374
|
*/
|
|
314
375
|
export declare function updateDateCellTimingToSystemTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T): T;
|
|
315
376
|
/**
|
|
316
|
-
*
|
|
377
|
+
* Updates the timing's timezone to UTC while preserving the absolute startsAt instant.
|
|
317
378
|
*
|
|
318
|
-
* @param timing
|
|
319
|
-
* @returns
|
|
379
|
+
* @param timing - timing to update
|
|
380
|
+
* @returns the timing with UTC timezone applied
|
|
320
381
|
*/
|
|
321
382
|
export declare function updateDateCellTimingToUTCTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T): T;
|
|
322
383
|
/**
|
|
323
|
-
*
|
|
384
|
+
* Updates a timing's timezone while preserving the absolute startsAt instant.
|
|
324
385
|
*
|
|
325
|
-
* @
|
|
326
|
-
*
|
|
327
|
-
* @
|
|
386
|
+
* Shorthand for creating an {@link updateDateCellTimingToTimezoneFunction} and immediately invoking it.
|
|
387
|
+
*
|
|
388
|
+
* @param timing - timing to update
|
|
389
|
+
* @param timezone - the new IANA timezone
|
|
390
|
+
* @returns the timing with the new timezone applied
|
|
328
391
|
*/
|
|
329
392
|
export declare function updateDateCellTimingToTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T, timezone: TimezoneString): T;
|
|
330
393
|
/**
|
|
@@ -338,32 +401,37 @@ export type ShiftDateCellTimingToTimezoneFunction = (<T extends DateCellTimingSt
|
|
|
338
401
|
readonly _normalInstance: DateTimezoneUtcNormalInstance;
|
|
339
402
|
};
|
|
340
403
|
/**
|
|
341
|
-
* Creates a
|
|
404
|
+
* Creates a function that shifts a timing's startsAt and end to represent the same "wall clock time" in a new timezone.
|
|
405
|
+
*
|
|
406
|
+
* Unlike {@link updateDateCellTimingToTimezoneFunction}, which preserves the absolute instant, this shifts the absolute times
|
|
407
|
+
* so the local time appearance remains the same (e.g. 8AM UTC becomes 8AM Denver).
|
|
342
408
|
*
|
|
343
|
-
* @param
|
|
344
|
-
* @returns
|
|
409
|
+
* @param timezoneInput - the target timezone to shift into
|
|
410
|
+
* @returns a function that shifts timings into the new timezone
|
|
345
411
|
*/
|
|
346
412
|
export declare function shiftDateCellTimingToTimezoneFunction(timezoneInput: DateCellTimingTimezoneInput): ShiftDateCellTimingToTimezoneFunction;
|
|
347
413
|
/**
|
|
348
|
-
*
|
|
414
|
+
* Shifts a timing to the system timezone, preserving the wall clock time appearance.
|
|
349
415
|
*
|
|
350
|
-
* @param timing
|
|
351
|
-
* @returns
|
|
416
|
+
* @param timing - timing to shift
|
|
417
|
+
* @returns the timing shifted to the system timezone
|
|
352
418
|
*/
|
|
353
419
|
export declare function shiftDateCellTimingToSystemTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T): T;
|
|
354
420
|
/**
|
|
355
|
-
*
|
|
421
|
+
* Shifts a timing to UTC, preserving the wall clock time appearance.
|
|
356
422
|
*
|
|
357
|
-
* @param timing
|
|
358
|
-
* @returns
|
|
423
|
+
* @param timing - timing to shift
|
|
424
|
+
* @returns the timing shifted to UTC
|
|
359
425
|
*/
|
|
360
426
|
export declare function shiftDateCellTimingToUTCTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T): T;
|
|
361
427
|
/**
|
|
362
|
-
*
|
|
428
|
+
* Shifts a timing to a new timezone, preserving the wall clock time appearance.
|
|
363
429
|
*
|
|
364
|
-
* @
|
|
365
|
-
*
|
|
366
|
-
* @
|
|
430
|
+
* Shorthand for creating a {@link shiftDateCellTimingToTimezoneFunction} and immediately invoking it.
|
|
431
|
+
*
|
|
432
|
+
* @param timing - timing to shift
|
|
433
|
+
* @param timezone - the target timezone
|
|
434
|
+
* @returns the timing shifted to the new timezone
|
|
367
435
|
*/
|
|
368
436
|
export declare function shiftDateCellTimingToTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T, timezone: DateCellTimingTimezoneInput): T;
|
|
369
437
|
export interface CalculateExpectedDateCellTimingDurationPair {
|
|
@@ -371,33 +439,36 @@ export interface CalculateExpectedDateCellTimingDurationPair {
|
|
|
371
439
|
readonly expectedFinalStartsAt: Date;
|
|
372
440
|
}
|
|
373
441
|
/**
|
|
374
|
-
*
|
|
442
|
+
* Calculates the expected duration and the final event's startsAt from a timing range, accounting for DST transitions.
|
|
375
443
|
*
|
|
376
|
-
* @param timing
|
|
377
|
-
* @returns
|
|
444
|
+
* @param timing - the timing range to analyze
|
|
445
|
+
* @returns the computed duration in minutes and the expected startsAt of the last event
|
|
378
446
|
*/
|
|
379
447
|
export declare function calculateExpectedDateCellTimingDurationPair(timing: DateCellTimingStartsAtEndRange): CalculateExpectedDateCellTimingDurationPair;
|
|
380
448
|
/**
|
|
381
|
-
*
|
|
449
|
+
* Calculates the expected event duration in minutes from a timing range by analyzing the gap between startsAt and end.
|
|
382
450
|
*
|
|
383
|
-
* @param timing
|
|
384
|
-
* @returns
|
|
451
|
+
* @param timing - the timing range to analyze
|
|
452
|
+
* @returns the duration in minutes
|
|
385
453
|
*/
|
|
386
454
|
export declare function calculateExpectedDateCellTimingDuration(timing: DateCellTimingStartsAtEndRange): Minutes;
|
|
387
455
|
/**
|
|
388
|
-
*
|
|
456
|
+
* Converts a {@link DateCellTimingStartsAtEndRange} to a full {@link DateCellTiming} by computing the duration from the range.
|
|
389
457
|
*
|
|
390
|
-
* @param timing
|
|
391
|
-
* @returns DateCellTiming
|
|
458
|
+
* @param timing - the starts-at/end range to convert
|
|
459
|
+
* @returns a DateCellTiming with the calculated duration
|
|
392
460
|
*/
|
|
393
461
|
export declare function dateCellTimingFromDateCellTimingStartsAtEndRange(timing: DateCellTimingStartsAtEndRange): DateCellTiming;
|
|
394
462
|
/**
|
|
395
|
-
*
|
|
463
|
+
* Computes the startsAt time and duration for the final event in a timing range.
|
|
396
464
|
*
|
|
397
|
-
* @param timing
|
|
398
|
-
* @returns DateCellTimingEvent
|
|
465
|
+
* @param timing - the timing range to analyze
|
|
466
|
+
* @returns a DateCellTimingEvent representing the last scheduled event
|
|
399
467
|
*/
|
|
400
468
|
export declare function dateCellTimingFinalStartsAtEvent(timing: DateCellTimingStartsAtEndRange): DateCellTimingEvent;
|
|
469
|
+
/**
|
|
470
|
+
* Detailed validation result for a {@link DateCellTiming}, with individual boolean flags for each validation rule.
|
|
471
|
+
*/
|
|
401
472
|
export interface IsValidDateCellTimingInfo {
|
|
402
473
|
readonly isValid: boolean;
|
|
403
474
|
readonly startsAtHasZeroSeconds: boolean;
|
|
@@ -407,14 +478,27 @@ export interface IsValidDateCellTimingInfo {
|
|
|
407
478
|
readonly isExpectedValidEnd: boolean;
|
|
408
479
|
readonly normalInstance: DateTimezoneUtcNormalInstance;
|
|
409
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* Performs detailed validation of a {@link DateCellTiming}, returning an info object with individual check results.
|
|
483
|
+
*
|
|
484
|
+
* Validates that end is after startsAt, duration is within bounds, startsAt has no fractional seconds, and the computed duration matches the expected value.
|
|
485
|
+
*
|
|
486
|
+
* @param timing - the timing to validate
|
|
487
|
+
* @returns detailed validation info with individual boolean flags
|
|
488
|
+
*/
|
|
410
489
|
export declare function isValidDateCellTimingInfo(timing: DateCellTiming): IsValidDateCellTimingInfo;
|
|
411
490
|
/**
|
|
412
|
-
*
|
|
491
|
+
* Returns true if the {@link DateCellTiming} passes all validation checks.
|
|
413
492
|
*
|
|
414
|
-
* @
|
|
415
|
-
*
|
|
493
|
+
* Shorthand for {@link isValidDateCellTimingInfo} when only the boolean result is needed.
|
|
494
|
+
*
|
|
495
|
+
* @param timing - the timing to validate
|
|
496
|
+
* @returns whether the timing is valid
|
|
416
497
|
*/
|
|
417
498
|
export declare function isValidDateCellTiming(timing: DateCellTiming): boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Extended validation result for a {@link FullDateCellTiming}, adding checks for the derived `start` date alignment.
|
|
501
|
+
*/
|
|
418
502
|
export interface IsValidFullDateCellTimingInfo extends IsValidDateCellTimingInfo {
|
|
419
503
|
readonly isStartRoundedToSeconds: boolean;
|
|
420
504
|
readonly startIsAtMidnight: boolean;
|
|
@@ -422,5 +506,20 @@ export interface IsValidFullDateCellTimingInfo extends IsValidDateCellTimingInfo
|
|
|
422
506
|
readonly startsAtIsAfterStart: boolean;
|
|
423
507
|
readonly startsAtIsLessThan24HoursAfterStart: boolean;
|
|
424
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Performs detailed validation of a {@link FullDateCellTiming}, including all {@link isValidDateCellTimingInfo} checks
|
|
511
|
+
* plus additional checks that the `start` date is at midnight and properly aligned with `startsAt`.
|
|
512
|
+
*
|
|
513
|
+
* @param timing - the full timing to validate
|
|
514
|
+
* @returns detailed validation info with individual boolean flags
|
|
515
|
+
*/
|
|
425
516
|
export declare function isValidFullDateCellTimingInfo(timing: FullDateCellTiming): IsValidFullDateCellTimingInfo;
|
|
517
|
+
/**
|
|
518
|
+
* Returns true if the {@link FullDateCellTiming} passes all validation checks, including start date alignment.
|
|
519
|
+
*
|
|
520
|
+
* Shorthand for {@link isValidFullDateCellTimingInfo} when only the boolean result is needed.
|
|
521
|
+
*
|
|
522
|
+
* @param timing - the full timing to validate
|
|
523
|
+
* @returns whether the timing is valid
|
|
524
|
+
*/
|
|
426
525
|
export declare function isValidFullDateCellTiming(timing: FullDateCellTiming): boolean;
|