Function: org-agenda-check-clock-gap

org-agenda-check-clock-gap is a byte-compiled function defined in org-agenda.el.gz.

Signature

(org-agenda-check-clock-gap T1 T2 OK-LIST)

Documentation

Check if gap T1 -> T2 contains one of the OK-LIST time-of-day values.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-check-clock-gap (t1 t2 ok-list)
  "Check if gap T1 -> T2 contains one of the OK-LIST time-of-day values."
  (catch 'exit
    (unless ok-list
      ;; there are no OK times for gaps...
      (throw 'exit nil))
    (when (> (- (/ t2 36000) (/ t1 36000)) 24)
      ;; This is more than 24 hours, so it is OK.
      ;; because we have at least one OK time, that must be in the
      ;; 24 hour interval.
      (throw 'exit t))
    ;; We have a shorter gap.
    ;; Now we have to get the minute of the day when these times are
    (let* ((t1dec (decode-time t1))
	   (t2dec (decode-time t2))
	   ;; compute the minute on the day
	   (min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec))))
	   (min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec)))))
      (when (< min2 min1)
	;; if min2 is smaller than min1, this means it is on the next day.
	;; Wrap it to after midnight.
	(setq min2 (+ min2 1440)))
      ;; Now check if any of the OK times is in the gap
      (mapc (lambda (x)
	      ;; Wrap the time to after midnight if necessary
	      (when (< x min1) (setq x (+ x 1440)))
	      ;; Check if in interval
	      (and (<= min1 x) (>= min2 x) (throw 'exit t)))
	    ok-list)
      ;; Nope, this gap is not OK
      nil)))