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

From: Colin Baxter <[email-masked]>
Date: Thu, 26 Aug 2021 20:11:40 +0100

Using emacs-28.0.50:

A. First Process

1. No timeclock log file
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 [0:00]
5. M-x timeclock-in <RET>
6. mode-line reads [11:59]
7. Wait a minute or two.
8. M-x timeclock-out <RET>
9. mode-line reads [11:58]
10. Wrote /home/redknight/.emacs.d/timelog
11. Close emacs.

Emacs correctly counts down the set workday of 12:00 hours.

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.

C. Repeat process but change order of lisp

1. timeclock log file present
2. emacs -Q
3. In Scratch buffer, evaluate
   (display-time)
   (setq timeclock-workday (* 12 60 60))
   (timeclock-mode-line-display 1)
4. mode-line reads [11:55]
5. Mx timeclock-in <RET>
6. mode-line reads <11:55>
7. Wrote /home/redknight/.emacs.d/timelog
8. Wait a minute or two.
9. M-x timeclock-out <RET>
10. mode-line reads [11:54]
11. Wrote /home/redknight/.emacs.d/timelog
12. Close emacs

By setting workday before mode-line-display, Emacs gives the correct workday, counting down from the set 12 hours.

D. Repeat first process A. but omit (display-time)

1. No timeclock log file
2. emacs -Q
3. In Scratch buffer, evaluate
   (timeclock-mode-line-display 1)
   Message: "Activate ‘display-time-mode’ or turn off ‘timeclock-use-display-time’ to see timeclock information"
   (setq timeclock-workday (* 12 60 60))
4. M-x timeclock-in <RET>
5. mode-line reads [11:59]
6. Wait a minute or two.
7. M-x timeclock-out <RET>
8. mode-line reads [11:56]
9. Wrote /home/redknight/.emacs.d/timelog
10. Close emacs.

Emacs gives the correct workday.

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). If it is present then the display of the set workday of 12 hours depends on when timeclock-mode-line is activated. Only if it is activated after setting the workday does the mode-line display correctly. However, if (display-time) is not used then the user gets an "Activate" message.

In GNU Emacs 27.2 (build 1, i686-pc-linux-gnu, X toolkit, cairo version 1.14.8, Xaw3d scroll bars)
 of 2021-03-28 built on bluestar
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description: Debian GNU/Linux 9 (stretch)