Function: icalendar--get-most-recent-observance

icalendar--get-most-recent-observance is a byte-compiled function defined in icalendar.el.gz.

Signature

(icalendar--get-most-recent-observance ALIST SUB-COMP)

Documentation

Return the latest observance for SUB-COMP DAYLIGHT or STANDARD.

ALIST is a VTIMEZONE potentially containing historical records.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar.el.gz
(defun icalendar--get-most-recent-observance (alist sub-comp)
  "Return the latest observance for SUB-COMP DAYLIGHT or STANDARD.
ALIST is a VTIMEZONE potentially containing historical records."
;FIXME?: "most recent" should be relative to a given date
  (let ((components (icalendar--get-children alist sub-comp)))
    (list
     (car
      (sort components
            (lambda (a b)
              (let* ((get-recent (lambda (n)
                                   (car
                                    (sort
                                     (delq nil
                                           (mapcar (lambda (p)
                                                     (and (memq (car p) '(DTSTART RDATE))
                                                          (car (cddr p))))
                                                   n))
                                     'string-greaterp))))
                     (a-recent (funcall get-recent (car (cddr a))))
                     (b-recent (funcall get-recent (car (cddr b)))))
                (string-greaterp a-recent b-recent))))))))