Function: icalendar-recur-subintervals-to-date-times

icalendar-recur-subintervals-to-date-times is a byte-compiled function defined in icalendar-recur.el.gz.

Signature

(icalendar-recur-subintervals-to-date-times SUBINTERVALS &optional VTIMEZONE)

Documentation

Transform SUBINTERVALS into a list of icalendar-date-time recurrences.

The returned list of recurrences contains one date-time value for each second of each subinterval.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
;; Once we have refined an interval into a final set of subintervals, we
;; need to convert those subintervals into a set of recurrences.  For a
;; recurrence set where DTSTART and the recurrences are date-times, the
;; recurrence set (in this interval) consists of every date-time
;; corresponding to each second of any subinterval.  When DTSTART and the
;; recurrences are plain dates, the recurrence set consists of each
;; distinct date in any subinterval.
(defun icr:subintervals-to-date-times (subintervals &optional vtimezone)
  "Transform SUBINTERVALS into a list of `icalendar-date-time' recurrences.

The returned list of recurrences contains one date-time value for each
second of each subinterval."
  (let (recurrences)
    (dolist (int subintervals)
      (let* ((start (icr:interval-low int))
             (dt start)
             ;; Use absolute times for the loop in case the subinterval
             ;; crosses the boundary between two observances.
             ;; N.B. floating times will be correctly treated as local
             ;; times by encode-time.
             (end (time-convert (encode-time (icr:interval-high int)) 'integer))
             (tick (time-convert (encode-time start) 'integer)))
        (while (time-less-p tick end)
          (push dt recurrences)
          (setq tick (1+ tick)
                dt (if vtimezone (icr:tz-decode-time tick vtimezone)
                     (ical:date/time-add dt :second 1))))))
    (nreverse recurrences)))