@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.
- 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 +17 -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
|
@@ -2,38 +2,48 @@ import { type CalendarDate, type DateRange } from '../date';
|
|
|
2
2
|
import { type DateRRuleInstance } from './date.rrule';
|
|
3
3
|
import { type RRuleLines, type RRuleStringLineSet } from './date.rrule.parse';
|
|
4
4
|
import { type TimezoneString } from '@dereekb/util';
|
|
5
|
+
/**
|
|
6
|
+
* Marks an entity as potentially recurring by carrying optional
|
|
7
|
+
* {@link ModelRecurrenceInfo} and a convenience boolean flag.
|
|
8
|
+
*/
|
|
5
9
|
export interface RecurrenceModel {
|
|
10
|
+
/** Detailed recurrence metadata; undefined when the model does not recur. */
|
|
6
11
|
recur?: ModelRecurrenceInfo;
|
|
12
|
+
/** Quick check for whether this model has active recurrence rules. */
|
|
7
13
|
recurs: boolean;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
10
|
-
*
|
|
16
|
+
* Serializable recurrence metadata stored alongside a model, containing the
|
|
17
|
+
* RRule string, the computed start/end of the recurrence window, and a
|
|
18
|
+
* "forever" flag. Implements {@link DateRange} for easy integration with
|
|
19
|
+
* date-range utilities.
|
|
11
20
|
*/
|
|
12
|
-
export
|
|
13
|
-
/**
|
|
14
|
-
* Timezone the rule is a part of.
|
|
15
|
-
*
|
|
16
|
-
* Required for RRules that have timezone-sensitive implementations.
|
|
17
|
-
*/
|
|
21
|
+
export interface ModelRecurrenceInfo extends DateRange {
|
|
22
|
+
/** Timezone the rule is a part of. Required for RRules that have timezone-sensitive implementations. */
|
|
18
23
|
timezone?: TimezoneString;
|
|
19
|
-
/**
|
|
20
|
-
* RRules for this recurrence.
|
|
21
|
-
*/
|
|
24
|
+
/** RRules for this recurrence. */
|
|
22
25
|
rrule: RRuleLines;
|
|
23
|
-
/**
|
|
24
|
-
* First instance of the recurrence.
|
|
25
|
-
*/
|
|
26
|
+
/** First instance of the recurrence. */
|
|
26
27
|
start: Date;
|
|
27
|
-
/**
|
|
28
|
-
* Final instance of the recurrence.
|
|
29
|
-
*/
|
|
28
|
+
/** Final instance of the recurrence. */
|
|
30
29
|
end: Date;
|
|
31
|
-
/**
|
|
32
|
-
* True if the recurrence has no end.
|
|
33
|
-
*/
|
|
30
|
+
/** True if the recurrence has no end. */
|
|
34
31
|
forever?: boolean;
|
|
35
|
-
constructor(template?: ModelRecurrenceInfo);
|
|
36
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* ArkType schema for {@link ModelRecurrenceInfo}.
|
|
35
|
+
*/
|
|
36
|
+
export declare const modelRecurrenceInfoType: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
37
|
+
rrule: string;
|
|
38
|
+
start: Date;
|
|
39
|
+
end: Date;
|
|
40
|
+
timezone?: string | undefined;
|
|
41
|
+
forever?: boolean | undefined;
|
|
42
|
+
}, {}>;
|
|
43
|
+
/**
|
|
44
|
+
* Input used to create or update recurrence on a model, before it is
|
|
45
|
+
* expanded into a full {@link ModelRecurrenceInfo}.
|
|
46
|
+
*/
|
|
37
47
|
export interface ModelRecurrenceStart {
|
|
38
48
|
/**
|
|
39
49
|
* Lines/set of rules to follow.
|
|
@@ -49,12 +59,46 @@ export interface ModelRecurrenceStart {
|
|
|
49
59
|
timezone?: TimezoneString;
|
|
50
60
|
}
|
|
51
61
|
/**
|
|
52
|
-
*
|
|
62
|
+
* Stateless utility for converting between recurrence input
|
|
63
|
+
* ({@link ModelRecurrenceStart}) and the indexed storage form
|
|
64
|
+
* ({@link ModelRecurrenceInfo}).
|
|
53
65
|
*/
|
|
54
66
|
export declare class ModelRecurrenceInfoUtility {
|
|
55
67
|
/**
|
|
56
|
-
*
|
|
68
|
+
* Expands a {@link ModelRecurrenceStart} into a fully resolved
|
|
69
|
+
* {@link ModelRecurrenceInfo} by parsing the RRule, computing the
|
|
70
|
+
* recurrence date range, and populating the `forever` flag.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const info = ModelRecurrenceInfoUtility.expandModelRecurrenceStartToModelRecurrenceInfo({
|
|
75
|
+
* rrule: ['FREQ=WEEKLY;COUNT=10'],
|
|
76
|
+
* date: { startsAt: new Date(), duration: 3600000 },
|
|
77
|
+
* timezone: 'America/Chicago'
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param update - The recurrence start input to expand.
|
|
82
|
+
* @returns A new {@link ModelRecurrenceInfo} with computed start, end, and forever fields.
|
|
57
83
|
*/
|
|
58
84
|
static expandModelRecurrenceStartToModelRecurrenceInfo(update: ModelRecurrenceStart): ModelRecurrenceInfo;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a {@link DateRRuleInstance} from stored {@link ModelRecurrenceInfo}
|
|
87
|
+
* and a reference {@link CalendarDate}, allowing further expansion or
|
|
88
|
+
* recurrence queries.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const instance = ModelRecurrenceInfoUtility.makeDateRRuleInstance(
|
|
93
|
+
* model.recur,
|
|
94
|
+
* { startsAt: new Date(), duration: 3600000 }
|
|
95
|
+
* );
|
|
96
|
+
* const nextDate = instance.nextRecurrenceDate();
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param info - Stored recurrence metadata.
|
|
100
|
+
* @param date - Reference calendar date providing startsAt and duration.
|
|
101
|
+
* @returns A new {@link DateRRuleInstance} ready for expansion.
|
|
102
|
+
*/
|
|
59
103
|
static makeDateRRuleInstance(info: ModelRecurrenceInfo, date: CalendarDate): DateRRuleInstance;
|
|
60
104
|
}
|
|
@@ -5,9 +5,15 @@ import { type BaseDateAsUTC, DateTimezoneUtcNormalInstance } from '../date/date.
|
|
|
5
5
|
import { DateRRule } from './date.rrule.extension';
|
|
6
6
|
import { type RRuleLines, type RRuleStringLineSet, type RRuleStringSetSeparation } from './date.rrule.parse';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Alias emphasizing that dates passed to the RRule library must be expressed
|
|
9
|
+
* in UTC, since RRule internally treats all timestamps as UTC.
|
|
9
10
|
*/
|
|
10
11
|
export type RRuleBaseDateAsUTC = BaseDateAsUTC;
|
|
12
|
+
/**
|
|
13
|
+
* Options controlling which portion of a recurrence rule is expanded into
|
|
14
|
+
* concrete dates. Provide either a resolved {@link DateRange} or
|
|
15
|
+
* {@link DateRangeParams} to limit the expansion window.
|
|
16
|
+
*/
|
|
11
17
|
export interface DateRRuleExpansionOptions {
|
|
12
18
|
/**
|
|
13
19
|
* Start/End Dates to get the range between.
|
|
@@ -18,6 +24,10 @@ export interface DateRRuleExpansionOptions {
|
|
|
18
24
|
*/
|
|
19
25
|
rangeParams?: DateRangeParams;
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Parameters for constructing a {@link DateRRuleInstance}. Exactly one of
|
|
29
|
+
* `rruleLines` or `rruleStringLineSet` must be provided.
|
|
30
|
+
*/
|
|
21
31
|
export interface MakeDateRRuleInstance {
|
|
22
32
|
/**
|
|
23
33
|
* Lines string to build an RRule from.
|
|
@@ -32,6 +42,10 @@ export interface MakeDateRRuleInstance {
|
|
|
32
42
|
*/
|
|
33
43
|
options: DateRRuleInstanceOptions;
|
|
34
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Expansion options accepted by the static {@link DateRRuleUtility.expand}
|
|
47
|
+
* method. Provide either a pre-built instance or parameters to build one.
|
|
48
|
+
*/
|
|
35
49
|
export interface DateRRuleStaticExpansionOptions extends DateRRuleExpansionOptions {
|
|
36
50
|
/**
|
|
37
51
|
* DateRRuleInstanceInstance to use for expansion.
|
|
@@ -42,6 +56,10 @@ export interface DateRRuleStaticExpansionOptions extends DateRRuleExpansionOptio
|
|
|
42
56
|
*/
|
|
43
57
|
instanceFrom?: MakeDateRRuleInstance;
|
|
44
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Result of expanding a recurrence rule, containing the resolved dates and
|
|
61
|
+
* the optional range that was used to bound the expansion.
|
|
62
|
+
*/
|
|
45
63
|
export interface DateRRuleExpansion {
|
|
46
64
|
/**
|
|
47
65
|
* Range used for expansion, if applicable.
|
|
@@ -49,6 +67,10 @@ export interface DateRRuleExpansion {
|
|
|
49
67
|
between?: Maybe<DateRange>;
|
|
50
68
|
dates: CalendarDate[];
|
|
51
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Configuration supplied when constructing a {@link DateRRuleInstance},
|
|
72
|
+
* including the reference date, optional timezone, and dates to exclude.
|
|
73
|
+
*/
|
|
52
74
|
export interface DateRRuleInstanceOptions {
|
|
53
75
|
/**
|
|
54
76
|
* Start reference/date. Required if DTSTART is not provided.
|
|
@@ -65,6 +87,10 @@ export interface DateRRuleInstanceOptions {
|
|
|
65
87
|
*/
|
|
66
88
|
exclude?: DateSet;
|
|
67
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A {@link DateRange} extended with recurrence-specific metadata, indicating
|
|
92
|
+
* whether the recurrence runs indefinitely and when the last occurrence ends.
|
|
93
|
+
*/
|
|
68
94
|
export interface RecurrenceDateRange extends DateRange {
|
|
69
95
|
/**
|
|
70
96
|
* True if the recurrence never ends.
|
|
@@ -77,49 +103,146 @@ export interface RecurrenceDateRange extends DateRange {
|
|
|
77
103
|
*/
|
|
78
104
|
finalRecurrenceEndsAt?: Maybe<Date>;
|
|
79
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Narrowed variant of {@link RecurrenceDateRange} for rules with no end
|
|
108
|
+
* (`forever: true`), guaranteeing `finalRecurrenceEndsAt` is undefined.
|
|
109
|
+
*/
|
|
80
110
|
export interface ForeverRecurrenceDateRange extends RecurrenceDateRange {
|
|
81
111
|
forever: true;
|
|
82
112
|
finalRecurrenceEndsAt?: undefined;
|
|
83
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Wraps an RRule with timezone-aware date normalization so that recurrence
|
|
116
|
+
* expansion, next-date lookups, and range checks all work correctly across
|
|
117
|
+
* timezones.
|
|
118
|
+
*
|
|
119
|
+
* Use the static {@link DateRRuleInstance.make} factory or
|
|
120
|
+
* {@link DateRRuleUtility.makeInstance} to create instances.
|
|
121
|
+
*/
|
|
84
122
|
export declare class DateRRuleInstance {
|
|
85
123
|
readonly options: DateRRuleInstanceOptions;
|
|
86
124
|
readonly rrule: DateRRule;
|
|
87
125
|
readonly normalInstance: DateTimezoneUtcNormalInstance;
|
|
88
126
|
/**
|
|
89
|
-
*
|
|
127
|
+
* Factory that parses the RRule string, merges excluded dates, and builds
|
|
128
|
+
* a fully configured instance.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const instance = DateRRuleInstance.make({
|
|
133
|
+
* rruleLines: 'FREQ=DAILY;COUNT=5',
|
|
134
|
+
* options: { date: { startsAt: new Date(), duration: 3600000 }, timezone: 'America/Chicago' }
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @param params - RRule source and instance options.
|
|
139
|
+
* @throws Error if neither `rruleLines` nor `rruleStringLineSet` is provided.
|
|
140
|
+
* @returns A new {@link DateRRuleInstance}.
|
|
90
141
|
*/
|
|
91
142
|
static make(params: MakeDateRRuleInstance): DateRRuleInstance;
|
|
92
143
|
constructor(rrule: RRule, options: DateRRuleInstanceOptions);
|
|
93
144
|
get timezone(): TimezoneString;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the next recurrence date on or after the given reference date,
|
|
147
|
+
* or `undefined` if the recurrence has ended.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const next = instance.nextRecurrenceDate(new Date());
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @param from - Reference point; defaults to now.
|
|
155
|
+
* @returns The next occurrence date, or `undefined`.
|
|
156
|
+
*/
|
|
94
157
|
nextRecurrenceDate(from?: Date): Maybe<Date>;
|
|
95
158
|
/**
|
|
96
|
-
* Expands the
|
|
159
|
+
* Expands the recurrence rule into concrete {@link CalendarDate} instances,
|
|
160
|
+
* optionally bounded by a date range.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const expansion = instance.expand({
|
|
165
|
+
* range: { start: new Date('2026-01-01'), end: new Date('2026-12-31') }
|
|
166
|
+
* });
|
|
167
|
+
* console.log(expansion.dates.length);
|
|
168
|
+
* ```
|
|
97
169
|
*
|
|
98
|
-
* @param options
|
|
99
|
-
* @
|
|
170
|
+
* @param options - Range constraints for the expansion.
|
|
171
|
+
* @throws Error when the rule expands infinitely and no range is provided.
|
|
172
|
+
* @returns The expanded dates and the resolved range used.
|
|
100
173
|
*/
|
|
101
174
|
expand(options: DateRRuleExpansionOptions): DateRRuleExpansion;
|
|
102
175
|
/**
|
|
103
|
-
*
|
|
176
|
+
* Checks whether at least one recurrence falls within the given date range.
|
|
177
|
+
*
|
|
178
|
+
* @param dateRange - The range to test against.
|
|
179
|
+
* @returns `true` if any occurrence exists within the range.
|
|
104
180
|
*/
|
|
105
181
|
haveRecurrenceInDateRange(dateRange: DateRange): boolean;
|
|
106
182
|
/**
|
|
107
|
-
*
|
|
183
|
+
* Computes the full date range spanned by this recurrence, from its first
|
|
184
|
+
* occurrence to the end of its last occurrence (accounting for event
|
|
185
|
+
* duration). Returns a {@link ForeverRecurrenceDateRange} when the rule
|
|
186
|
+
* has no count or until constraint.
|
|
187
|
+
*
|
|
188
|
+
* @returns The recurrence date range with `forever` flag and optional `finalRecurrenceEndsAt`.
|
|
108
189
|
*/
|
|
109
190
|
getRecurrenceDateRange(): RecurrenceDateRange | ForeverRecurrenceDateRange;
|
|
191
|
+
/**
|
|
192
|
+
* Returns `true` when the underlying RRule has neither a `count` nor an
|
|
193
|
+
* `until` constraint, meaning it recurs indefinitely.
|
|
194
|
+
*/
|
|
110
195
|
hasForeverRange(): boolean;
|
|
111
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Parsed RRule options combining the separated string components with the
|
|
199
|
+
* native `rrule` library's partial {@link Options}.
|
|
200
|
+
*/
|
|
112
201
|
export interface RRuleOptions extends RRuleStringSetSeparation {
|
|
113
202
|
/**
|
|
114
203
|
* Options for an RRule instance
|
|
115
204
|
*/
|
|
116
205
|
options: Partial<Options>;
|
|
117
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Stateless utility providing convenience factory and expansion methods for
|
|
209
|
+
* {@link DateRRuleInstance}. Prefer these static methods over constructing
|
|
210
|
+
* instances manually.
|
|
211
|
+
*/
|
|
118
212
|
export declare class DateRRuleUtility {
|
|
119
213
|
/**
|
|
120
|
-
*
|
|
214
|
+
* Expands a recurrence rule into concrete dates using either a pre-built
|
|
215
|
+
* instance or parameters to build one on-the-fly.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const result = DateRRuleUtility.expand({
|
|
220
|
+
* instanceFrom: {
|
|
221
|
+
* rruleLines: 'FREQ=WEEKLY;COUNT=4',
|
|
222
|
+
* options: { date: { startsAt: new Date(), duration: 3600000 } }
|
|
223
|
+
* },
|
|
224
|
+
* range: { start: new Date('2026-01-01'), end: new Date('2026-03-01') }
|
|
225
|
+
* });
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @param options - Instance (or parameters to create one) and optional range.
|
|
229
|
+
* @throws Error if neither `instance` nor `instanceFrom` is provided.
|
|
230
|
+
* @returns The expansion result containing resolved dates.
|
|
121
231
|
*/
|
|
122
232
|
static expand(options: DateRRuleStaticExpansionOptions): DateRRuleExpansion;
|
|
233
|
+
/**
|
|
234
|
+
* Convenience alias for {@link DateRRuleInstance.make}.
|
|
235
|
+
*
|
|
236
|
+
* @param params - RRule source and instance options.
|
|
237
|
+
* @returns A new {@link DateRRuleInstance}.
|
|
238
|
+
*/
|
|
123
239
|
static makeInstance(params: MakeDateRRuleInstance): DateRRuleInstance;
|
|
240
|
+
/**
|
|
241
|
+
* Parses an {@link RRuleStringLineSet} into native {@link RRuleOptions}
|
|
242
|
+
* that can be fed into the `rrule` library.
|
|
243
|
+
*
|
|
244
|
+
* @param rruleStringLineSet - The raw RRule string set to parse.
|
|
245
|
+
* @returns Parsed options including separated EXDATE and basic rule components.
|
|
246
|
+
*/
|
|
124
247
|
static toRRuleOptions(rruleStringLineSet: RRuleStringLineSet): RRuleOptions;
|
|
125
248
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type Maybe } from '@dereekb/util';
|
|
2
2
|
import { RRule } from 'rrule';
|
|
3
|
+
/**
|
|
4
|
+
* Internal iteration arguments used by the RRule iteration engine.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the shape expected by RRule's `_iter` method for custom iteration control.
|
|
7
|
+
*/
|
|
3
8
|
export interface IterArgs {
|
|
4
9
|
inc: boolean;
|
|
5
10
|
before: Date;
|
|
@@ -7,26 +12,53 @@ export interface IterArgs {
|
|
|
7
12
|
dt: Date;
|
|
8
13
|
_value: Date | Date[] | null;
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Safety limit to prevent infinite iteration over unbounded recurrence rules.
|
|
17
|
+
*/
|
|
10
18
|
export declare const DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED = 10000;
|
|
19
|
+
/**
|
|
20
|
+
* Extended RRule that adds convenience methods for querying recurrence dates
|
|
21
|
+
* using custom iteration strategies (`last`, `next`, `any`).
|
|
22
|
+
*
|
|
23
|
+
* Works around missing typings in the upstream RRule library.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const rule = new DateRRule({ freq: RRule.DAILY, dtstart: new Date() });
|
|
28
|
+
* const lastDate = rule.last();
|
|
29
|
+
* const nextDate = rule.next(new Date());
|
|
30
|
+
* const hasAny = rule.any({ minDate: startDate, maxDate: endDate });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
11
33
|
export declare class DateRRule extends RRule {
|
|
12
34
|
/**
|
|
13
|
-
* Returns the last
|
|
35
|
+
* Returns the last occurrence in the rule chain, up to the configured max iteration limit.
|
|
14
36
|
*
|
|
15
|
-
* @
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const rule = new DateRRule({ freq: RRule.DAILY, count: 5, dtstart: startDate });
|
|
40
|
+
* const lastDate = rule.last(); // fifth occurrence
|
|
41
|
+
* ```
|
|
16
42
|
*/
|
|
17
43
|
last(): Maybe<Date>;
|
|
18
44
|
/**
|
|
19
|
-
* Returns the
|
|
45
|
+
* Returns the first recurrence that occurs on or after the given date.
|
|
20
46
|
*
|
|
21
|
-
* @
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const rule = new DateRRule({ freq: RRule.WEEKLY, dtstart: startDate });
|
|
50
|
+
* const nextDate = rule.next(new Date());
|
|
51
|
+
* ```
|
|
22
52
|
*/
|
|
23
53
|
next(minDate: Date): Maybe<Date>;
|
|
24
54
|
/**
|
|
25
|
-
*
|
|
55
|
+
* Checks whether any recurrence falls within the optional date bounds.
|
|
26
56
|
*
|
|
27
|
-
* @
|
|
28
|
-
*
|
|
29
|
-
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const rule = new DateRRule({ freq: RRule.DAILY, dtstart: startDate });
|
|
60
|
+
* const exists = rule.any({ minDate: rangeStart, maxDate: rangeEnd });
|
|
61
|
+
* ```
|
|
30
62
|
*/
|
|
31
63
|
any(filter?: {
|
|
32
64
|
minDate?: Maybe<Date>;
|
|
@@ -47,7 +79,8 @@ declare abstract class BaseRRuleIter {
|
|
|
47
79
|
getValue(): Date | null;
|
|
48
80
|
}
|
|
49
81
|
/**
|
|
50
|
-
*
|
|
82
|
+
* Iterator result that captures the last date encountered before reaching the max future date
|
|
83
|
+
* or the iteration limit. Used by {@link DateRRule.last}.
|
|
51
84
|
*/
|
|
52
85
|
export declare class LastIterResult extends BaseRRuleIter {
|
|
53
86
|
private readonly _maxIterationsAllowed;
|
|
@@ -58,6 +91,10 @@ export declare class LastIterResult extends BaseRRuleIter {
|
|
|
58
91
|
add(date: Date): boolean;
|
|
59
92
|
clone(): LastIterResult;
|
|
60
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Iterator result that finds the first recurrence on or after a minimum date.
|
|
96
|
+
* Stops iteration as soon as a qualifying date is found. Used by {@link DateRRule.next}.
|
|
97
|
+
*/
|
|
61
98
|
export declare class NextIterResult extends BaseRRuleIter {
|
|
62
99
|
readonly minDate: Date;
|
|
63
100
|
readonly maxIterationsAllowed: number;
|
|
@@ -67,6 +104,10 @@ export declare class NextIterResult extends BaseRRuleIter {
|
|
|
67
104
|
add(date: Date): boolean;
|
|
68
105
|
clone(): NextIterResult;
|
|
69
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Iterator result that checks whether any recurrence falls within an optional date range.
|
|
109
|
+
* Stops as soon as one qualifying date is found. Used by {@link DateRRule.any}.
|
|
110
|
+
*/
|
|
70
111
|
export declare class AnyIterResult extends BaseRRuleIter {
|
|
71
112
|
readonly maxIterationsAllowed: number;
|
|
72
113
|
readonly minDate: Date | null;
|
|
@@ -23,6 +23,9 @@ export type RRuleRawParamString = string;
|
|
|
23
23
|
* Set of values.
|
|
24
24
|
*/
|
|
25
25
|
export type RRuleRawValueSetString = CommaSeparatedString;
|
|
26
|
+
/**
|
|
27
|
+
* A single raw value from an RRule value set.
|
|
28
|
+
*/
|
|
26
29
|
export type RRuleRawValueString = string;
|
|
27
30
|
/**
|
|
28
31
|
* RRule line broken into a name and value.
|
|
@@ -66,6 +69,9 @@ export type RFC5545DateString = string;
|
|
|
66
69
|
* https://datatracker.ietf.org/doc/html/rfc5545#section-3.3.5
|
|
67
70
|
*/
|
|
68
71
|
export type RFC5545DateTimeString = string;
|
|
72
|
+
/**
|
|
73
|
+
* Result of separating an RRule string set into basic rules and parsed EXDATE exclusions.
|
|
74
|
+
*/
|
|
69
75
|
export interface RRuleStringSetSeparation {
|
|
70
76
|
/**
|
|
71
77
|
* All of the original input.
|
|
@@ -93,24 +99,101 @@ export interface RRuleExdateAttribute {
|
|
|
93
99
|
*/
|
|
94
100
|
dates: Date[];
|
|
95
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Delimiter separating the property name/params from values in an RRule line.
|
|
104
|
+
*/
|
|
96
105
|
export declare const RRuleStringSplitter = ":";
|
|
106
|
+
/**
|
|
107
|
+
* Utility class for parsing and manipulating RFC 5545 RRule strings.
|
|
108
|
+
*
|
|
109
|
+
* Provides static methods for separating EXDATE rules, parsing RFC 5545 date-time strings,
|
|
110
|
+
* and converting between raw line formats and structured property representations.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const lines = DateRRuleParseUtility.toRRuleStringSet(rruleString);
|
|
115
|
+
* const { basic, exdates } = DateRRuleParseUtility.separateRRuleStringSetValues(lines);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
97
118
|
export declare class DateRRuleParseUtility {
|
|
119
|
+
/**
|
|
120
|
+
* Splits an RRule line set into basic rules and parsed EXDATE exclusion dates.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const result = DateRRuleParseUtility.separateRRuleStringSetValues([
|
|
125
|
+
* 'RRULE:FREQ=DAILY',
|
|
126
|
+
* 'EXDATE:20210611T110000Z'
|
|
127
|
+
* ]);
|
|
128
|
+
* // result.basic = ['RRULE:FREQ=DAILY']
|
|
129
|
+
* // result.exdates contains the parsed exclusion dates
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
98
132
|
static separateRRuleStringSetValues(input: RRuleStringLineSet): RRuleStringSetSeparation;
|
|
133
|
+
/**
|
|
134
|
+
* Parses an EXDATE line into its timezone and date components.
|
|
135
|
+
*
|
|
136
|
+
* @throws Error if the line is not an EXDATE property.
|
|
137
|
+
*/
|
|
99
138
|
static parseExdateAttributeFromLine(line: RRuleLineString): RRuleExdateAttribute;
|
|
139
|
+
/**
|
|
140
|
+
* Extracts timezone and UTC-normalized dates from an already-parsed EXDATE property.
|
|
141
|
+
*/
|
|
100
142
|
static parseExdateAttributeFromProperty(property: RRuleProperty): RRuleExdateAttribute;
|
|
143
|
+
/**
|
|
144
|
+
* Convenience wrapper that creates a timezone converter and delegates to {@link parseDateTimeString}.
|
|
145
|
+
*
|
|
146
|
+
* @throws Error if the date string is not UTC and no timezone is provided.
|
|
147
|
+
*/
|
|
101
148
|
static parseDateTimeStringWithTimezone(rfcDateString: RFC5545DateString | RFC5545DateTimeString, timezone: Maybe<string>): Date;
|
|
102
149
|
/**
|
|
103
|
-
* Parses
|
|
150
|
+
* Parses an RFC 5545 date or date-time string into a JavaScript Date.
|
|
151
|
+
*
|
|
152
|
+
* If the string does not end in `Z` (indicating UTC), the converter is used to normalize
|
|
153
|
+
* the local date representation to its true UTC equivalent.
|
|
104
154
|
*
|
|
105
|
-
*
|
|
155
|
+
* @throws Error if the string cannot be parsed or a non-UTC string lacks a converter.
|
|
106
156
|
*/
|
|
107
157
|
static parseDateTimeString(rfcDateString: RFC5545DateString | RFC5545DateTimeString, converter: Maybe<DateTimezoneBaseDateConverter>): Date;
|
|
158
|
+
/**
|
|
159
|
+
* Formats a Date as an RFC 5545 UTC date-time string (e.g., `"20210611T110000Z"`).
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* DateRRuleParseUtility.formatDateTimeString(new Date('2021-06-11T11:00:00Z'));
|
|
164
|
+
* // => '20210611T110000Z'
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
108
167
|
static formatDateTimeString(date: Date): RFC5545DateTimeString;
|
|
168
|
+
/**
|
|
169
|
+
* Parses a full RRule line string into a structured {@link RRuleProperty}.
|
|
170
|
+
*/
|
|
109
171
|
static parseProperty(line: RRuleLineString): RRuleProperty;
|
|
172
|
+
/**
|
|
173
|
+
* Converts an {@link RRuleRawLine} into a structured {@link RRuleProperty} by splitting the type and params.
|
|
174
|
+
*/
|
|
110
175
|
static propertyFromRawLine(rawLine: RRuleRawLine): RRuleProperty;
|
|
176
|
+
/**
|
|
177
|
+
* Splits a raw param string (e.g., `"TZID=America/New_York"`) into key-value form.
|
|
178
|
+
*/
|
|
111
179
|
static parseRawParam(param: RRuleRawParamString): RRuleParam;
|
|
180
|
+
/**
|
|
181
|
+
* Splits a raw line at the colon delimiter into params and values portions.
|
|
182
|
+
* Falls back to treating a single-segment line as an RRULE value.
|
|
183
|
+
*/
|
|
112
184
|
static parseRawLine(line: RRuleLineString): RRuleRawLine;
|
|
185
|
+
/**
|
|
186
|
+
* Splits a newline-delimited RRule string into individual line strings.
|
|
187
|
+
*/
|
|
113
188
|
static toRRuleStringSet(lines: RRuleLines): RRuleStringLineSet;
|
|
189
|
+
/**
|
|
190
|
+
* Joins an array of RRule line strings into a single newline-delimited string.
|
|
191
|
+
*/
|
|
114
192
|
static toRRuleLines(rruleStringSet: RRuleStringLineSet): RRuleLines;
|
|
193
|
+
/**
|
|
194
|
+
* Asserts that the property has the expected type, throwing if it does not match.
|
|
195
|
+
*
|
|
196
|
+
* @throws Error if the property type does not match the expected type.
|
|
197
|
+
*/
|
|
115
198
|
static assertPropertyType(type: RRulePropertyType, property: RRuleProperty): void;
|
|
116
199
|
}
|