Function: icalendar-recur-recurrences-to-count

icalendar-recur-recurrences-to-count is a byte-compiled function defined in icalendar-recur.el.gz.

Signature

(icalendar-recur-recurrences-to-count COMPONENT &optional VTIMEZONE)

Documentation

Return all the recurrences in COMPONENT up to COUNT in its recurrence rule.

COMPONENT should be an iCalendar component node representing a recurring event: it should contain at least an icalendar-dtstart and an icalendar-rrule, which must contain a COUNT=... clause.

Warning: this function finds *all* the recurrences in COMPONENT's recurrence set. If the value of COUNT is large, this can be slow.

If specified, VTIMEZONE should be an icalendar-vtimezone component. In this case, the dates and times of recurrences will be computed with UTC offsets local to that time zone.

Other relevant functions are documented in the icalendar group.

Shortdoc

;; icalendar
(icalendar-recur-recurrences-to-count '(1 1 2026) '(12 31 2026)
                                          vevent)
    e.g. => ((1 10 2026) (2 10 2026) (3 10 2026))

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:recurrences-to-count (component &optional vtimezone)
  "Return all the recurrences in COMPONENT up to COUNT in its recurrence rule.

COMPONENT should be an iCalendar component node representing a recurring
event: it should contain at least an `icalendar-dtstart' and an
`icalendar-rrule', which must contain a COUNT=... clause.

Warning: this function finds *all* the recurrences in COMPONENT's
recurrence set.  If the value of COUNT is large, this can be slow.

If specified, VTIMEZONE should be an `icalendar-vtimezone' component.
In this case, the dates and times of recurrences will be computed with
UTC offsets local to that time zone."
  (ical:with-component component
      ((ical:dtstart :value dtstart)
       (ical:tzoffsetfrom :value offset-from)
       (ical:rrule :value rrule)
       (ical:rdate :all rdate-nodes))
    (when (memq (ical:ast-node-type component) '(ical:standard ical:daylight))
      ;; in time zone observances, set the zone field in dtstart
      ;; from the TZOFFSETFROM property:
      (setq dtstart
            (ical:date-time-variant dtstart
                                    :zone offset-from
                                    :dst (not (ical:daylight-component-p
                                               component)))))
    (unless (or rrule rdate-nodes)
      (error "No recurrence data in component: %s" component))
    (unless (ical:rrule-count rrule)
      (error "Recurrence rule has no COUNT clause"))
    (let ((count (ical:rrule-count rrule))
          (int (icr:nth-interval 0 dtstart rrule vtimezone))
          recs)
      (while (length< recs count)
        (setq recs
              (nconc recs (icr:recurrences-in-interval int component vtimezone
                                                       (- count (length recs)))))
        (setq int (icr:next-interval int rrule vtimezone)))
      recs)))