Function: icalendar-recur-find-yearly-interval

icalendar-recur-find-yearly-interval is a byte-compiled function defined in icalendar-recur.el.gz.

Signature

(icalendar-recur-find-yearly-interval TARGET DTSTART INTERVALSIZE &optional VTIMEZONE)

Documentation

Find a YEARLY recurrence interval.

See icalendar-recur-find-interval for arguments' meanings.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:find-yearly-interval (target dtstart intervalsize &optional vtimezone)
  "Find a YEARLY recurrence interval.
See `icalendar-recur-find-interval' for arguments' meanings."
  (let* ((start-year (ical:date/time-year dtstart))
         (target-year (ical:date/time-year target))
         ;; The year before target that is the closest integer multiple
         ;; of intervalsize years after dtstart:
         (low-year (- target-year
                      (mod (- target-year start-year) intervalsize)))
         (low (ical:make-date-time :year low-year :month 1 :day 1
                                   :hour 0 :minute 0 :second 0 :tz vtimezone))
         (high (ical:make-date-time :year (1+ low-year) :month 1 :day 1
                                    :hour 0 :minute 0 :second 0 :tz vtimezone))
         (next-low
          (when (< 1 intervalsize)
            (ical:make-date-time :year (+ low-year intervalsize)
                                 :month 1 :day 1 :hour 0 :minute 0 :second 0
                                 :tz vtimezone))))

    ;; Return the bounds:
    (icr:make-interval low high next-low)))