Function: icalendar-date-add

icalendar-date-add is a byte-compiled function defined in icalendar-utils.el.gz.

Signature

(icalendar-date-add DATE UNIT N)

Documentation

Add N UNITs to DATE.

UNIT should be :year, :month, :week, or :day; time units will be ignored. N may be a positive or negative integer.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-utils.el.gz
(defun ical:date-add (date unit n)
  "Add N UNITs to DATE.

UNIT should be `:year', `:month', `:week', or `:day'; time units will be
ignored.  N may be a positive or negative integer."
  (if (memq unit '(:hour :minute :second))
      date
    (let* ((dt (ical:make-date-time :year (calendar-extract-year date)
                                    :month (calendar-extract-month date)
                                    :day (calendar-extract-day date)))
           (delta (if (eq unit :week)
                      (make-decoded-time :day (* 7 n))
                    (make-decoded-time unit n)))
           (new-dt (decoded-time-add dt delta)))
      (ical:date-time-to-date new-dt))))