@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.
@@ -7,9 +7,13 @@ import { type TimezoneString } from '@dereekb/util';
7
7
  * {@link ModelRecurrenceInfo} and a convenience boolean flag.
8
8
  */
9
9
  export interface RecurrenceModel {
10
- /** Detailed recurrence metadata; undefined when the model does not recur. */
10
+ /**
11
+ * Detailed recurrence metadata; undefined when the model does not recur.
12
+ */
11
13
  recur?: ModelRecurrenceInfo;
12
- /** Quick check for whether this model has active recurrence rules. */
14
+ /**
15
+ * Quick check for whether this model has active recurrence rules.
16
+ */
13
17
  recurs: boolean;
14
18
  }
15
19
  /**
@@ -19,15 +23,25 @@ export interface RecurrenceModel {
19
23
  * date-range utilities.
20
24
  */
21
25
  export interface ModelRecurrenceInfo extends DateRange {
22
- /** Timezone the rule is a part of. Required for RRules that have timezone-sensitive implementations. */
26
+ /**
27
+ * Timezone the rule is a part of. Required for RRules that have timezone-sensitive implementations.
28
+ */
23
29
  timezone?: TimezoneString;
24
- /** RRules for this recurrence. */
30
+ /**
31
+ * RRules for this recurrence.
32
+ */
25
33
  rrule: RRuleLines;
26
- /** First instance of the recurrence. */
34
+ /**
35
+ * First instance of the recurrence.
36
+ */
27
37
  start: Date;
28
- /** Final instance of the recurrence. */
38
+ /**
39
+ * Final instance of the recurrence.
40
+ */
29
41
  end: Date;
30
- /** True if the recurrence has no end. */
42
+ /**
43
+ * True if the recurrence has no end.
44
+ */
31
45
  forever?: boolean;
32
46
  }
33
47
  /**
@@ -191,6 +191,8 @@ export declare class DateRRuleInstance {
191
191
  /**
192
192
  * Returns `true` when the underlying RRule has neither a `count` nor an
193
193
  * `until` constraint, meaning it recurs indefinitely.
194
+ *
195
+ * @returns `true` if the rule recurs indefinitely.
194
196
  */
195
197
  hasForeverRange(): boolean;
196
198
  }
