[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG] Incorrect time calculation in agenda clockcheck
From: |
Raffael Stocker |
Subject: |
[BUG] Incorrect time calculation in agenda clockcheck |
Date: |
Wed, 15 May 2024 15:34:01 +0200 |
User-agent: |
mu4e 1.12.0; emacs 29.3 |
Hi org-mode,
in the Org Agenda clockcheck view, a warning about missing end time of a
clocked-in task is displayed together with the already elapsed time of
that task. If the starting time is in the future (this can happen if
rounding and continuous clocking are used), the elapsed time is
incorrect. For example, if a clocked-in task starts in 5 minutes,
clockcheck will report something like "No end time: (0:55)". It would
be more sensible to say "No end time: (-0:05)" or even "No end time: (in
0:05)".
The culprit is the use of ‘org-duration-from-minutes’ in
‘org-agenda-show-clocking-issues’, because org-duration always assumes
positive durations and is given a negative one here. The problem can
easily be corrected with something like the following:
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b3c7294a2..968b6bd50 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6237,11 +6237,12 @@ defun org-agenda-show-clocking-issues
(setq issue
(format
"No end time: (%s)"
- (org-duration-from-minutes
- (floor
- (- (float-time (org-current-time))
- (float-time (org-time-string-to-time (match-string
1))))
- 60)))
+ (let ((diff (floor
+ (- (float-time (org-current-time))
+ (float-time (org-time-string-to-time
(match-string 1))))
+ 60)))
+ (concat (if (> 0 diff) "-" "")
+ (org-duration-from-minutes (abs diff)))))
face (or (plist-get pl :no-end-time-face) face))
(throw 'next t))
(setq ts (match-string 1)
However, I believe it would be more useful (and general) to use a
similar trick to teach org-duration to work with negative durations.
Cheers,
Raffael
- [BUG] Incorrect time calculation in agenda clockcheck,
Raffael Stocker <=