emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Incorrect time calculation in agenda clockcheck
@ 2024-05-15 13:34 Raffael Stocker
  2024-05-17 11:45 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Raffael Stocker @ 2024-05-15 13:34 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]


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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-agenda-primitive.patch --]
[-- Type: text/x-patch, Size: 863 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [BUG] Incorrect time calculation in agenda clockcheck
  2024-05-15 13:34 [BUG] Incorrect time calculation in agenda clockcheck Raffael Stocker
@ 2024-05-17 11:45 ` Ihor Radchenko
  2024-05-17 13:43   ` Mnet-Mail
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2024-05-17 11:45 UTC (permalink / raw)
  To: Raffael Stocker; +Cc: emacs-orgmode

Raffael Stocker <r.stocker@mnet-mail.de> writes:

> 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)".

Thanks for reporting!
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ee58259bc

> 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:
>...
> However, I believe it would be more useful (and general) to use a
> similar trick to teach org-duration to work with negative durations.

That's what I ended up doing.

> ... It would be more sensible to ... or even "No end time: (in 0:05)".

I find this confusing, so I left -0:05.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] Incorrect time calculation in agenda clockcheck
  2024-05-17 11:45 ` Ihor Radchenko
@ 2024-05-17 13:43   ` Mnet-Mail
  0 siblings, 0 replies; 3+ messages in thread
From: Mnet-Mail @ 2024-05-17 13:43 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]

Thanks!

Am 17. Mai 2024 11:45:32 UTC schrieb Ihor Radchenko <yantar92@posteo.net>:
>Raffael Stocker <r.stocker@mnet-mail.de> writes:
>
>> 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)".
>
>Thanks for reporting!
>Fixed, on main.
>https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ee58259bc
>
>> 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:
>>...
>> However, I believe it would be more useful (and general) to use a
>> similar trick to teach org-duration to work with negative durations.
>
>That's what I ended up doing.
>
>> ... It would be more sensible to ... or even "No end time: (in 0:05)".
>
>I find this confusing, so I left -0:05.
>
>-- 
>Ihor Radchenko // yantar92,
>Org mode contributor,
>Learn more about Org mode at <https://orgmode.org/>.
>Support Org development at <https://liberapay.com/org-mode>,
>or support my work at <https://liberapay.com/yantar92>

[-- Attachment #2: Type: text/html, Size: 2319 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-17 13:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15 13:34 [BUG] Incorrect time calculation in agenda clockcheck Raffael Stocker
2024-05-17 11:45 ` Ihor Radchenko
2024-05-17 13:43   ` Mnet-Mail

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).