Function: icalendar-recur-recurrences-in-window

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

Signature

(icalendar-recur-recurrences-in-window LOWER UPPER COMPONENT &optional VTIMEZONE)

Documentation

Return the recurrences of COMPONENT in the window between LOWER and UPPER.

LOWER and UPPER may be arbitrary icalendar-date or icalendar-date-time values. COMPONENT should be an iCalendar component node representing a recurring event: it should contain at least an icalendar-dtstart and either an icalendar-rrule or icalendar-rdate property.

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-in-window '(1 1 2026) '(12 31 2026)
                                          vevent)
    e.g. => ((1 10 2026) (2 10 2026) ...)

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:recurrences-in-window (lower upper component &optional vtimezone)
  "Return the recurrences of COMPONENT in the window between LOWER and UPPER.

LOWER and UPPER may be arbitrary `icalendar-date' or
`icalendar-date-time' values.  COMPONENT should be an iCalendar component
node representing a recurring event: it should contain at least an
`icalendar-dtstart' and either an `icalendar-rrule' or `icalendar-rdate'
property.

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))
    (if (not (or rrule rdate-nodes))
        ;; No recurrences to calculate, so just return early:
        nil
      ;; Otherwise, calculate the recurrences in the window:
      (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)))))

      (let* (;; don't look for nonexistent intervals:
             (low-start (if (ical:date/time< lower dtstart) dtstart lower))
             (until (ical:rrule-until rrule))
             (high-end (if (and until (ical:date/time< until upper)) until upper))
             (curr-interval (icr:find-interval low-start dtstart rrule
                                               vtimezone))
             (high-interval (icr:find-interval high-end dtstart rrule
                                               vtimezone))
             (high-intbound (icr:interval-high high-interval))
             (recurrences nil))

        (while (ical:date-time< (icr:interval-low curr-interval) high-intbound)
          (setq recurrences
                (nconc
                 (icr:recurrences-in-interval curr-interval component vtimezone)
                 recurrences))
          (setq curr-interval (icr:next-interval curr-interval rrule
                                                 vtimezone)))

        ;; exclude any recurrences inside the first and last intervals but
        ;; outside the window before returning:
        (seq-filter
         (lambda (dt)
           (and (ical:date/time<= lower dt)
                (ical:date/time< dt upper)))
         recurrences)))))