A Millwork codec for RFC 5545 recurrence rules with rrule.
pnpm add @millwork-ts/rrule @millwork-ts/core rrule
| Codec | Value | Raw |
|---|---|---|
rrule |
an RRule or RRuleSet |
"FREQ=WEEKLY;BYDAY=MO,WE", with or without DTSTART |
rrulestr. A string with EXDATE, RDATE or more than one
rule gives an RRuleSet.value.toString(). A bare "FREQ=…" is written as "RRULE:FREQ=…".COUNT=abc, is bad input.RRuleSet setters
change it. Do not change the value. To change a rule, make a new one and set it.rrule uses JavaScript Date values in UTC. It shows local times as "floating" UTC times. For
example, DTSTART;TZID=America/New_York:20240101T090000 gives dates at 09:00Z, not at
14:00Z. Read the dates with their UTC fields, or use the
rrule time zone notes. The codec
does not change this.
| Option | Default | Meaning |
|---|---|---|
allowSecondly |
false |
When true, FREQ=SECONDLY is read. |
rrule finds each date by a step of the frequency. A rule that has no dates, or very few, can
make after(), between() and all() iterate for many seconds before they stop. For
example, FREQ=MINUTELY;BYMONTH=2;BYMONTHDAY=30 blocks for about 20 seconds.
FREQ=SECONDLY is bad input by default. Set allowSecondly: true only for rules that you
trust.BYMONTHDAY that no month of BYMONTH has is bad input, at each frequency.BYYEARDAY and BYMONTH that do not
meet). Do not iterate a rule from a user that you do not trust without a limit: give
between() a short range, or use COUNT or UNTIL.equals compares the string form. "FREQ=DAILY" equals "RRULE:FREQ=DAILY".
Register the codecs before the store calls transformations(), because transformations()
reads the registry when it runs. See the
@millwork-ts/warp-drive README.
import { codecs } from '@millwork-ts/rrule'
import { registerCodecs, valueField } from '@millwork-ts/warp-drive'
import { withDefaults } from '@warp-drive/core/reactive'
registerCodecs(codecs)
export const MeetingSchema = withDefaults({
type: 'meeting',
fields: [valueField('recurrence', 'rrule')],
})