@@ -39,6 +39,8 @@ export declare class DateRRule extends RRule {
39
39
  * const rule = new DateRRule({ freq: RRule.DAILY, count: 5, dtstart: startDate });
40
40
  * const lastDate = rule.last(); // fifth occurrence
41
41
  * ```
42
+ *
43
+ * @returns The last occurrence date, or `undefined` if there are none.
42
44
  */
43
45
  last(): Maybe<Date>;
44
46
  /**
@@ -49,6 +51,9 @@ export declare class DateRRule extends RRule {
49
51
  * const rule = new DateRRule({ freq: RRule.WEEKLY, dtstart: startDate });
50
52
  * const nextDate = rule.next(new Date());
51
53
  * ```
54
+ *
55
+ * @param minDate - The earliest date to consider.
56
+ * @returns The first occurrence on or after `minDate`, or `undefined` if none.
52
57
  */
53
58
  next(minDate: Date): Maybe<Date>;
54
59
  /**
@@ -59,6 +64,11 @@ export declare class DateRRule extends RRule {
59
64
  * const rule = new DateRRule({ freq: RRule.DAILY, dtstart: startDate });
60
65
  * const exists = rule.any({ minDate: rangeStart, maxDate: rangeEnd });
61
66
  * ```
67
+ *
68
+ * @param filter - Optional date bounds with `minDate` and `maxDate`.
69
+ * @param filter.minDate - Optional minimum date bound.
70
+ * @param filter.maxDate - Optional maximum date bound.
71
+ * @returns `true` if at least one recurrence falls within the bounds.
62
72
  */
63
73
  any(filter?: {
64
74
  minDate?: Maybe<Date>;
@@ -103,7 +103,9 @@ export interface RRuleExdateAttribute {
103
103
  * Delimiter separating the property name/params from values in an RRule line.
104
104
  */
105
105
  export declare const RRULE_STRING_SPLITTER = ":";
106
- /** @deprecated use RRULE_STRING_SPLITTER instead. */
106
+ /**
107
+ * @deprecated use RRULE_STRING_SPLITTER instead.
108
+ */
107
109
  export declare const RRuleStringSplitter = ":";
108
110
  /**
109
111
  * Utility class for parsing and manipulating RFC 5545 RRule strings.
@@ -130,21 +132,32 @@ export declare class DateRRuleParseUtility {
130
132
  * // result.basic = ['RRULE:FREQ=DAILY']
131
133
  * // result.exdates contains the parsed exclusion dates
132
134
  * ```
135
+ *
136
+ * @param input - The RRule string line set to separate.
137
+ * @returns The separated basic rules and parsed EXDATE exclusion dates.
133
138
  */
134
139
  static separateRRuleStringSetValues(input: RRuleStringLineSet): RRuleStringSetSeparation;
135
140
  /**
136
141
  * Parses an EXDATE line into its timezone and date components.
137
142
  *
143
+ * @param line - The raw EXDATE line string to parse.
144
+ * @returns The parsed EXDATE attribute with timezone and dates.
138
145
  * @throws Error if the line is not an EXDATE property.
139
146
  */
140
147
  static parseExdateAttributeFromLine(line: RRuleLineString): RRuleExdateAttribute;
141
148
  /**
142
149
  * Extracts timezone and UTC-normalized dates from an already-parsed EXDATE property.
150
+ *
151
+ * @param property - The parsed EXDATE property to extract from.
152
+ * @returns The EXDATE attribute containing timezone and UTC-normalized dates.
143
153
  */
144
154
  static parseExdateAttributeFromProperty(property: RRuleProperty): RRuleExdateAttribute;
145
155
  /**
146
156
  * Convenience wrapper that creates a timezone converter and delegates to {@link parseDateTimeString}.
147
157
  *
158
+ * @param rfcDateString - The RFC 5545 date or date-time string to parse.
159
+ * @param timezone - Optional timezone for non-UTC date strings.
160
+ * @returns The parsed JavaScript Date.
148
161
  * @throws Error if the date string is not UTC and no timezone is provided.
149
162
  */
150
163
  static parseDateTimeStringWithTimezone(rfcDateString: RFC5545DateString | RFC5545DateTimeString, timezone: Maybe<string>): Date;
@@ -154,6 +167,9 @@ export declare class DateRRuleParseUtility {
154
167
  * If the string does not end in `Z` (indicating UTC), the converter is used to normalize
155
168
  * the local date representation to its true UTC equivalent.
156
169
  *
170
+ * @param rfcDateString - The RFC 5545 date or date-time string to parse.
171
+ * @param converter - Optional timezone converter for non-UTC date strings.
172
+ * @returns The parsed JavaScript Date.
157
173
  * @throws Error if the string cannot be parsed or a non-UTC string lacks a converter.
158
174
  */
159
175
  static parseDateTimeString(rfcDateString: RFC5545DateString | RFC5545DateTimeString, converter: Maybe<DateTimezoneBaseDateConverter>): Date;
@@ -165,36 +181,59 @@ export declare class DateRRuleParseUtility {
165
181
  * DateRRuleParseUtility.formatDateTimeString(new Date('2021-06-11T11:00:00Z'));
166
182
  * // => '20210611T110000Z'
167
183
  * ```
184
+ *
185
+ * @param date - The date to format.
186
+ * @returns The RFC 5545 UTC date-time string representation.
168
187
  */
169
188
  static formatDateTimeString(date: Date): RFC5545DateTimeString;
170
189
  /**
171
190
  * Parses a full RRule line string into a structured {@link RRuleProperty}.
191
+ *
192
+ * @param line - The raw RRule line string to parse.
193
+ * @returns The structured property with type, params, and values.
172
194
  */
173
195
  static parseProperty(line: RRuleLineString): RRuleProperty;
174
196
  /**
175
197
  * Converts an {@link RRuleRawLine} into a structured {@link RRuleProperty} by splitting the type and params.
198
+ *
199
+ * @param rawLine - The raw line to convert.
200
+ * @returns The structured property with separated type, params, and values.
176
201
  */
177
202
  static propertyFromRawLine(rawLine: RRuleRawLine): RRuleProperty;
178
203
  /**
179
204
  * Splits a raw param string (e.g., `"TZID=America/New_York"`) into key-value form.
205
+ *
206
+ * @param param - The raw param string to split.
207
+ * @returns The parsed key-value param.
180
208
  */
181
209
  static parseRawParam(param: RRuleRawParamString): RRuleParam;
182
210
  /**
183
211
  * Splits a raw line at the colon delimiter into params and values portions.
184
212
  * Falls back to treating a single-segment line as an RRULE value.
213
+ *
214
+ * @param line - The raw RRule line string to split.
215
+ * @returns The raw line with separated params and values.
185
216
  */
186
217
  static parseRawLine(line: RRuleLineString): RRuleRawLine;
187
218
  /**
188
219
  * Splits a newline-delimited RRule string into individual line strings.
220
+ *
221
+ * @param lines - The newline-delimited RRule string to split.
222
+ * @returns An array of individual RRule line strings.
189
223
  */
190
224
  static toRRuleStringSet(lines: RRuleLines): RRuleStringLineSet;
191
225
  /**
192
226
  * Joins an array of RRule line strings into a single newline-delimited string.
227
+ *
228
+ * @param rruleStringSet - The array of RRule line strings to join.
229
+ * @returns A single newline-delimited RRule string.
193
230
  */
194
231
  static toRRuleLines(rruleStringSet: RRuleStringLineSet): RRuleLines;
195
232
  /**
196
233
  * Asserts that the property has the expected type, throwing if it does not match.
197
234
  *
235
+ * @param type - The expected property type.
236
+ * @param property - The property to check.
198
237
  * @throws Error if the property type does not match the expected type.
199
238
  */
200
239
  static assertPropertyType(type: RRulePropertyType, property: RRuleProperty): void;
@@ -1,2 +1 @@
1
1
  export * from './timezone';
2
- export * from './timezone.validator';
@@ -2,6 +2,8 @@ import { type Maybe, type TimezoneAbbreviation, type TimezoneString, type Timezo
2
2
  /**
3
3
  * Returns all recognized IANA timezone strings, including the explicit UTC entry.
4
4
  *
5
+ * @returns all known IANA timezone strings plus UTC
6
+ *
5
7
  * @example
6
8
  * ```ts
7
9
  * const zones = allTimezoneStrings();
@@ -32,18 +34,28 @@ export declare const allTimezoneInfos: import("@dereekb/util").CachedFactoryWith
32
34
  * {@link searchTimezoneInfos} can perform fast case-insensitive matching.
33
35
  */
34
36
  export interface TimezoneInfo extends TimezoneStringRef {
35
- /** Searchable form with slashes/underscores replaced by spaces and lowercased. */
37
+ /**
38
+ * Searchable form with slashes/underscores replaced by spaces and lowercased.
39
+ */
36
40
  readonly search: string;
37
- /** Lowercased IANA timezone identifier. */
41
+ /**
42
+ * Lowercased IANA timezone identifier.
43
+ */
38
44
  readonly lowercase: string;
39
- /** Short abbreviation (e.g., `"EST"`, `"PDT"`). */
45
+ /**
46
+ * Short abbreviation (e.g., `"EST"`, `"PDT"`).
47
+ */
40
48
  readonly abbreviation: string;
41
- /** Lowercased abbreviation for case-insensitive matching. */
49
+ /**
50
+ * Lowercased abbreviation for case-insensitive matching.
51
+ */
42
52
  readonly lowercaseAbbreviation: string;
43
53
  }
44
54
  /**
45
55
  * Returns the {@link TimezoneInfo} for the current system timezone, falling back to UTC.
46
56
  *
57
+ * @returns timezone info for the current system timezone
58
+ *
47
59
  * @example
48
60
  * ```ts
49
61
  * const info = timezoneInfoForSystem();
@@ -57,6 +69,10 @@ export declare function timezoneInfoForSystem(): TimezoneInfo;
57
69
  * The date matters because abbreviations change with DST transitions.
58
70
  * Returns `"UKNOWN"` if no timezone is provided.
59
71
  *
72
+ * @param timezone - the IANA timezone string (or UTC abbreviation) to get the abbreviation for
73
+ * @param date - the date at which to evaluate the abbreviation (defaults to now)
74
+ * @returns the short timezone abbreviation
75
+ *
60
76
  * @example
61
77
  * ```ts
62
78
  * getTimezoneAbbreviation('America/New_York'); // 'EST' or 'EDT'
@@ -68,6 +84,10 @@ export declare function getTimezoneAbbreviation(timezone: Maybe<TimezoneString |
68
84
  *
69
85
  * Returns `"Unknown Timezone"` if no timezone is provided.
70
86
  *
87
+ * @param timezone - the IANA timezone string to get the long name for
88
+ * @param date - the date at which to evaluate the name (defaults to now)
89
+ * @returns the full timezone display name
90
+ *
71
91
  * @example
72
92
  * ```ts
73
93
  * getTimezoneLongName('America/New_York'); // 'Eastern Standard Time'
@@ -77,6 +97,10 @@ export declare function getTimezoneLongName(timezone: Maybe<TimezoneString>, dat
77
97
  /**
78
98
  * Builds a {@link TimezoneInfo} for the given timezone, computing abbreviation and search variants.
79
99
  *
100
+ * @param timezone - the IANA timezone string to build info for
101
+ * @param date - the date at which to evaluate the abbreviation (defaults to now)
102
+ * @returns the computed TimezoneInfo
103
+ *
80
104
  * @example
81
105
  * ```ts
82
106
  * const info = timezoneStringToTimezoneInfo('America/Chicago');
@@ -91,6 +115,10 @@ export declare function timezoneStringToTimezoneInfo(timezone: TimezoneString, d
91
115
  *
92
116
  * For queries longer than 2 characters, substring matching on the searchable name is also used.
93
117
  *
118
+ * @param search - the search query string
119
+ * @param infos - the array of TimezoneInfo objects to filter
120
+ * @returns the matching TimezoneInfo entries
121
+ *
94
122
  * @example
95
123
  * ```ts
96
124
  * const results = searchTimezoneInfos('eastern', allTimezoneInfos());
@@ -102,6 +130,9 @@ export declare function searchTimezoneInfos(search: string, infos: TimezoneInfo[
102
130
  *
103
131
  * Replaces `/` and `_` with spaces (e.g., `"America/New_York"` becomes `"america new york"`).
104
132
  *
133
+ * @param timezone - the IANA timezone string to convert
134
+ * @returns the searchable lowercase string
135
+ *
105
136
  * @example
106
137
  * ```ts
107
138
  * timezoneStringToSearchableString('America/New_York'); // 'america new york'
@@ -113,6 +144,9 @@ export declare function timezoneStringToSearchableString(timezone: TimezoneStrin
113
144
  *
114
145
  * Uses the cached set from {@link allKnownTimezoneStrings} for O(1) lookup.
115
146
  *
147
+ * @param input - the string to check
148
+ * @returns whether the input is a known timezone
149
+ *
116
150
  * @example
117
151
  * ```ts
118
152
  * isKnownTimezone('America/New_York'); // true