Function: icalendar-recur-recurrences-in-window-w/end-times

icalendar-recur-recurrences-in-window-w/end-times is a byte-compiled function defined in icalendar-recur.el.gz.

Signature

(icalendar-recur-recurrences-in-window-w/end-times LOWER UPPER COMPONENT &optional VTIMEZONE)

Documentation

Like icalendar-recur-recurrences-in-window, but returns end times.

The return value is a list of (START END) pairs representing the start and end time of each recurrence of COMPONENT in the window defined by LOWER and UPPER.

In the returned pairs, START and END are both icalendar-date or icalendar-date-time values of the same type as COMPONENT's icalendar-dtstart. Each END time is computed by adding COMPONENT's icalendar-duration value to START for each recurrence START between LOWER and UPPER. Or, if the recurrence is given by an icalendar-period value in an icalendar-rdate property, START and END are determined by the period.

Other relevant functions are documented in the icalendar group.

Shortdoc

;; icalendar
(icalendar-recur-recurrences-in-window-w/end-times
     '(0 0 0 1 1 2026 4 -1 nil) '(0 0 0 1 2 2026 1 -1 nil)
     vevent)
    e.g. => (((0 0 10 10 1 2026 4 -1 nil) (0 0 11 10 1 2026 4 -1 nil)) ...)

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:recurrences-in-window-w/end-times
    (lower upper component &optional vtimezone)
  "Like `icalendar-recur-recurrences-in-window', but returns end times.

The return value is a list of (START END) pairs representing the start
and end time of each recurrence of COMPONENT in the window defined by
LOWER and UPPER.

In the returned pairs, START and END are both `icalendar-date' or
`icalendar-date-time' values of the same type as COMPONENT's
`icalendar-dtstart'.  Each END time is computed by adding COMPONENT's
`icalendar-duration' value to START for each recurrence START between
LOWER and UPPER.  Or, if the recurrence is given by an `icalendar-period'
value in an `icalendar-rdate' property, START and END are determined by
the period."
  (ical:with-component component
    ((ical:duration :value duration)
     (ical:rdate :all rdate-nodes))
    ;; TODO: for higher-level applications showing a schedule, it might
    ;; be useful to include recurrences which start outside the window,
    ;; but end inside it.  This would mean we can't simply use
    ;; `recurrences-in-window' like this.
    (let ((starts (icr:recurrences-in-window lower upper component vtimezone))
          (periods (seq-filter
                    (lambda (vnode)
                      (when (eq 'ical:period (ical:ast-node-type vnode))
                        (ical:ast-node-value vnode)))
                    (append
                     (mapcar #'ical:ast-node-value rdate-nodes)))))
      (when (or starts periods)
        (seq-uniq
         (nconc (mapcar
                 (lambda (dt) (list dt (ical:date/time-add-duration
                                        dt duration vtimezone)))
                 starts)
                (mapcar
                 (lambda (p)
                   (let ((start (ical:period-start p)))
                     (list start
                           (or (ical:period-end p)
                               (ical:date/time-add-duration
                                start (ical:period-dur-value p) vtimezone)))))
                 periods)))))))