From 003051ab24c4f5e7f6cdef9503a02e8c83765b21 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Tue, 31 Jul 2018 14:07:20 +0200 Subject: [PATCH] [Timeline] Truncate start and end times --- site-lisp/timeline-tools.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/site-lisp/timeline-tools.el b/site-lisp/timeline-tools.el index 408c430..a1542aa 100644 --- a/site-lisp/timeline-tools.el +++ b/site-lisp/timeline-tools.el @@ -214,11 +214,9 @@ where MARKER is a marker to the beginning of the corresponding heading and CLOCK-TIMES is a list of cons cells of the form (START . END), where START and END are the starting and ending times of a clock line for this task. START and END are -given as seconds since the epoch, as a floating point number. No -truncation with respect to TSTART and TEND is done, i.e., START -or END may occassionally lie outside of these limits, as long as -the corresponding clockline has non-empty intersection with the -given bounds." +given as seconds since the epoch, as a floating point number. +Truncation with respect to TSTART and TEND is done, i.e., START +or END will always be in the interval [TSTART,TEND]." ;; adapted from `org-clock-sum’ (when (eq major-mode 'org-mode) (let* ((tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart)) @@ -236,7 +234,9 @@ given bounds." (when (or (<= tstart te tend) (<= tstart ts tend) (<= ts tstart tend te)) - (push (cons ts te) times)))) + (push (cons (max ts tstart) + (min te tend)) + times)))) ;; when on headlines, store away collected clocklines #'(lambda () ;; add currently running clock if wanted @@ -250,7 +250,9 @@ given bounds." (<= current-clock-start tstart tend current-clock-end)) - (push (cons current-clock-start current-clock-end) times)))) + (push (cons (max current-clock-start tstart) + (min current-clock-end tend)) + times)))) ;; store away clocklines of current headline (when (not (null times)) (push (cons (point-marker) times) task-clock-times)