rrule-temporal 1.1.14 → 1.2.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.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # rrule-temporal
2
2
 
3
- The first and only fully compliant Recurrence rule (RFC 5545) processing JS/TS library built on the Temporal API.
3
+ The first and only fully compliant Recurrence rule ([RFC-5545](https://www.rfc-editor.org/rfc/rfc5545.html)) processing JS/TS library built on the Temporal API, now with support for [RFC-7529](https://www.rfc-editor.org/rfc/rfc7529.html) (RSCALE / SKIP) for non-Gregorian calendars.
4
4
  The library accepts the familiar `RRULE` format and returns
5
5
  `Temporal.ZonedDateTime` instances for easy time‑zone aware scheduling.
6
6
 
7
7
  See the [demo site](https://ggaabe.github.io/rrule-temporal/) for an interactive playground.
8
8
 
9
- > This library was created to advance the rrule library to use Temporal, and to provide a more modern API, as the original rrule library is [not maintained anymore](https://github.com/jkbrzt/rrule/issues/615). Maintainers suggested to use Temporal instead of Date:
9
+ > This library was created to advance the rrule library to use Temporal, and to provide a more modern API, as the original rrule.js library is [not maintained anymore](https://github.com/jkbrzt/rrule/issues/615) and based on Date. Its maintainers suggested a new library based on Temporal instead of Date should be created:
10
10
  >https://github.com/jkbrzt/rrule/issues/450#issuecomment-1055853095
11
11
 
12
12
  ## Installation
@@ -137,16 +137,10 @@ toText(weekly, "es");
137
137
  // "cada semana en domingo a las 10 AM UTC"
138
138
  ```
139
139
 
140
- `toText()` currently ships translations for **English (`en`)**,
141
- **Spanish (`es`)**, **Hindi (`hi`)**, **Cantonese (`yue`)**, **Arabic (`ar`)**,
142
- **Hebrew (`he`)** and **Mandarin (`zh`)**. At build time you can reduce bundle size by
143
- defining the `TOTEXT_LANGS` environment variable (read from `process.env`),
144
- e.g. `TOTEXT_LANGS=en,es,ar`. When this environment variable is unavailable
145
- (such as in browser builds where `process` is undefined) all languages are
146
- included by default.
147
-
148
140
  ### `toText` supported languages
149
141
 
142
+ `toText()` currently ships translations for the following languages:
143
+
150
144
  | Code | Language |
151
145
  | ---- | -------- |
152
146
  | en | English |
@@ -157,6 +151,85 @@ included by default.
157
151
  | he | Hebrew |
158
152
  | zh | Mandarin |
159
153
 
154
+ **NOTE:** At build time you can reduce bundle size by
155
+ defining the `TOTEXT_LANGS` environment variable (read from `process.env`),
156
+ e.g. `TOTEXT_LANGS=en,es,ar`. When this environment variable is unavailable
157
+ (such as in browser builds where `process` is undefined) all languages are
158
+ included by default.
159
+
160
+ ### RFC 7529 (RSCALE / SKIP)
161
+
162
+ This library implements the iCalendar RSCALE and SKIP extensions described in RFC 7529 for defining recurrence rules in non‑Gregorian calendars and for controlling how invalid dates are handled.
163
+
164
+ - Spec: RFC 7529 — Non‑Gregorian Recurrence Rules in iCalendar
165
+ https://www.rfc-editor.org/rfc/rfc7529.html
166
+
167
+ What RSCALE does:
168
+ - Extends `RRULE` with `RSCALE=<calendar>` to choose the calendar used for recurrence generation while keeping DTSTART/RECURRENCE‑ID/RDATE/EXDATE in Gregorian.
169
+ - Supported calendars: `GREGORIAN`, `CHINESE`, `HEBREW`, `INDIAN` (Saka/Indian National Calendar).
170
+ - Interprets `BY*` parts (month, day, week, etc.) in the specified calendar when expanding occurrences, then converts the generated dates back to the requested time zone.
171
+
172
+ What SKIP does:
173
+ - Extends `RRULE` with `SKIP=OMIT|BACKWARD|FORWARD` (only when `RSCALE` is present).
174
+ - Controls how invalid dates produced by the rule are handled (e.g., Feb 29 in non‑leap years, or months that don’t have the desired day):
175
+ - `OMIT` (default): drop the invalid occurrence.
176
+ - `BACKWARD`: move to the previous valid day/month (e.g., Feb 28).
177
+ - `FORWARD`: move to the next valid day/month (e.g., Mar 1).
178
+ - RFC 7529 defines the evaluation order; notably, SKIP may apply after `BYMONTH` (invalid month) and after `BYMONTHDAY` (invalid day). If SKIP changes the month and that leads to an invalid day‑of‑month, SKIP is re‑applied for the day step.
179
+
180
+ Leap months and BYMONTH:
181
+ - `BYMONTH` accepts leap‑month tokens with an `L` suffix (e.g., `5L`) under RSCALE. These are matched against the target calendar’s `monthCode` (e.g., Chinese `M06L`, Hebrew `M05L`).
182
+ - Example tokens:
183
+ - Chinese: `5L` matches `monthCode=M05L` (leap 5th) or `M06L` depending on calendar system; we match by the numeric part + `L` via `monthCode`.
184
+ - Hebrew: `5L` typically corresponds to Adar I (`monthCode=M05L`).
185
+ - Numeric months without `L` (e.g., `5`) match the regular month (e.g., `monthCode=M05`).
186
+
187
+ Supported RSCALE coverage in this library:
188
+ - Frequencies: `YEARLY`, `MONTHLY`, `WEEKLY` with Chinese/Hebrew calendars.
189
+ - Constraints: `BYMONTH` (including leap tokens), `BYMONTHDAY`, `BYDAY` (weekday tokens; ordinal support at monthly/yearly levels), `BYYEARDAY`, `BYWEEKNO`, `BYSETPOS`.
190
+ - Sub‑daily (`DAILY`, `HOURLY`, `MINUTELY`) behavior:
191
+ - The engine first filters eligible calendar days using `BYWEEKNO`, `BYYEARDAY`, `BYMONTH`, `BYMONTHDAY`, and simple `BYDAY` (weekday codes). Then it expands times via `BYHOUR`/`BYMINUTE`/`BYSECOND`.
192
+ - For `HOURLY`/`MINUTELY`, INTERVAL alignment is based on elapsed real hours/minutes since `DTSTART`. Occurrences are kept when the elapsed units are multiples of `INTERVAL`.
193
+ - Ordinal `BYDAY` (e.g., `1MO`, `-1SU`) is not interpreted at sub‑daily RSCALE levels; use `MONTHLY`/`YEARLY` for these.
194
+
195
+ Examples
196
+
197
+ Chinese New Year (1st day of 1st Chinese month), year over year from a Gregorian DTSTART:
198
+
199
+ ```ics
200
+ DTSTART;VALUE=DATE:20130210
201
+ RRULE:RSCALE=CHINESE;FREQ=YEARLY
202
+ ```
203
+
204
+ Hebrew New Year (Tishrei 1) — using BYYEARDAY=1 in Hebrew calendar:
205
+
206
+ ```ics
207
+ DTSTART;TZID=UTC:20230916T090000
208
+ RRULE:RSCALE=HEBREW;FREQ=YEARLY;BYYEARDAY=1;BYHOUR=9
209
+ ```
210
+
211
+ Feb 29 birthday — SKIP strategies:
212
+
213
+ ```ics
214
+ DTSTART;TZID=UTC:20160229T120000
215
+ RRULE:RSCALE=GREGORIAN;FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=29;SKIP=OMIT
216
+ ```
217
+
218
+ ```ics
219
+ DTSTART;TZID=UTC:20160229T120000
220
+ RRULE:RSCALE=GREGORIAN;FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=29;SKIP=BACKWARD
221
+ ```
222
+
223
+ ```ics
224
+ DTSTART;TZID=UTC:20160229T120000
225
+ RRULE:RSCALE=GREGORIAN;FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=29;SKIP=FORWARD
226
+ ```
227
+
228
+ Notes
229
+ - SKIP MUST NOT be present unless RSCALE is present (per RFC 7529).
230
+ - Default SKIP is `OMIT` when RSCALE is present.
231
+ - This library surfaces `RSCALE`/`SKIP` in `toText()` at the end of the description: e.g., `(RSCALE=HEBREW;SKIP=OMIT)`.
232
+
160
233
  ## API
161
234
 
162
235
  | Method | Description |