Subject: bug#50216: 27.2; timeclock gives incorrect time in mode-line

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 27 Aug 2021 03:01:13 +0200

Colin Baxter <[email-masked]> writes:

> B. Repeat the process.
>
> 1. timeclock log file present
> 2. emacs -Q
> 3. In Scratch buffer, evaluate
>    (display-time)
>    (timeclock-mode-line-display 1)
>    (setq timeclock-workday (* 12 60 60))
> 4. mode-line reads [7:58]
> 5. Mx timeclock-in <RET>
> 6. mode-line reads <7:57>
> 7. Wrote /home/redknight/.emacs.d/timelog
> 8. Wait a minute or two.
> 9. M-x timeclock-out <RET>
> 10. mode-line reads [7:55]
> 11. Wrote /home/redknight/.emacs.d/timelog
> 12. Close emacs
>
> Emacs incorrectly counts down workday, starting form the default value of 8 hours even though it was set to 12 hours.

Thanks for the detailed recipes.  I tried this in Emacs 28, and I can
reproduce the problem.  However, I'm seeing exactly the same behaviour
in Emacs 27.2 (and earlier), and I think you said over on emacs-devel
that this used to work there?

> E. Repeat process but change the lisp order
>
> 1. No timeclock log file
> 2. emacs -Q
> 3. In Scratch buffer, evaluate
>    (setq timeclock-workday (* 12 60 60))
>    (timeclock-mode-line-display 1)
>    Message: "Activate ‘display-time-mode’ or turn off ‘timeclock-use-display-time’ to see timeclock information"
> 4. M-x timeclock-in <RET>
> 5. mode-line reads [11:56]
> 6. Wait a minute or two.
> 7. M-x timeclock-out <RET>
> 8. mode-line reads [11:54]
> 9. Wrote /home/redknight/.emacs.d/timelog
> 10. Close emacs.
>
> Emacs again gives the correct workday even when the mode-line display
> occurs after the workday setting.
>
> The issue seem to be the presence or otherwise of (display-time).

I'm not so sure.  In all the cases where things work correctly (when
setting timeclock after `timeclock-mode-line-display'), there's no
timelog file.  So the issue seems to be: Setting workday after timeclock
+ having a log file?

I haven't really started debugging in, but the issue seems to be
`timeclock-find-discrep' using some data that was computed before
timeclock-workday was set...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no