org-clock: Fix regression in `org-clock-sum'
* lisp/org-clock.el (org-clock-sum): Fix regression introduced in
112c5ba479
. Small refactoring.
Reported-by: Josh Moller-Mara <jmm@cns.nyu.edu>
http://lists.gnu.org/archive/html/emacs-orgmode/2017-08/msg00117.html
This commit is contained in:
parent
e67f0f29de
commit
7e241af591
|
@ -1803,14 +1803,15 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
||||||
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
||||||
(lmax 30)
|
(lmax 30)
|
||||||
(ltimes (make-vector lmax 0))
|
(ltimes (make-vector lmax 0))
|
||||||
(t1 0)
|
|
||||||
(level 0)
|
(level 0)
|
||||||
ts te dt
|
(tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart t))
|
||||||
|
((consp tstart) (float-time tstart))
|
||||||
|
(t tstart)))
|
||||||
|
(tend (cond ((stringp tend) (org-time-string-to-seconds tend t))
|
||||||
|
((consp tend) (float-time tend))
|
||||||
|
(t tend)))
|
||||||
|
(t1 0)
|
||||||
time)
|
time)
|
||||||
(if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart)))
|
|
||||||
(if (stringp tend) (setq tend (org-time-string-to-seconds tend)))
|
|
||||||
(if (consp tstart) (setq tstart (float-time tstart)))
|
|
||||||
(if (consp tend) (setq tend (float-time tend)))
|
|
||||||
(remove-text-properties (point-min) (point-max)
|
(remove-text-properties (point-min) (point-max)
|
||||||
`(,(or propname :org-clock-minutes) t
|
`(,(or propname :org-clock-minutes) t
|
||||||
:org-clock-force-headline-inclusion t))
|
:org-clock-force-headline-inclusion t))
|
||||||
|
@ -1819,26 +1820,27 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
||||||
(while (re-search-backward re nil t)
|
(while (re-search-backward re nil t)
|
||||||
(cond
|
(cond
|
||||||
((match-end 2)
|
((match-end 2)
|
||||||
;; Two time stamps
|
;; Two time stamps.
|
||||||
(setq ts (match-string 2)
|
(let* ((ts (float-time
|
||||||
te (match-string 3)
|
(apply #'encode-time
|
||||||
ts (float-time
|
(save-match-data
|
||||||
(apply #'encode-time (org-parse-time-string ts nil t)))
|
(org-parse-time-string
|
||||||
te (float-time
|
(match-string 2) nil t)))))
|
||||||
(apply #'encode-time (org-parse-time-string te nil t)))
|
(te (float-time
|
||||||
ts (if tstart (max ts tstart) ts)
|
(apply #'encode-time
|
||||||
te (if tend (min te tend) te)
|
(org-parse-time-string (match-string 3) nil t))))
|
||||||
dt (- te ts)
|
(dt (- (if tend (min te tend) te)
|
||||||
t1 (if (> dt 0) (+ t1 (floor (/ dt 60))) t1)))
|
(if tstart (max ts tstart) ts))))
|
||||||
|
(when (> dt 0) (cl-incf t1 (floor (/ dt 60))))))
|
||||||
((match-end 4)
|
((match-end 4)
|
||||||
;; A naked time
|
;; A naked time.
|
||||||
(setq t1 (+ t1 (string-to-number (match-string 5))
|
(setq t1 (+ t1 (string-to-number (match-string 5))
|
||||||
(* 60 (string-to-number (match-string 4))))))
|
(* 60 (string-to-number (match-string 4))))))
|
||||||
(t ;; A headline
|
(t ;A headline
|
||||||
;; Add the currently clocking item time to the total
|
;; Add the currently clocking item time to the total.
|
||||||
(when (and org-clock-report-include-clocking-task
|
(when (and org-clock-report-include-clocking-task
|
||||||
(equal (org-clocking-buffer) (current-buffer))
|
(eq (org-clocking-buffer) (current-buffer))
|
||||||
(equal (marker-position org-clock-hd-marker) (point))
|
(eq (marker-position org-clock-hd-marker) (point))
|
||||||
tstart
|
tstart
|
||||||
tend
|
tend
|
||||||
(>= (float-time org-clock-start-time) tstart)
|
(>= (float-time org-clock-start-time) tstart)
|
||||||
|
|
Loading…
Reference in New Issue