Function: icalendar-recur-nth-interval
icalendar-recur-nth-interval is a byte-compiled function defined in
icalendar-recur.el.gz.
Signature
(icalendar-recur-nth-interval N DTSTART RRULE &optional VTIMEZONE)
Documentation
Return the Nth recurrence interval after DTSTART.
The returned value is an interval [LOW HIGH NEXT-LOW] which is the Nth
recurrence interval after DTSTART. LOW is equal to START +
N*INTERVALSIZE units, HIGH is equal to START + (N+1)*INTERVALSIZE units,
and LOW <= TARGET < HIGH. START here is a time derived from DTSTART
depending on RRULE's FREQ part: the first day of the year for a
'YEARLY rule, first day of the month for a 'MONTHLY rule, etc.
RRULE's interval determines INTERVALSIZE, and its frequency determines the units: a month for 'MONTHLY, etc.
N should be a non-negative integer. Interval 0 is the interval
containing DTSTART. DTSTART should be an icalendar-date or
icalendar-date-time value. RRULE should be an
icalendar-recur.
If VTIMEZONE is provided, it is used to set time zone information in the returned interval bounds. Otherwise, the bounds contain no time zone information and represent floating local times.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:nth-interval (n dtstart rrule &optional vtimezone)
"Return the Nth recurrence interval after DTSTART.
The returned value is an interval [LOW HIGH NEXT-LOW] which is the Nth
recurrence interval after DTSTART. LOW is equal to START +
N*INTERVALSIZE units, HIGH is equal to START + (N+1)*INTERVALSIZE units,
and LOW <= TARGET < HIGH. START here is a time derived from DTSTART
depending on RRULE's FREQ part: the first day of the year for a
\\='YEARLY rule, first day of the month for a \\='MONTHLY rule, etc.
RRULE's interval determines INTERVALSIZE, and its frequency
determines the units: a month for \\='MONTHLY, etc.
N should be a non-negative integer. Interval 0 is the interval
containing DTSTART. DTSTART should be an `icalendar-date' or
`icalendar-date-time' value. RRULE should be an
`icalendar-recur'.
If VTIMEZONE is provided, it is used to set time zone information in the
returned interval bounds. Otherwise, the bounds contain no time zone
information and represent floating local times."
(when (< n 0) (error "Recurrence interval undefined for negative N"))
(let* ((start-dt (if (cl-typep dtstart 'ical:date)
(ical:date-to-date-time dtstart :tz vtimezone)
dtstart))
(freq (ical:rrule-freq rrule))
(intervalsize (ical:rrule-interval-size rrule))
(unit (cl-case freq
(YEARLY :year)
(MONTHLY :month)
(WEEKLY :week)
(DAILY :day)
(HOURLY :hour)
(MINUTELY :minute)
(SECONDLY :second)))
(target (ical:date/time-add start-dt unit (* n intervalsize) vtimezone)))
(icr:find-interval target dtstart rrule vtimezone)))