Function: icalendar-duration-between
icalendar-duration-between is a byte-compiled function defined in
icalendar-utils.el.gz.
Signature
(icalendar-duration-between START END)
Documentation
Return the duration between START and END.
START should be an icalendar-date or icalendar-date-time; END must
be of the same type as START. The returned value is an
icalendar-dur-value, i.e., a time delta in the sense of
decoded-time-add.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-utils.el.gz
(defun ical:duration-between (start end)
"Return the duration between START and END.
START should be an `icalendar-date' or `icalendar-date-time'; END must
be of the same type as START. The returned value is an
`icalendar-dur-value', i.e., a time delta in the sense of
`decoded-time-add'."
(cl-typecase start
(ical:date
(make-decoded-time :day (- (calendar-absolute-from-gregorian end)
(calendar-absolute-from-gregorian start))))
(ical:date-time
(let* ((start-abs (time-convert (encode-time start) 'integer))
(end-abs (time-convert (encode-time end) 'integer))
(dur-secs (- end-abs start-abs))
(days (/ dur-secs (* 60 60 24)))
(dur-nodays (mod dur-secs (* 60 60 24)))
(hours (/ dur-nodays (* 60 60)))
(dur-nohours (mod dur-nodays (* 60 60)))
(minutes (/ dur-nohours 60))
(seconds (mod dur-nohours 60)))
(make-decoded-time :day days
:hour hours :minute minutes :second seconds)))))