Function: icalendar-date-time-simultaneous-p

icalendar-date-time-simultaneous-p is a byte-compiled function defined in icalendar-utils.el.gz.

Signature

(icalendar-date-time-simultaneous-p DT1 DT2)

Documentation

Return non-nil if DT1 and DT2 are simultaneous date-times.

This function returns non-nil if DT1 and DT2 encode to the same Lisp timestamp. Thus they can count as simultaneous even if they represent times in different timezones. If both date-times lack an offset from UTC, they are treated as simultaneous if they encode to the same timestamp in UTC.

If only one date-time has an offset, they are treated as non-simultaneous if they represent different clock times according to icalendar-date-time-locally-simultaneous-p. Otherwise an error is signaled.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-utils.el.gz
(defun ical:date-time-simultaneous-p (dt1 dt2)
  "Return non-nil if DT1 and DT2 are simultaneous date-times.

This function returns non-nil if DT1 and DT2 encode to the same Lisp
timestamp.  Thus they can count as simultaneous even if they represent
times in different timezones.  If both date-times lack an offset from
UTC, they are treated as simultaneous if they encode to the same
timestamp in UTC.

If only one date-time has an offset, they are treated as
non-simultaneous if they represent different clock times according to
`icalendar-date-time-locally-simultaneous-p'.  Otherwise an error is
signaled."
  (let ((zone1 (decoded-time-zone dt1))
        (zone2 (decoded-time-zone dt2)))
    (cond ((and zone1 zone2)
           (time-equal-p (encode-time dt1) (encode-time dt2)))
          ((and (null zone1) (null zone2))
           (time-equal-p (encode-time (ical:date-time-variant dt1 :zone t))
                         (encode-time (ical:date-time-variant dt2 :zone t))))
          (t
           ;; Best effort:
           ;; TODO: I'm not convinced this is the right thing to do yet.
           ;; Might want to be stricter here and fix the problem of comparing
           ;; times with and without zone information elsewhere.
           (if (ical:date-time-locally-simultaneous-p dt1 dt2)
               (error "Missing zone information: %s %s" dt1 dt2)
             nil)))))