Liking cljdoc? Tell your friends :D

dk.simongray.ical.rrule

Parse, write and expand recurrence rules (RFC 5545, section 3.3.10) on their own.

A rule is the map that an RRULE property holds as its value, with its parts by lower-case keyword, e.g. {:freq "MONTHLY" :byday ["2MO"]}. FREQ, WKST and BYDAY are upper-case strings, and UNTIL is a date or a date-time. COUNT and INTERVAL are numbers, and the other BYxxx parts are vectors of numbers.

Parse, write and expand recurrence rules (RFC 5545, section 3.3.10) on
their own.

A rule is the map that an RRULE property holds as its value, with its
parts by lower-case keyword, e.g. {:freq "MONTHLY" :byday ["2MO"]}.
FREQ, WKST and BYDAY are upper-case strings, and UNTIL is a date or a
date-time. COUNT and INTERVAL are numbers, and the other BYxxx parts
are vectors of numbers.
raw docstring

expandable?clj/s

(expandable? rule)

Whether the library can expand the recurrence rule. It can unless the rule has an RSCALE other than GREGORIAN, or a SKIP that RFC 7529 doesn't define.

Whether the library can expand the recurrence `rule`. It can unless the
rule has an RSCALE other than GREGORIAN, or a SKIP that RFC 7529
doesn't define.
sourceraw docstring

occurrencesclj/s

(occurrences rule start)
(occurrences rule start zone)

The instances that the rule generates from start, a date or a date-time, as a lazy sequence of dates or date-times in order. It's nil for a rule that the library can't expand (see expandable?).

The first instance is always start, as section 3.8.5.3 says, even when the rule wouldn't generate it, and COUNT counts it. Given the zone of a local start (from tz/zone), an instance at a time that the clocks skip moves forward by the gap (section 3.3.5), and an UNTIL in UTC compares with the instances' instants. Without it, the times are as the rule generates them, and compare as if they were in UTC.

(take 3 (occurrences {:freq "MONTHLY" :byday ["-1FR"]}
                     "2026-01-30T18:00:00"))
;; => ("2026-01-30T18:00:00" "2026-02-27T18:00:00"
;;     "2026-03-27T18:00:00")
The instances that the `rule` generates from `start`, a date or a
date-time, as a lazy sequence of dates or date-times in order. It's nil
for a rule that the library can't expand (see expandable?).

The first instance is always `start`, as section 3.8.5.3 says, even
when the rule wouldn't generate it, and COUNT counts it. Given the
`zone` of a local `start` (from tz/zone), an instance at a time that
the clocks skip moves forward by the gap (section 3.3.5), and an UNTIL
in UTC compares with the instances' instants. Without it, the times
are as the rule generates them, and compare as if they were in UTC.

    (take 3 (occurrences {:freq "MONTHLY" :byday ["-1FR"]}
                         "2026-01-30T18:00:00"))
    ;; => ("2026-01-30T18:00:00" "2026-02-27T18:00:00"
    ;;     "2026-03-27T18:00:00")
sourceraw docstring

parseclj/s

(parse s)

The recurrence rule in the text s, or nil when it isn't one: when it has no FREQ, or a part that doesn't parse or appears twice.

(parse "FREQ=WEEKLY;BYDAY=MO,WE")
;; => {:freq "WEEKLY" :byday ["MO" "WE"]}
The recurrence rule in the text `s`, or nil when it isn't one: when it
has no FREQ, or a part that doesn't parse or appears twice.

    (parse "FREQ=WEEKLY;BYDAY=MO,WE")
    ;; => {:freq "WEEKLY" :byday ["MO" "WE"]}
sourceraw docstring

serializeclj/s

(serialize rule)

The text of the recurrence rule, with FREQ first.

The text of the recurrence `rule`, with FREQ first.
sourceraw docstring

valid?clj/s

(valid? rule)
(valid? rule start)
(valid? rule start zone)

Whether the recurrence rule has no validation errors other than warnings. It takes the same arguments as validation-errors.

Whether the recurrence `rule` has no validation errors other than
warnings. It takes the same arguments as validation-errors.
sourceraw docstring

validation-errorsclj/s

(validation-errors rule)
(validation-errors rule start)
(validation-errors rule start zone)

The ways that the recurrence rule, a map or its text, breaks RFC 5545, section 3.3.10, and RFC 7529, as a vector of maps like those of ical/validation-errors, without :path. Each has an :error, e.g. :count-and-until or :rule-part-out-of-range, a :level, and keys with the details, e.g. :part and :value.

A map that a person or a program built can have parts of the wrong form, e.g. a FREQ of "FORTNIGHTLY", and then those are the errors. Given the start it would expand from, it also checks the rule with it, e.g. that UNTIL has the same type, and that the rule generates start. A local start is floating, unless a zone (from tz/zone) is given.

(validation-errors {:freq "WEEKLY" :count 4 :until "2026-12-31"})
;; => [{:error :count-and-until :level :error}]
The ways that the recurrence `rule`, a map or its text, breaks RFC 5545,
section 3.3.10, and RFC 7529, as a vector of maps like those of
ical/validation-errors, without :path. Each has an :error, e.g.
:count-and-until or :rule-part-out-of-range, a :level, and keys with the
details, e.g. :part and :value.

A map that a person or a program built can have parts of the wrong
form, e.g. a FREQ of "FORTNIGHTLY", and then those are the errors.
Given the `start` it would expand from, it also checks the rule with
it, e.g. that UNTIL has the same type, and that the rule generates
`start`. A local `start` is floating, unless a `zone` (from tz/zone) is
given.

    (validation-errors {:freq "WEEKLY" :count 4 :until "2026-12-31"})
    ;; => [{:error :count-and-until :level :error}]
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close