Function: icalendar-recur-previous-interval
icalendar-recur-previous-interval is a byte-compiled function defined
in icalendar-recur.el.gz.
Signature
(icalendar-recur-previous-interval INTERVAL RRULE DTSTART &optional VTIMEZONE)
Documentation
Given a recurrence INTERVAL, return the previous interval.
For an interval [LOW HIGH NEXT-LOW], the previous interval is
[PREV-LOW PREV-HIGH LOW], where PREV-LOW and PREV-HIGH are determined by
the frequency and interval sizes of RRULE (see
icalendar-recur-find-interval). If the resulting period of time
between PREV-LOW and PREV-HIGH occurs entirely before DTSTART, then the
interval does not exist; in this case nil is returned.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:previous-interval (interval rrule dtstart &optional vtimezone)
"Given a recurrence INTERVAL, return the previous interval.
For an interval [LOW HIGH NEXT-LOW], the previous interval is
[PREV-LOW PREV-HIGH LOW], where PREV-LOW and PREV-HIGH are determined by
the frequency and interval sizes of RRULE (see
`icalendar-recur-find-interval'). If the resulting period of time
between PREV-LOW and PREV-HIGH occurs entirely before DTSTART, then the
interval does not exist; in this case nil is returned."
(let* ((upper (icr:interval-low interval))
(freq (ical:rrule-freq rrule))
(unit (cl-case freq
(YEARLY :year)
(MONTHLY :month)
(WEEKLY :week)
(DAILY :day)
(HOURLY :hour)
(MINUTELY :minute)
(SECONDLY :second)))
(intervalsize (ical:rrule-interval-size rrule))
(new-low (ical:date/time-add upper unit (* -1 intervalsize) vtimezone))
(new-high
(if (< 1 intervalsize)
(ical:date/time-add new-low unit 1 vtimezone)
upper))
(new-upper
(when (< 1 intervalsize)
upper)))
(when vtimezone
;; (icr:tz-set-zone new-low vtimezone)
;; (icr:tz-set-zone new-high vtimezone)
(icr:tz-set-zone upper vtimezone))
(unless (ical:date-time< new-high dtstart)
(icr:make-interval new-low new-high new-upper))))