Mercurial > emacs
annotate lisp/calendar/timeclock.el @ 102975:efeb215b8665
* display.texi (Truncation): Overlays can use line-prefix and
wrap-prefix too.
(Overlay Properties): Document wrap-prefix and line-prefix.
(Face Attributes): Document underline-minimum-offset.
(Face Remapping): Copyedits.
(Low-Level Font): Copyedits.
(Image Cache): Note that the image cache is shared between frames.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 15 Apr 2009 03:07:06 +0000 |
parents | a9dc0e7c3f2b |
children | bd2966850aac |
rev | line source |
---|---|
30781 | 1 ;;; timeclock.el --- mode for keeping track of how much you work |
2 | |
92600 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
100908 | 4 ;; 2008, 2009 Free Software Foundation, Inc. |
30781 | 5 |
6 ;; Author: John Wiegley <johnw@gnu.org> | |
7 ;; Created: 25 Mar 1999 | |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
8 ;; Version: 2.6.1 |
30781 | 9 ;; Keywords: calendar data |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92957
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
30781 | 14 ;; it under the terms of the GNU General Public License as published by |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92957
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92957
diff
changeset
|
16 ;; (at your option) any later version. |
30781 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92957
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
30781 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This mode is for keeping track of time intervals. You can use it | |
29 ;; for whatever purpose you like, but the typical scenario is to keep | |
30 ;; track of how much time you spend working on certain projects. | |
31 ;; | |
32 ;; Use `timeclock-in' when you start on a project, and `timeclock-out' | |
33 ;; when you're done. Once you've collected some data, you can use | |
34 ;; `timeclock-workday-remaining' to see how much time is left to be | |
51871 | 35 ;; worked today (where `timeclock-workday' specifies the length of the |
36 ;; working day), and `timeclock-when-to-leave' to calculate when you're free. | |
30781 | 37 |
38 ;; You'll probably want to bind the timeclock commands to some handy | |
51871 | 39 ;; keystrokes. At the moment, C-x t is unused: |
30781 | 40 ;; |
41 ;; (require 'timeclock) | |
42 ;; | |
43 ;; (define-key ctl-x-map "ti" 'timeclock-in) | |
44 ;; (define-key ctl-x-map "to" 'timeclock-out) | |
45 ;; (define-key ctl-x-map "tc" 'timeclock-change) | |
46 ;; (define-key ctl-x-map "tr" 'timeclock-reread-log) | |
47 ;; (define-key ctl-x-map "tu" 'timeclock-update-modeline) | |
48 ;; (define-key ctl-x-map "tw" 'timeclock-when-to-leave-string) | |
49 | |
50 ;; If you want Emacs to display the amount of time "left" to your | |
51 ;; workday in the modeline, you can either set the value of | |
52 ;; `timeclock-modeline-display' to t using M-x customize, or you | |
53 ;; can add this code to your .emacs file: | |
54 ;; | |
55 ;; (require 'timeclock) | |
56 ;; (timeclock-modeline-display) | |
57 ;; | |
58 ;; To cancel this modeline display at any time, just call | |
59 ;; `timeclock-modeline-display' again. | |
60 | |
61 ;; You may also want Emacs to ask you before exiting, if you are | |
54704 | 62 ;; currently working on a project. This can be done either by setting |
30781 | 63 ;; `timeclock-ask-before-exiting' to t using M-x customize (this is |
64 ;; the default), or by adding the following to your .emacs file: | |
65 ;; | |
51263 | 66 ;; (add-hook 'kill-emacs-query-functions 'timeclock-query-out) |
30781 | 67 |
68 ;; NOTE: If you change your .timelog file without using timeclock's | |
69 ;; functions, or if you change the value of any of timeclock's | |
70 ;; customizable variables, you should run the command | |
71 ;; `timeclock-reread-log'. This will recompute any discrepancies in | |
72 ;; your average working time, and will make sure that the various | |
73 ;; display functions return the correct value. | |
74 | |
75 ;;; History: | |
76 | |
77 ;;; Code: | |
78 | |
79 (defgroup timeclock nil | |
61327 | 80 "Keeping track of the time that gets spent." |
30781 | 81 :group 'data) |
82 | |
83 ;;; User Variables: | |
84 | |
30795
5b4027fef808
(timeclock-file): Run .timelog through convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents:
30781
diff
changeset
|
85 (defcustom timeclock-file (convert-standard-filename "~/.timelog") |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
86 "The file used to store timeclock data in." |
30781 | 87 :type 'file |
88 :group 'timeclock) | |
89 | |
90 (defcustom timeclock-workday (* 8 60 60) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
91 "The length of a work period in seconds." |
30781 | 92 :type 'integer |
93 :group 'timeclock) | |
94 | |
95 (defcustom timeclock-relative t | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
96 "Whether to make reported time relative to `timeclock-workday'. |
30781 | 97 For example, if the length of a normal workday is eight hours, and you |
98 work four hours on Monday, then the amount of time \"remaining\" on | |
99 Tuesday is twelve hours -- relative to an averaged work period of | |
100 eight hours -- or eight hours, non-relative. So relative time takes | |
51871 | 101 into account any discrepancy of time under-worked or over-worked on |
102 previous days. This only affects the timeclock modeline display." | |
30781 | 103 :type 'boolean |
104 :group 'timeclock) | |
105 | |
106 (defcustom timeclock-get-project-function 'timeclock-ask-for-project | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
107 "The function used to determine the name of the current project. |
30781 | 108 When clocking in, and no project is specified, this function will be |
54704 | 109 called to determine what is the current project to be worked on. |
30781 | 110 If this variable is nil, no questions will be asked." |
111 :type 'function | |
112 :group 'timeclock) | |
113 | |
114 (defcustom timeclock-get-reason-function 'timeclock-ask-for-reason | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
115 "A function used to determine the reason for clocking out. |
30781 | 116 When clocking out, and no reason is specified, this function will be |
54704 | 117 called to determine what is the reason. |
30781 | 118 If this variable is nil, no questions will be asked." |
119 :type 'function | |
120 :group 'timeclock) | |
121 | |
122 (defcustom timeclock-get-workday-function nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
123 "A function used to determine the length of today's workday. |
30781 | 124 The first time that a user clocks in each day, this function will be |
54704 | 125 called to determine what is the length of the current workday. If |
46341
ff3a56c0df0f
(timeclock-get-workday-function): `timeclock-workday' is not a valid
Glenn Morris <rgm@gnu.org>
parents:
46160
diff
changeset
|
126 the return value is nil, or equal to `timeclock-workday', nothing special |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48224
diff
changeset
|
127 will be done. If it is a quantity different from `timeclock-workday', |
46341
ff3a56c0df0f
(timeclock-get-workday-function): `timeclock-workday' is not a valid
Glenn Morris <rgm@gnu.org>
parents:
46160
diff
changeset
|
128 however, a record will be output to the timelog file to note the fact that |
54704 | 129 that day has a length that is different from the norm." |
46341
ff3a56c0df0f
(timeclock-get-workday-function): `timeclock-workday' is not a valid
Glenn Morris <rgm@gnu.org>
parents:
46160
diff
changeset
|
130 :type '(choice (const nil) function) |
30781 | 131 :group 'timeclock) |
132 | |
133 (defcustom timeclock-ask-before-exiting t | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
134 "If non-nil, ask if the user wants to clock out before exiting Emacs. |
54704 | 135 This variable only has effect if set with \\[customize]." |
30781 | 136 :set (lambda (symbol value) |
137 (if value | |
51263 | 138 (add-hook 'kill-emacs-query-functions 'timeclock-query-out) |
139 (remove-hook 'kill-emacs-query-functions 'timeclock-query-out)) | |
30781 | 140 (setq timeclock-ask-before-exiting value)) |
141 :type 'boolean | |
142 :group 'timeclock) | |
143 | |
144 (defvar timeclock-update-timer nil | |
145 "The timer used to update `timeclock-mode-string'.") | |
146 | |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
147 ;; For byte-compiler. |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
148 (defvar display-time-hook) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
149 (defvar timeclock-modeline-display) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
150 |
30781 | 151 (defcustom timeclock-use-display-time t |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
152 "If non-nil, use `display-time-hook' for doing modeline updates. |
54704 | 153 The advantage of this is that one less timer has to be set running |
154 amok in Emacs' process space. The disadvantage is that it requires | |
155 you to have `display-time' running. If you don't want to use | |
30781 | 156 `display-time', but still want the modeline to show how much time is |
51871 | 157 left, set this variable to nil. Changing the value of this variable |
158 while timeclock information is being displayed in the modeline has no | |
159 effect. You should call the function `timeclock-modeline-display' with | |
160 a positive argument to force an update." | |
30781 | 161 :set (lambda (symbol value) |
162 (let ((currently-displaying | |
163 (and (boundp 'timeclock-modeline-display) | |
164 timeclock-modeline-display))) | |
165 ;; if we're changing to the state that | |
166 ;; `timeclock-modeline-display' is already using, don't | |
167 ;; bother toggling it. This happens on the initial loading | |
168 ;; of timeclock.el. | |
169 (if (and currently-displaying | |
170 (or (and value | |
171 (boundp 'display-time-hook) | |
172 (memq 'timeclock-update-modeline | |
173 display-time-hook)) | |
174 (and (not value) | |
175 timeclock-update-timer))) | |
176 (setq currently-displaying nil)) | |
177 (and currently-displaying | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
178 (set-variable 'timeclock-modeline-display nil)) |
30781 | 179 (setq timeclock-use-display-time value) |
180 (and currently-displaying | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
181 (set-variable 'timeclock-modeline-display t)) |
30781 | 182 timeclock-use-display-time)) |
183 :type 'boolean | |
184 :group 'timeclock | |
185 :require 'time) | |
186 | |
187 (defcustom timeclock-first-in-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
188 "A hook run for the first \"in\" event each day. |
30781 | 189 Note that this hook is run before recording any events. Thus the |
190 value of `timeclock-hours-today', `timeclock-last-event' and the | |
191 return value of function `timeclock-last-period' are relative previous | |
192 to today." | |
193 :type 'hook | |
194 :group 'timeclock) | |
195 | |
196 (defcustom timeclock-load-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
197 "Hook that gets run after timeclock has been loaded." |
30781 | 198 :type 'hook |
199 :group 'timeclock) | |
200 | |
201 (defcustom timeclock-in-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
202 "A hook run every time an \"in\" event is recorded." |
30781 | 203 :type 'hook |
204 :group 'timeclock) | |
205 | |
206 (defcustom timeclock-day-over-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
207 "A hook that is run when the workday has been completed. |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
208 This hook is only run if the current time remaining is being displayed |
30781 | 209 in the modeline. See the variable `timeclock-modeline-display'." |
210 :type 'hook | |
211 :group 'timeclock) | |
212 | |
213 (defcustom timeclock-out-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
214 "A hook run every time an \"out\" event is recorded." |
30781 | 215 :type 'hook |
216 :group 'timeclock) | |
217 | |
218 (defcustom timeclock-done-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
219 "A hook run every time a project is marked as completed." |
30781 | 220 :type 'hook |
221 :group 'timeclock) | |
222 | |
223 (defcustom timeclock-event-hook nil | |
92548
979f17a77d87
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
224 "A hook run every time any event is recorded." |
30781 | 225 :type 'hook |
226 :group 'timeclock) | |
227 | |
228 (defvar timeclock-last-event nil | |
229 "A list containing the last event that was recorded. | |
33020 | 230 The format of this list is (CODE TIME PROJECT).") |
30781 | 231 |
232 (defvar timeclock-last-event-workday nil | |
233 "The number of seconds in the workday of `timeclock-last-event'.") | |
234 | |
235 ;;; Internal Variables: | |
236 | |
237 (defvar timeclock-discrepancy nil | |
238 "A variable containing the time discrepancy before the last event. | |
239 Normally, timeclock assumes that you intend to work for | |
240 `timeclock-workday' seconds every day. Any days in which you work | |
241 more or less than this amount is considered either a positive or | |
54704 | 242 a negative discrepancy. If you work in such a manner that the |
30781 | 243 discrepancy is always brought back to zero, then you will by |
244 definition have worked an average amount equal to `timeclock-workday' | |
245 each day.") | |
246 | |
247 (defvar timeclock-elapsed nil | |
248 "A variable containing the time elapsed for complete periods today. | |
249 This value is not accurate enough to be useful by itself. Rather, | |
250 call `timeclock-workday-elapsed', to determine how much time has been | |
251 worked so far today. Also, if `timeclock-relative' is nil, this value | |
72331
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
252 will be the same as `timeclock-discrepancy'.") |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
253 |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
254 (defvar timeclock-use-elapsed nil |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
255 "Non-nil if the modeline should display time elapsed, not remaining.") |
30781 | 256 |
257 (defvar timeclock-last-period nil | |
258 "Integer representing the number of seconds in the last period. | |
54704 | 259 Note that you shouldn't access this value, but instead should use the |
260 function `timeclock-last-period'.") | |
30781 | 261 |
262 (defvar timeclock-mode-string nil | |
51263 | 263 "The timeclock string (optionally) displayed in the modeline. |
264 The time is bracketed by <> if you are clocked in, otherwise by [].") | |
30781 | 265 |
266 (defvar timeclock-day-over nil | |
267 "The date of the last day when notified \"day over\" for.") | |
268 | |
269 ;;; User Functions: | |
270 | |
271 ;;;###autoload | |
272 (defun timeclock-modeline-display (&optional arg) | |
273 "Toggle display of the amount of time left today in the modeline. | |
51263 | 274 If `timeclock-use-display-time' is non-nil (the default), then |
275 the function `display-time-mode' must be active, and the modeline | |
276 will be updated whenever the time display is updated. Otherwise, | |
277 the timeclock will use its own sixty second timer to do its | |
278 updating. With prefix ARG, turn modeline display on if and only | |
279 if ARG is positive. Returns the new status of timeclock modeline | |
280 display (non-nil means on)." | |
30781 | 281 (interactive "P") |
51263 | 282 ;; cf display-time-mode. |
283 (setq timeclock-mode-string "") | |
284 (or global-mode-string (setq global-mode-string '(""))) | |
30781 | 285 (let ((on-p (if arg |
286 (> (prefix-numeric-value arg) 0) | |
287 (not timeclock-modeline-display)))) | |
288 (if on-p | |
51263 | 289 (progn |
290 (or (memq 'timeclock-mode-string global-mode-string) | |
291 (setq global-mode-string | |
292 (append global-mode-string '(timeclock-mode-string)))) | |
30781 | 293 (unless (memq 'timeclock-update-modeline timeclock-event-hook) |
294 (add-hook 'timeclock-event-hook 'timeclock-update-modeline)) | |
295 (when timeclock-update-timer | |
296 (cancel-timer timeclock-update-timer) | |
297 (setq timeclock-update-timer nil)) | |
298 (if (boundp 'display-time-hook) | |
299 (remove-hook 'display-time-hook 'timeclock-update-modeline)) | |
300 (if timeclock-use-display-time | |
51263 | 301 (progn |
302 ;; Update immediately so there is a visible change | |
303 ;; on calling this function. | |
51871 | 304 (if display-time-mode (timeclock-update-modeline) |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
305 (message "Activate `display-time-mode' or turn off \ |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
306 `timeclock-use-display-time' to see timeclock information")) |
51263 | 307 (add-hook 'display-time-hook 'timeclock-update-modeline)) |
30781 | 308 (setq timeclock-update-timer |
309 (run-at-time nil 60 'timeclock-update-modeline)))) | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
310 (setq global-mode-string |
51263 | 311 (delq 'timeclock-mode-string global-mode-string)) |
30781 | 312 (remove-hook 'timeclock-event-hook 'timeclock-update-modeline) |
313 (if (boundp 'display-time-hook) | |
314 (remove-hook 'display-time-hook | |
315 'timeclock-update-modeline)) | |
316 (when timeclock-update-timer | |
317 (cancel-timer timeclock-update-timer) | |
318 (setq timeclock-update-timer nil))) | |
319 (force-mode-line-update) | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
320 (setq timeclock-modeline-display on-p))) |
30781 | 321 |
322 ;; This has to be here so that the function definition of | |
323 ;; `timeclock-modeline-display' is known to the "set" function. | |
324 (defcustom timeclock-modeline-display nil | |
325 "Toggle modeline display of time remaining. | |
326 You must modify via \\[customize] for this variable to have an effect." | |
327 :set (lambda (symbol value) | |
328 (setq timeclock-modeline-display | |
329 (timeclock-modeline-display (or value 0)))) | |
330 :type 'boolean | |
331 :group 'timeclock | |
332 :require 'timeclock) | |
333 | |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
334 (defsubst timeclock-time-to-date (time) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
335 "Convert the TIME value to a textual date string." |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
336 (format-time-string "%Y/%m/%d" time)) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
337 |
30781 | 338 ;;;###autoload |
339 (defun timeclock-in (&optional arg project find-project) | |
340 "Clock in, recording the current time moment in the timelog. | |
341 With a numeric prefix ARG, record the fact that today has only that | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
342 many hours in it to be worked. If ARG is a non-numeric prefix argument |
30781 | 343 \(non-nil, but not a number), 0 is assumed (working on a holiday or |
344 weekend). *If not called interactively, ARG should be the number of | |
345 _seconds_ worked today*. This feature only has effect the first time | |
346 this function is called within a day. | |
347 | |
54704 | 348 PROJECT is the project being clocked into. If PROJECT is nil, and |
30781 | 349 FIND-PROJECT is non-nil -- or the user calls `timeclock-in' |
350 interactively -- call the function `timeclock-get-project-function' to | |
351 discover the name of the project." | |
352 (interactive | |
353 (list (and current-prefix-arg | |
354 (if (numberp current-prefix-arg) | |
355 (* current-prefix-arg 60 60) | |
356 0)))) | |
357 (if (equal (car timeclock-last-event) "i") | |
358 (error "You've already clocked in!") | |
359 (unless timeclock-last-event | |
360 (timeclock-reread-log)) | |
46350
9cead6e97a53
(timeclock-in): Run the new day section if, after rereading the log file,
Glenn Morris <rgm@gnu.org>
parents:
46341
diff
changeset
|
361 ;; Either no log file, or day has rolled over. |
9cead6e97a53
(timeclock-in): Run the new day section if, after rereading the log file,
Glenn Morris <rgm@gnu.org>
parents:
46341
diff
changeset
|
362 (unless (and timeclock-last-event |
9cead6e97a53
(timeclock-in): Run the new day section if, after rereading the log file,
Glenn Morris <rgm@gnu.org>
parents:
46341
diff
changeset
|
363 (equal (timeclock-time-to-date |
9cead6e97a53
(timeclock-in): Run the new day section if, after rereading the log file,
Glenn Morris <rgm@gnu.org>
parents:
46341
diff
changeset
|
364 (cadr timeclock-last-event)) |
9cead6e97a53
(timeclock-in): Run the new day section if, after rereading the log file,
Glenn Morris <rgm@gnu.org>
parents:
46341
diff
changeset
|
365 (timeclock-time-to-date (current-time)))) |
30781 | 366 (let ((workday (or (and (numberp arg) arg) |
367 (and arg 0) | |
368 (and timeclock-get-workday-function | |
369 (funcall timeclock-get-workday-function)) | |
370 timeclock-workday))) | |
371 (run-hooks 'timeclock-first-in-hook) | |
372 ;; settle the discrepancy for the new day | |
373 (setq timeclock-discrepancy | |
46350
9cead6e97a53
(timeclock-in): Run the new day section if, after rereading the log file,
Glenn Morris <rgm@gnu.org>
parents:
46341
diff
changeset
|
374 (- (or timeclock-discrepancy 0) workday)) |
30781 | 375 (if (not (= workday timeclock-workday)) |
77671
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
376 (timeclock-log "h" (number-to-string |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
377 (/ workday (if (zerop (% workday (* 60 60))) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
378 60 60.0) 60)))))) |
30781 | 379 (timeclock-log "i" (or project |
380 (and timeclock-get-project-function | |
381 (or find-project (interactive-p)) | |
382 (funcall timeclock-get-project-function)))) | |
383 (run-hooks 'timeclock-in-hook))) | |
384 | |
385 ;;;###autoload | |
386 (defun timeclock-out (&optional arg reason find-reason) | |
387 "Clock out, recording the current time moment in the timelog. | |
388 If a prefix ARG is given, the user has completed the project that was | |
389 begun during the last time segment. | |
390 | |
391 REASON is the user's reason for clocking out. If REASON is nil, and | |
392 FIND-REASON is non-nil -- or the user calls `timeclock-out' | |
393 interactively -- call the function `timeclock-get-reason-function' to | |
394 discover the reason." | |
395 (interactive "P") | |
40671
526c9b7941f5
(timeclock-out): Signal an error if timeclock-last-event is nil.
Eli Zaretskii <eliz@gnu.org>
parents:
37652
diff
changeset
|
396 (or timeclock-last-event |
526c9b7941f5
(timeclock-out): Signal an error if timeclock-last-event is nil.
Eli Zaretskii <eliz@gnu.org>
parents:
37652
diff
changeset
|
397 (error "You haven't clocked in!")) |
30781 | 398 (if (equal (downcase (car timeclock-last-event)) "o") |
399 (error "You've already clocked out!") | |
400 (timeclock-log | |
401 (if arg "O" "o") | |
402 (or reason | |
403 (and timeclock-get-reason-function | |
404 (or find-reason (interactive-p)) | |
405 (funcall timeclock-get-reason-function)))) | |
406 (run-hooks 'timeclock-out-hook) | |
407 (if arg | |
408 (run-hooks 'timeclock-done-hook)))) | |
409 | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
410 ;; Should today-only be removed in favour of timeclock-relative? - gm |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
411 (defsubst timeclock-workday-remaining (&optional today-only) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
412 "Return the number of seconds until the workday is complete. |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
413 The amount returned is relative to the value of `timeclock-workday'. |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
414 If TODAY-ONLY is non-nil, the value returned will be relative only to |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
415 the time worked today, and not to past time." |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
416 (let ((discrep (timeclock-find-discrep))) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
417 (if discrep |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
418 (- (if today-only (cadr discrep) |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
419 (car discrep))) |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
420 0.0))) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
421 |
30781 | 422 ;;;###autoload |
423 (defun timeclock-status-string (&optional show-seconds today-only) | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
424 "Report the overall timeclock status at the present moment. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
425 If SHOW-SECONDS is non-nil, display second resolution. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
426 If TODAY-ONLY is non-nil, the display will be relative only to time |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
427 worked today, ignoring the time worked on previous days." |
30781 | 428 (interactive "P") |
72331
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
429 (let ((remainder (timeclock-workday-remaining |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
430 (or today-only |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
431 (not timeclock-relative)))) |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
432 (last-in (equal (car timeclock-last-event) "i")) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
433 status) |
30781 | 434 (setq status |
435 (format "Currently %s since %s (%s), %s %s, leave at %s" | |
436 (if last-in "IN" "OUT") | |
437 (if show-seconds | |
438 (format-time-string "%-I:%M:%S %p" | |
439 (nth 1 timeclock-last-event)) | |
440 (format-time-string "%-I:%M %p" | |
441 (nth 1 timeclock-last-event))) | |
442 (or (nth 2 timeclock-last-event) | |
443 (if last-in "**UNKNOWN**" "workday over")) | |
444 (timeclock-seconds-to-string remainder show-seconds t) | |
445 (if (> remainder 0) | |
446 "remaining" "over") | |
447 (timeclock-when-to-leave-string show-seconds today-only))) | |
448 (if (interactive-p) | |
65591
a65f8ec418fc
message format spec fixes, commit # 10
Deepak Goel <deego@gnufans.org>
parents:
64085
diff
changeset
|
449 (message "%s" status) |
30781 | 450 status))) |
451 | |
452 ;;;###autoload | |
453 (defun timeclock-change (&optional arg project) | |
54704 | 454 "Change to working on a different project. |
455 This clocks out of the current project, then clocks in on a new one. | |
456 With a prefix ARG, consider the previous project as finished at the | |
457 time of changeover. PROJECT is the name of the last project you were | |
458 working on." | |
30781 | 459 (interactive "P") |
460 (timeclock-out arg) | |
461 (timeclock-in nil project (interactive-p))) | |
462 | |
463 ;;;###autoload | |
464 (defun timeclock-query-out () | |
54704 | 465 "Ask the user whether to clock out. |
51263 | 466 This is a useful function for adding to `kill-emacs-query-functions'." |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
467 (and (equal (car timeclock-last-event) "i") |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
468 (y-or-n-p "You're currently clocking time, clock out? ") |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
469 (timeclock-out)) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
470 ;; Unconditionally return t for `kill-emacs-query-functions'. |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
471 t) |
30781 | 472 |
473 ;;;###autoload | |
474 (defun timeclock-reread-log () | |
475 "Re-read the timeclock, to account for external changes. | |
476 Returns the new value of `timeclock-discrepancy'." | |
477 (interactive) | |
478 (setq timeclock-discrepancy nil) | |
479 (timeclock-find-discrep) | |
36851 | 480 (if (and timeclock-discrepancy timeclock-modeline-display) |
30781 | 481 (timeclock-update-modeline)) |
482 timeclock-discrepancy) | |
483 | |
484 (defun timeclock-seconds-to-string (seconds &optional show-seconds | |
485 reverse-leader) | |
486 "Convert SECONDS into a compact time string. | |
487 If SHOW-SECONDS is non-nil, make the resolution of the return string | |
488 include the second count. If REVERSE-LEADER is non-nil, it means to | |
489 output a \"+\" if the time value is negative, rather than a \"-\". | |
490 This is used when negative time values have an inverted meaning (such | |
491 as with time remaining, where negative time really means overtime)." | |
492 (if show-seconds | |
493 (format "%s%d:%02d:%02d" | |
494 (if (< seconds 0) (if reverse-leader "+" "-") "") | |
495 (truncate (/ (abs seconds) 60 60)) | |
496 (% (truncate (/ (abs seconds) 60)) 60) | |
497 (% (truncate (abs seconds)) 60)) | |
498 (format "%s%d:%02d" | |
499 (if (< seconds 0) (if reverse-leader "+" "-") "") | |
500 (truncate (/ (abs seconds) 60 60)) | |
501 (% (truncate (/ (abs seconds) 60)) 60)))) | |
502 | |
33020 | 503 (defsubst timeclock-currently-in-p () |
30781 | 504 "Return non-nil if the user is currently clocked in." |
505 (equal (car timeclock-last-event) "i")) | |
506 | |
507 ;;;###autoload | |
508 (defun timeclock-workday-remaining-string (&optional show-seconds | |
509 today-only) | |
510 "Return a string representing the amount of time left today. | |
511 Display second resolution if SHOW-SECONDS is non-nil. If TODAY-ONLY | |
512 is non-nil, the display will be relative only to time worked today. | |
513 See `timeclock-relative' for more information about the meaning of | |
514 \"relative to today\"." | |
515 (interactive) | |
516 (let ((string (timeclock-seconds-to-string | |
517 (timeclock-workday-remaining today-only) | |
518 show-seconds t))) | |
519 (if (interactive-p) | |
65591
a65f8ec418fc
message format spec fixes, commit # 10
Deepak Goel <deego@gnufans.org>
parents:
64085
diff
changeset
|
520 (message "%s" string) |
30781 | 521 string))) |
522 | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
523 (defsubst timeclock-workday-elapsed () |
46160
b88409633904
(timeclock-workday-remaining): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
40671
diff
changeset
|
524 "Return the number of seconds worked so far today. |
30781 | 525 If RELATIVE is non-nil, the amount returned will be relative to past |
526 time worked. The default is to return only the time that has elapsed | |
527 so far today." | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
528 (let ((discrep (timeclock-find-discrep))) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
529 (if discrep |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
530 (nth 2 discrep) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
531 0.0))) |
30781 | 532 |
533 ;;;###autoload | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
534 (defun timeclock-workday-elapsed-string (&optional show-seconds) |
30781 | 535 "Return a string representing the amount of time worked today. |
536 Display seconds resolution if SHOW-SECONDS is non-nil. If RELATIVE is | |
537 non-nil, the amount returned will be relative to past time worked." | |
538 (interactive) | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
539 (let ((string (timeclock-seconds-to-string (timeclock-workday-elapsed) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
540 show-seconds))) |
30781 | 541 (if (interactive-p) |
65591
a65f8ec418fc
message format spec fixes, commit # 10
Deepak Goel <deego@gnufans.org>
parents:
64085
diff
changeset
|
542 (message "%s" string) |
30781 | 543 string))) |
544 | |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
545 (defsubst timeclock-time-to-seconds (time) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
546 "Convert TIME to a floating point number." |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
547 (+ (* (car time) 65536.0) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
548 (cadr time) |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
549 (/ (or (nth 2 time) 0) 1000000.0))) |
51549
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
550 |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
551 (defsubst timeclock-seconds-to-time (seconds) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
552 "Convert SECONDS (a floating point number) to an Emacs time structure." |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
553 (list (floor seconds 65536) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
554 (floor (mod seconds 65536)) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
555 (floor (* (- seconds (ffloor seconds)) 1000000)))) |
48facdb1558e
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
Glenn Morris <rgm@gnu.org>
parents:
51263
diff
changeset
|
556 |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
557 ;; Should today-only be removed in favour of timeclock-relative? - gm |
33020 | 558 (defsubst timeclock-when-to-leave (&optional today-only) |
54704 | 559 "Return a time value representing the end of today's workday. |
30781 | 560 If TODAY-ONLY is non-nil, the value returned will be relative only to |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
561 the time worked today, and not to past time." |
30781 | 562 (timeclock-seconds-to-time |
563 (- (timeclock-time-to-seconds (current-time)) | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
564 (let ((discrep (timeclock-find-discrep))) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
565 (if discrep |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
566 (if today-only |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
567 (cadr discrep) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
568 (car discrep)) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
569 0.0))))) |
30781 | 570 |
571 ;;;###autoload | |
572 (defun timeclock-when-to-leave-string (&optional show-seconds | |
573 today-only) | |
54704 | 574 "Return a string representing the end of today's workday. |
30781 | 575 This string is relative to the value of `timeclock-workday'. If |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
576 SHOW-SECONDS is non-nil, the value printed/returned will include |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
577 seconds. If TODAY-ONLY is non-nil, the value returned will be |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
578 relative only to the time worked today, and not to past time." |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
579 ;; Should today-only be removed in favour of timeclock-relative? - gm |
30781 | 580 (interactive) |
581 (let* ((then (timeclock-when-to-leave today-only)) | |
582 (string | |
583 (if show-seconds | |
584 (format-time-string "%-I:%M:%S %p" then) | |
585 (format-time-string "%-I:%M %p" then)))) | |
586 (if (interactive-p) | |
65591
a65f8ec418fc
message format spec fixes, commit # 10
Deepak Goel <deego@gnufans.org>
parents:
64085
diff
changeset
|
587 (message "%s" string) |
30781 | 588 string))) |
589 | |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
590 (defun timeclock-make-hours-explicit (old-default) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
591 "Specify all workday lengths in `timeclock-file'. |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
592 OLD-DEFAULT hours are set for every day that has no number indicated." |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
593 (interactive "P") |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
594 (if old-default (setq old-default (prefix-numeric-value old-default)) |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
595 (error "`timelog-make-hours-explicit' requires an explicit argument")) |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
596 (let ((extant-timelog (find-buffer-visiting timeclock-file)) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
597 current-date) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
598 (with-current-buffer (find-file-noselect timeclock-file t) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
599 (unwind-protect |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
600 (save-excursion |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
601 (save-restriction |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
602 (widen) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
603 (goto-char (point-min)) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
604 (while (progn (skip-chars-forward "\n") (not (eobp))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
605 ;; This is just a variant of `timeclock-moment-regexp'. |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
606 (unless (looking-at |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
607 (concat "^\\([bhioO]\\) \\([0-9]+/[0-9]+/[0-9]+\\) " |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
608 "\\([0-9]+:[0-9]+:[0-9]+\\)")) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
609 (error "Can't parse `%s'" timeclock-file)) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
610 (let ((this-date (match-string 2))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
611 (unless (or (and current-date |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
612 (string= this-date current-date)) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
613 (string= (match-string 1) "h")) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
614 (insert (format "h %s %s %s\n" (match-string 2) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
615 (match-string 3) old-default))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
616 (if (string-match "^[ih]" (match-string 1)) ; ignore logouts |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
617 (setq current-date this-date))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
618 (forward-line)) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
619 (save-buffer))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
620 (unless extant-timelog (kill-buffer (current-buffer))))))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
621 |
30781 | 622 ;;; Internal Functions: |
623 | |
624 (defvar timeclock-project-list nil) | |
625 (defvar timeclock-last-project nil) | |
626 | |
37324
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
627 (defun timeclock-completing-read (prompt alist &optional default) |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
628 "A version of `completing-read' that works on both Emacs and XEmacs. |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
629 PROMPT, ALIST and DEFAULT are used for the PROMPT, COLLECTION and DEF |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
630 arguments of `completing-read'." |
37324
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
631 (if (featurep 'xemacs) |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
632 (let ((str (completing-read prompt alist))) |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
633 (if (or (null str) (zerop (length str))) |
37324
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
634 default |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
635 str)) |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
636 (completing-read prompt alist nil nil nil nil default))) |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
637 |
30781 | 638 (defun timeclock-ask-for-project () |
639 "Ask the user for the project they are clocking into." | |
37324
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
640 (timeclock-completing-read |
65680
ed770a0a7846
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents:
65591
diff
changeset
|
641 (format "Clock into which project (default %s): " |
37324
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
642 (or timeclock-last-project |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
643 (car timeclock-project-list))) |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
644 (mapcar 'list timeclock-project-list) |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
645 (or timeclock-last-project |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
646 (car timeclock-project-list)))) |
30781 | 647 |
648 (defvar timeclock-reason-list nil) | |
649 | |
650 (defun timeclock-ask-for-reason () | |
651 "Ask the user for the reason they are clocking out." | |
37324
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
652 (timeclock-completing-read "Reason for clocking out: " |
570c667b4d1c
(timeclock-completing-read): new function.
John Wiegley <johnw@newartisans.com>
parents:
37282
diff
changeset
|
653 (mapcar 'list timeclock-reason-list))) |
30781 | 654 |
655 (defun timeclock-update-modeline () | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
656 "Update the `timeclock-mode-string' displayed in the modeline. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
657 The value of `timeclock-relative' affects the display as described in |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
658 that variable's documentation." |
30781 | 659 (interactive) |
72331
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
660 (let ((remainder |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
661 (if timeclock-use-elapsed |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
662 (timeclock-workday-elapsed) |
4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
John Wiegley <johnw@newartisans.com>
parents:
68721
diff
changeset
|
663 (timeclock-workday-remaining (not timeclock-relative)))) |
51263 | 664 (last-in (equal (car timeclock-last-event) "i"))) |
30781 | 665 (when (and (< remainder 0) |
666 (not (and timeclock-day-over | |
667 (equal timeclock-day-over | |
668 (timeclock-time-to-date | |
669 (current-time)))))) | |
670 (setq timeclock-day-over | |
671 (timeclock-time-to-date (current-time))) | |
672 (run-hooks 'timeclock-day-over-hook)) | |
673 (setq timeclock-mode-string | |
51263 | 674 (propertize |
675 (format " %c%s%c " | |
676 (if last-in ?< ?[) | |
677 (timeclock-seconds-to-string remainder nil t) | |
678 (if last-in ?> ?])) | |
679 'help-echo "timeclock: time remaining")))) | |
680 | |
681 (put 'timeclock-mode-string 'risky-local-variable t) | |
30781 | 682 |
683 (defun timeclock-log (code &optional project) | |
684 "Log the event CODE to the timeclock log, at the time of call. | |
685 If PROJECT is a string, it represents the project which the event is | |
33020 | 686 being logged for. Normally only \"in\" events specify a project." |
77671
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
687 (let ((extant-timelog (find-buffer-visiting timeclock-file))) |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
688 (with-current-buffer (find-file-noselect timeclock-file t) |
77671
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
689 (save-excursion |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
690 (save-restriction |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
691 (widen) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
692 (goto-char (point-max)) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
693 (if (not (bolp)) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
694 (insert "\n")) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
695 (let ((now (current-time))) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
696 (insert code " " |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
697 (format-time-string "%Y/%m/%d %H:%M:%S" now) |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
698 (or (and (stringp project) |
77671
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
699 (> (length project) 0) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
700 (concat " " project)) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
701 "") |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
702 "\n") |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
703 (if (equal (downcase code) "o") |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
704 (setq timeclock-last-period |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
705 (- (timeclock-time-to-seconds now) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
706 (timeclock-time-to-seconds |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
707 (cadr timeclock-last-event))) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
708 timeclock-discrepancy |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
709 (+ timeclock-discrepancy |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
710 timeclock-last-period))) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
711 (setq timeclock-last-event (list code now project))))) |
693e049fff70
(timeclock-in): Fix non-interactive workday specifications.
Richard M. Stallman <rms@gnu.org>
parents:
75346
diff
changeset
|
712 (save-buffer) |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
713 (unless extant-timelog (kill-buffer (current-buffer))))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
714 (run-hooks 'timeclock-event-hook)) |
30781 | 715 |
33020 | 716 (defvar timeclock-moment-regexp |
717 (concat "\\([bhioO]\\)\\s-+" | |
718 "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)\\s-+" | |
719 "\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\)[ \t]*" "\\([^\n]*\\)")) | |
720 | |
721 (defsubst timeclock-read-moment () | |
30781 | 722 "Read the moment under point from the timelog." |
33020 | 723 (if (looking-at timeclock-moment-regexp) |
724 (let ((code (match-string 1)) | |
725 (year (string-to-number (match-string 2))) | |
726 (mon (string-to-number (match-string 3))) | |
727 (mday (string-to-number (match-string 4))) | |
728 (hour (string-to-number (match-string 5))) | |
729 (min (string-to-number (match-string 6))) | |
730 (sec (string-to-number (match-string 7))) | |
731 (project (match-string 8))) | |
732 (list code (encode-time sec min hour mday mon year) project)))) | |
30781 | 733 |
734 (defun timeclock-last-period (&optional moment) | |
735 "Return the value of the last event period. | |
736 If the last event was a clock-in, the period will be open ended, and | |
737 growing every second. Otherwise, it is a fixed amount which has been | |
738 recorded to disk. If MOMENT is non-nil, use that as the current time. | |
739 This is only provided for coherency when used by | |
740 `timeclock-discrepancy'." | |
741 (if (equal (car timeclock-last-event) "i") | |
742 (- (timeclock-time-to-seconds (or moment (current-time))) | |
743 (timeclock-time-to-seconds | |
744 (cadr timeclock-last-event))) | |
745 timeclock-last-period)) | |
746 | |
33020 | 747 (defsubst timeclock-entry-length (entry) |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
748 "Return the length of ENTRY in seconds." |
33020 | 749 (- (timeclock-time-to-seconds (cadr entry)) |
750 (timeclock-time-to-seconds (car entry)))) | |
751 | |
752 (defsubst timeclock-entry-begin (entry) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
753 "Return the start time of ENTRY." |
33020 | 754 (car entry)) |
755 | |
756 (defsubst timeclock-entry-end (entry) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
757 "Return the end time of ENTRY." |
33020 | 758 (cadr entry)) |
759 | |
760 (defsubst timeclock-entry-project (entry) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
761 "Return the project of ENTRY." |
33020 | 762 (nth 2 entry)) |
763 | |
764 (defsubst timeclock-entry-comment (entry) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
765 "Return the comment of ENTRY." |
33020 | 766 (nth 3 entry)) |
767 | |
768 (defsubst timeclock-entry-list-length (entry-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
769 "Return the total length of ENTRY-LIST in seconds." |
33020 | 770 (let ((length 0)) |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
771 (dolist (entry entry-list) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
772 (setq length (+ length (timeclock-entry-length entry)))) |
33020 | 773 length)) |
774 | |
775 (defsubst timeclock-entry-list-begin (entry-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
776 "Return the start time of the first element of ENTRY-LIST." |
33020 | 777 (timeclock-entry-begin (car entry-list))) |
778 | |
779 (defsubst timeclock-entry-list-end (entry-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
780 "Return the end time of the last element of ENTRY-LIST." |
33020 | 781 (timeclock-entry-end (car (last entry-list)))) |
782 | |
783 (defsubst timeclock-entry-list-span (entry-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
784 "Return the total time in seconds spanned by ENTRY-LIST." |
33020 | 785 (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list)) |
786 (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list)))) | |
787 | |
788 (defsubst timeclock-entry-list-break (entry-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
789 "Return the total break time (span - length) in ENTRY-LIST." |
33020 | 790 (- (timeclock-entry-list-span entry-list) |
791 (timeclock-entry-list-length entry-list))) | |
792 | |
793 (defsubst timeclock-entry-list-projects (entry-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
794 "Return a list of all the projects in ENTRY-LIST." |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
795 (let (projects proj) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
796 (dolist (entry entry-list) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
797 (setq proj (timeclock-entry-project entry)) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
798 (if projects |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
799 (add-to-list 'projects proj) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
800 (setq projects (list proj)))) |
33020 | 801 projects)) |
802 | |
803 (defsubst timeclock-day-required (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
804 "Return the required length of DAY in seconds, default `timeclock-workday'." |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
805 (or (car day) timeclock-workday)) |
33020 | 806 |
807 (defsubst timeclock-day-length (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
808 "Return the actual length of DAY in seconds." |
33020 | 809 (timeclock-entry-list-length (cdr day))) |
810 | |
811 (defsubst timeclock-day-debt (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
812 "Return the debt (required - actual) associated with DAY, in seconds." |
33020 | 813 (- (timeclock-day-required day) |
814 (timeclock-day-length day))) | |
815 | |
816 (defsubst timeclock-day-begin (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
817 "Return the start time of DAY." |
33020 | 818 (timeclock-entry-list-begin (cdr day))) |
819 | |
820 (defsubst timeclock-day-end (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
821 "Return the end time of DAY." |
33020 | 822 (timeclock-entry-list-end (cdr day))) |
823 | |
824 (defsubst timeclock-day-span (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
825 "Return the span of DAY." |
33020 | 826 (timeclock-entry-list-span (cdr day))) |
827 | |
828 (defsubst timeclock-day-break (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
829 "Return the total break time of DAY." |
33020 | 830 (timeclock-entry-list-break (cdr day))) |
831 | |
832 (defsubst timeclock-day-projects (day) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
833 "Return a list of all the projects in DAY." |
97105
1cf204ce38b7
* calendar/timeclock.el (timeclock-day-projects): Change a `cdr' to `cddr'.
John Wiegley <johnw@newartisans.com>
parents:
94653
diff
changeset
|
834 (timeclock-entry-list-projects (cddr day))) |
33020 | 835 |
836 (defmacro timeclock-day-list-template (func) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
837 "Template for summing the result of FUNC on each element of DAY-LIST." |
33020 | 838 `(let ((length 0)) |
839 (while day-list | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
840 (setq length (+ length (,(eval func) (car day-list))) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
841 day-list (cdr day-list))) |
33020 | 842 length)) |
843 | |
844 (defun timeclock-day-list-required (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
845 "Return total required length of DAY-LIST, in seconds." |
33020 | 846 (timeclock-day-list-template 'timeclock-day-required)) |
847 | |
848 (defun timeclock-day-list-length (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
849 "Return actual length of DAY-LIST, in seconds." |
33020 | 850 (timeclock-day-list-template 'timeclock-day-length)) |
851 | |
852 (defun timeclock-day-list-debt (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
853 "Return total debt (required - actual) of DAY-LIST." |
33020 | 854 (timeclock-day-list-template 'timeclock-day-debt)) |
855 | |
856 (defsubst timeclock-day-list-begin (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
857 "Return the start time of DAY-LIST." |
33020 | 858 (timeclock-day-begin (car day-list))) |
859 | |
860 (defsubst timeclock-day-list-end (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
861 "Return the end time of DAY-LIST." |
33020 | 862 (timeclock-day-end (car (last day-list)))) |
863 | |
864 (defun timeclock-day-list-span (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
865 "Return the span of DAY-LIST." |
33020 | 866 (timeclock-day-list-template 'timeclock-day-span)) |
867 | |
868 (defun timeclock-day-list-break (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
869 "Return the total break of DAY-LIST." |
33020 | 870 (timeclock-day-list-template 'timeclock-day-break)) |
871 | |
872 (defun timeclock-day-list-projects (day-list) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
873 "Return a list of all the projects in DAY-LIST." |
33020 | 874 (let (projects) |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
875 (dolist (day day-list) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
876 (dolist (proj (timeclock-day-projects day)) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
877 (if projects |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
878 (add-to-list 'projects proj) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
879 (setq projects (list proj))))) |
33020 | 880 projects)) |
881 | |
882 (defsubst timeclock-current-debt (&optional log-data) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
883 "Return the seconds debt from LOG-DATA, default `timeclock-log-data'." |
33020 | 884 (nth 0 (or log-data (timeclock-log-data)))) |
885 | |
886 (defsubst timeclock-day-alist (&optional log-data) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
887 "Return the date alist from LOG-DATA, default `timeclock-log-data'." |
33020 | 888 (nth 1 (or log-data (timeclock-log-data)))) |
889 | |
890 (defun timeclock-day-list (&optional log-data) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
891 "Return a list of the cdrs of the date alist from LOG-DATA." |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
892 (let (day-list) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
893 (dolist (date-list (timeclock-day-alist log-data)) |
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
894 (setq day-list (cons (cdr date-list) day-list))) |
33020 | 895 day-list)) |
896 | |
897 (defsubst timeclock-project-alist (&optional log-data) | |
92669
c0e9d49498b9
Add doc-strings to all functions.
Glenn Morris <rgm@gnu.org>
parents:
92600
diff
changeset
|
898 "Return the project alist from LOG-DATA, default `timeclock-log-data'." |
33020 | 899 (nth 2 (or log-data (timeclock-log-data)))) |
900 | |
901 (defun timeclock-log-data (&optional recent-only filename) | |
902 "Return the contents of the timelog file, in a useful format. | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
903 If the optional argument RECENT-ONLY is non-nil, only show the contents |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
904 from the last point where the time debt (see below) was set. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
905 If the optional argument FILENAME is non-nil, it is used instead of |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
906 the file specified by `timeclock-file.' |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
907 |
33020 | 908 A timelog contains data in the form of a single entry per line. |
909 Each entry has the form: | |
910 | |
911 CODE YYYY/MM/DD HH:MM:SS [COMMENT] | |
912 | |
913 CODE is one of: b, h, i, o or O. COMMENT is optional when the code is | |
914 i, o or O. The meanings of the codes are: | |
915 | |
916 b Set the current time balance, or \"time debt\". Useful when | |
917 archiving old log data, when a debt must be carried forward. | |
918 The COMMENT here is the number of seconds of debt. | |
919 | |
920 h Set the required working time for the given day. This must | |
921 be the first entry for that day. The COMMENT in this case is | |
54704 | 922 the number of hours in this workday. Floating point amounts |
923 are allowed. | |
33020 | 924 |
925 i Clock in. The COMMENT in this case should be the name of the | |
926 project worked on. | |
927 | |
928 o Clock out. COMMENT is unnecessary, but can be used to provide | |
929 a description of how the period went, for example. | |
930 | |
931 O Final clock out. Whatever project was being worked on, it is | |
932 now finished. Useful for creating summary reports. | |
933 | |
934 When this function is called, it will return a data structure with the | |
935 following format: | |
936 | |
937 (DEBT ENTRIES-BY-DAY ENTRIES-BY-PROJECT) | |
938 | |
939 DEBT is a floating point number representing the number of seconds | |
940 \"owed\" before any work was done. For a new file (one without a 'b' | |
941 entry), this is always zero. | |
942 | |
943 The two entries lists have similar formats. They are both alists, | |
944 where the CAR is the index, and the CDR is a list of time entries. | |
945 For ENTRIES-BY-DAY, the CAR is a textual date string, of the form | |
946 YYYY/MM/DD. For ENTRIES-BY-PROJECT, it is the name of the project | |
947 worked on, or t for the default project. | |
948 | |
949 The CDR for ENTRIES-BY-DAY is slightly different than for | |
950 ENTRIES-BY-PROJECT. It has the following form: | |
951 | |
952 (DAY-LENGTH TIME-ENTRIES...) | |
953 | |
954 For ENTRIES-BY-PROJECT, there is no DAY-LENGTH member. It is simply a | |
955 list of TIME-ENTRIES. Note that if DAY-LENGTH is nil, it means | |
956 whatever is the default should be used. | |
957 | |
958 A TIME-ENTRY is a recorded time interval. It has the following format | |
959 \(although generally one does not have to manipulate these entries | |
960 directly; see below): | |
961 | |
962 (BEGIN-TIME END-TIME PROJECT [COMMENT] [FINAL-P]) | |
963 | |
964 Anyway, suffice it to say there are a lot of structures. Typically | |
965 the user is expected to manipulate to the day(s) or project(s) that he | |
966 or she wants, at which point the following helper functions may be | |
967 used: | |
968 | |
969 timeclock-day-required | |
970 timeclock-day-length | |
971 timeclock-day-debt | |
972 timeclock-day-begin | |
973 timeclock-day-end | |
974 timeclock-day-span | |
975 timeclock-day-break | |
976 timeclock-day-projects | |
977 | |
978 timeclock-day-list-required | |
979 timeclock-day-list-length | |
980 timeclock-day-list-debt | |
981 timeclock-day-list-begin | |
982 timeclock-day-list-end | |
983 timeclock-day-list-span | |
984 timeclock-day-list-break | |
985 timeclock-day-list-projects | |
986 | |
987 timeclock-entry-length | |
988 timeclock-entry-begin | |
989 timeclock-entry-end | |
990 timeclock-entry-project | |
991 timeclock-entry-comment | |
992 | |
993 timeclock-entry-list-length | |
994 timeclock-entry-list-begin | |
995 timeclock-entry-list-end | |
996 timeclock-entry-list-span | |
997 timeclock-entry-list-break | |
998 timeclock-entry-list-projects | |
999 | |
1000 A few comments should make the use of the above functions obvious: | |
1001 | |
1002 `required' is the amount of time that must be spent during a day, or | |
1003 sequence of days, in order to have no debt. | |
1004 | |
1005 `length' is the actual amount of time that was spent. | |
1006 | |
1007 `debt' is the difference between required time and length. A | |
1008 negative debt signifies overtime. | |
1009 | |
1010 `begin' is the earliest moment at which work began. | |
1011 | |
1012 `end' is the final moment work was done. | |
1013 | |
1014 `span' is the difference between begin and end. | |
1015 | |
1016 `break' is the difference between span and length. | |
1017 | |
1018 `project' is the project that was worked on, and `projects' is a | |
1019 list of all the projects that were worked on during a given period. | |
1020 | |
1021 `comment', where it applies, could mean anything. | |
1022 | |
1023 There are a few more functions available, for locating day and entry | |
1024 lists: | |
1025 | |
1026 timeclock-day-alist LOG-DATA | |
1027 timeclock-project-alist LOG-DATA | |
1028 timeclock-current-debt LOG-DATA | |
1029 | |
1030 See the documentation for the given function if more info is needed." | |
1031 (let* ((log-data (list 0.0 nil nil)) | |
1032 (now (current-time)) | |
1033 (todays-date (timeclock-time-to-date now)) | |
1034 last-date-limited last-date-seconds last-date | |
36851 | 1035 (line 0) last beg day entry event) |
33020 | 1036 (with-temp-buffer |
1037 (insert-file-contents (or filename timeclock-file)) | |
1038 (when recent-only | |
1039 (goto-char (point-max)) | |
1040 (unless (re-search-backward "^b\\s-+" nil t) | |
1041 (goto-char (point-min)))) | |
1042 (while (or (setq event (timeclock-read-moment)) | |
1043 (and beg (not last) | |
1044 (setq last t event (list "o" now)))) | |
1045 (setq line (1+ line)) | |
1046 (cond ((equal (car event) "b") | |
1047 (setcar log-data (string-to-number (nth 2 event)))) | |
1048 ((equal (car event) "h") | |
1049 (setq last-date-limited (timeclock-time-to-date (cadr event)) | |
1050 last-date-seconds (* (string-to-number (nth 2 event)) | |
1051 3600.0))) | |
1052 ((equal (car event) "i") | |
1053 (if beg | |
1054 (error "Error in format of timelog file, line %d" line) | |
1055 (setq beg t)) | |
1056 (setq entry (list (cadr event) nil | |
1057 (and (> (length (nth 2 event)) 0) | |
1058 (nth 2 event)))) | |
1059 (let ((date (timeclock-time-to-date (cadr event)))) | |
1060 (if (and last-date | |
1061 (not (equal date last-date))) | |
36851 | 1062 (progn |
1063 (setcar (cdr log-data) | |
1064 (cons (cons last-date day) | |
1065 (cadr log-data))) | |
1066 (setq day (list (and last-date-limited | |
1067 last-date-seconds)))) | |
1068 (unless day | |
1069 (setq day (list (and last-date-limited | |
1070 last-date-seconds))))) | |
33020 | 1071 (setq last-date date |
1072 last-date-limited nil))) | |
1073 ((equal (downcase (car event)) "o") | |
1074 (if (not beg) | |
1075 (error "Error in format of timelog file, line %d" line) | |
1076 (setq beg nil)) | |
1077 (setcar (cdr entry) (cadr event)) | |
1078 (let ((desc (and (> (length (nth 2 event)) 0) | |
1079 (nth 2 event)))) | |
1080 (if desc | |
1081 (nconc entry (list (nth 2 event)))) | |
1082 (if (equal (car event) "O") | |
1083 (nconc entry (if desc | |
1084 (list t) | |
1085 (list nil t)))) | |
1086 (nconc day (list entry)) | |
1087 (setq desc (nth 2 entry)) | |
1088 (let ((proj (assoc desc (nth 2 log-data)))) | |
36851 | 1089 (if (null proj) |
33020 | 1090 (setcar (cddr log-data) |
1091 (cons (cons desc (list entry)) | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1092 (nth 2 log-data))) |
33020 | 1093 (nconc (cdr proj) (list entry))))))) |
1094 (forward-line)) | |
1095 (if day | |
1096 (setcar (cdr log-data) | |
1097 (cons (cons last-date day) | |
1098 (cadr log-data)))) | |
1099 log-data))) | |
1100 | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1101 (defun timeclock-find-discrep () |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1102 "Calculate time discrepancies, in seconds. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1103 The result is a three element list, containing the total time |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1104 discrepancy, today's discrepancy, and the time worked today." |
33020 | 1105 ;; This is not implemented in terms of the functions above, because |
1106 ;; it's a bit wasteful to read all of that data in, just to throw | |
1107 ;; away more than 90% of the information afterwards. | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1108 ;; |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1109 ;; If it were implemented using those functions, it would look |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1110 ;; something like this: |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1111 ;; (let ((days (timeclock-day-alist (timeclock-log-data))) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1112 ;; (total 0.0)) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1113 ;; (while days |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1114 ;; (setq total (+ total (- (timeclock-day-length (cdar days)) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1115 ;; (timeclock-day-required (cdar days)))) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1116 ;; days (cdr days))) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1117 ;; total) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1118 (let* ((now (current-time)) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1119 (todays-date (timeclock-time-to-date now)) |
37648
9baaf32f355a
(timeclock-find-discrep): Initialize `elapsed' to 0.
John Wiegley <johnw@newartisans.com>
parents:
37625
diff
changeset
|
1120 (first t) (accum 0) (elapsed 0) |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1121 event beg last-date avg |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1122 last-date-limited last-date-seconds) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1123 (unless timeclock-discrepancy |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1124 (when (file-readable-p timeclock-file) |
36851 | 1125 (setq timeclock-project-list nil |
1126 timeclock-last-project nil | |
1127 timeclock-reason-list nil | |
1128 timeclock-elapsed 0) | |
1129 (with-temp-buffer | |
1130 (insert-file-contents timeclock-file) | |
1131 (goto-char (point-max)) | |
1132 (unless (re-search-backward "^b\\s-+" nil t) | |
1133 (goto-char (point-min))) | |
1134 (while (setq event (timeclock-read-moment)) | |
1135 (cond ((equal (car event) "b") | |
1136 (setq accum (string-to-number (nth 2 event)))) | |
1137 ((equal (car event) "h") | |
1138 (setq last-date-limited | |
1139 (timeclock-time-to-date (cadr event)) | |
1140 last-date-seconds | |
1141 (* (string-to-number (nth 2 event)) 3600.0))) | |
1142 ((equal (car event) "i") | |
1143 (when (and (nth 2 event) | |
1144 (> (length (nth 2 event)) 0)) | |
1145 (add-to-list 'timeclock-project-list (nth 2 event)) | |
1146 (setq timeclock-last-project (nth 2 event))) | |
1147 (let ((date (timeclock-time-to-date (cadr event)))) | |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1148 (if (if last-date |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1149 (not (equal date last-date)) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1150 first) |
36851 | 1151 (setq first nil |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1152 accum (- accum (if last-date-limited |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1153 last-date-seconds |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1154 timeclock-workday)))) |
36851 | 1155 (setq last-date date |
1156 last-date-limited nil) | |
1157 (if beg | |
1158 (error "Error in format of timelog file!") | |
1159 (setq beg (timeclock-time-to-seconds (cadr event)))))) | |
1160 ((equal (downcase (car event)) "o") | |
1161 (if (and (nth 2 event) | |
30781 | 1162 (> (length (nth 2 event)) 0)) |
36851 | 1163 (add-to-list 'timeclock-reason-list (nth 2 event))) |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1164 (if (not beg) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1165 (error "Error in format of timelog file!") |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1166 (setq timeclock-last-period |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1167 (- (timeclock-time-to-seconds (cadr event)) beg) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1168 accum (+ timeclock-last-period accum) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1169 beg nil)) |
36851 | 1170 (if (equal last-date todays-date) |
1171 (setq timeclock-elapsed | |
1172 (+ timeclock-last-period timeclock-elapsed))))) | |
1173 (setq timeclock-last-event event | |
1174 timeclock-last-event-workday | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1175 (if (equal (timeclock-time-to-date now) last-date-limited) |
36851 | 1176 last-date-seconds |
1177 timeclock-workday)) | |
1178 (forward-line)) | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1179 (setq timeclock-discrepancy accum)))) |
37650
061ef023b0af
(timeclock-find-discrep): Set `timeclock-last-event-workday' if it's
John Wiegley <johnw@newartisans.com>
parents:
37648
diff
changeset
|
1180 (unless timeclock-last-event-workday |
061ef023b0af
(timeclock-find-discrep): Set `timeclock-last-event-workday' if it's
John Wiegley <johnw@newartisans.com>
parents:
37648
diff
changeset
|
1181 (setq timeclock-last-event-workday timeclock-workday)) |
51263 | 1182 (setq accum (or timeclock-discrepancy 0) |
37652
7fb1a7ce4a40
One more variable coming up nil on the first time around, needing
John Wiegley <johnw@newartisans.com>
parents:
37651
diff
changeset
|
1183 elapsed (or timeclock-elapsed elapsed)) |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1184 (if timeclock-last-event |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1185 (if (equal (car timeclock-last-event) "i") |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1186 (let ((last-period (timeclock-last-period now))) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1187 (setq accum (+ accum last-period) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1188 elapsed (+ elapsed last-period))) |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1189 (if (not (equal (timeclock-time-to-date |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1190 (cadr timeclock-last-event)) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1191 (timeclock-time-to-date now))) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1192 (setq accum (- accum timeclock-last-event-workday))))) |
37625
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1193 (list accum (- elapsed timeclock-last-event-workday) |
53351976477e
(timeclock-workday-remaining): Changed logic for determining how much
John Wiegley <johnw@newartisans.com>
parents:
37437
diff
changeset
|
1194 elapsed))) |
36851 | 1195 |
1196 ;;; A reporting function that uses timeclock-log-data | |
1197 | |
1198 (defun timeclock-day-base (&optional time) | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1199 "Given a time within a day, return 0:0:0 within that day. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1200 If optional argument TIME is non-nil, use that instead of the current time." |
36851 | 1201 (let ((decoded (decode-time (or time (current-time))))) |
1202 (setcar (nthcdr 0 decoded) 0) | |
1203 (setcar (nthcdr 1 decoded) 0) | |
1204 (setcar (nthcdr 2 decoded) 0) | |
1205 (apply 'encode-time decoded))) | |
1206 | |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1207 (defun timeclock-mean (l) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1208 "Compute the arithmetic mean of the values in the list L." |
36851 | 1209 (let ((total 0) |
1210 (count 0)) | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1211 (dolist (thisl l) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1212 (setq total (+ total thisl) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1213 count (1+ count))) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1214 (if (zerop count) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1215 0 |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1216 (/ total count)))) |
36851 | 1217 |
1218 (defun timeclock-generate-report (&optional html-p) | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1219 "Generate a summary report based on the current timelog file. |
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1220 By default, the report is in plain text, but if the optional argument |
54704 | 1221 HTML-P is non-nil, HTML markup is added." |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1222 (interactive "P") |
36851 | 1223 (let ((log (timeclock-log-data)) |
1224 (today (timeclock-day-base))) | |
1225 (if html-p (insert "<p>")) | |
1226 (insert "Currently ") | |
1227 (let ((project (nth 2 timeclock-last-event)) | |
1228 (begin (nth 1 timeclock-last-event)) | |
1229 done) | |
1230 (if (timeclock-currently-in-p) | |
1231 (insert "IN") | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1232 (if (zerop (length project)) |
36851 | 1233 (progn (insert "Done Working Today") |
1234 (setq done t)) | |
1235 (insert "OUT"))) | |
1236 (unless done | |
1237 (insert " since " (format-time-string "%Y/%m/%d %-I:%M %p" begin)) | |
1238 (if html-p | |
1239 (insert "<br>\n<b>") | |
1240 (insert "\n*")) | |
1241 (if (timeclock-currently-in-p) | |
1242 (insert "Working on ")) | |
1243 (if html-p | |
37282
d30baa39a3b4
(timeclock-generate-report): Added a missing insert of the project
John Wiegley <johnw@newartisans.com>
parents:
36854
diff
changeset
|
1244 (insert project "</b><br>\n") |
36851 | 1245 (insert project "*\n")) |
1246 (let ((proj-data (cdr (assoc project (timeclock-project-alist log)))) | |
1247 (two-weeks-ago (timeclock-seconds-to-time | |
1248 (- (timeclock-time-to-seconds today) | |
1249 (* 2 7 24 60 60)))) | |
1250 two-week-len today-len) | |
1251 (while proj-data | |
55207
a3244da8e396
(timeclock-time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54704
diff
changeset
|
1252 (if (not (time-less-p |
36851 | 1253 (timeclock-entry-begin (car proj-data)) today)) |
1254 (setq today-len (timeclock-entry-list-length proj-data) | |
1255 proj-data nil) | |
1256 (if (and (null two-week-len) | |
55207
a3244da8e396
(timeclock-time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54704
diff
changeset
|
1257 (not (time-less-p |
36851 | 1258 (timeclock-entry-begin (car proj-data)) |
1259 two-weeks-ago))) | |
1260 (setq two-week-len (timeclock-entry-list-length proj-data))) | |
1261 (setq proj-data (cdr proj-data)))) | |
1262 (if (null two-week-len) | |
1263 (setq two-week-len today-len)) | |
1264 (if html-p (insert "<p>")) | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1265 (if today-len |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1266 (insert "\nTime spent on this task today: " |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1267 (timeclock-seconds-to-string today-len) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1268 ". In the last two weeks: " |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1269 (timeclock-seconds-to-string two-week-len)) |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1270 (if two-week-len |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1271 (insert "\nTime spent on this task in the last two weeks: " |
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1272 (timeclock-seconds-to-string two-week-len)))) |
36851 | 1273 (if html-p (insert "<br>")) |
1274 (insert "\n" | |
1275 (timeclock-seconds-to-string (timeclock-workday-elapsed)) | |
1276 " worked today, " | |
1277 (timeclock-seconds-to-string (timeclock-workday-remaining)) | |
1278 " remaining, done at " | |
1279 (timeclock-when-to-leave-string) "\n"))) | |
1280 (if html-p (insert "<p>")) | |
1281 (insert "\nThere have been " | |
1282 (number-to-string | |
1283 (length (timeclock-day-alist log))) | |
1284 " days of activity, starting " | |
1285 (caar (last (timeclock-day-alist log)))) | |
1286 (if html-p (insert "</p>")) | |
1287 (when html-p | |
1288 (insert "<p> | |
1289 <table> | |
1290 <td width=\"25\"><br></td><td> | |
1291 <table border=1 cellpadding=3> | |
1292 <tr><th><i>Statistics</i></th> | |
1293 <th>Entire</th> | |
1294 <th>-30 days</th> | |
1295 <th>-3 mons</th> | |
1296 <th>-6 mons</th> | |
1297 <th>-1 year</th> | |
1298 </tr>") | |
1299 (let* ((day-list (timeclock-day-list)) | |
1300 (thirty-days-ago (timeclock-seconds-to-time | |
1301 (- (timeclock-time-to-seconds today) | |
1302 (* 30 24 60 60)))) | |
1303 (three-months-ago (timeclock-seconds-to-time | |
1304 (- (timeclock-time-to-seconds today) | |
1305 (* 90 24 60 60)))) | |
1306 (six-months-ago (timeclock-seconds-to-time | |
1307 (- (timeclock-time-to-seconds today) | |
1308 (* 180 24 60 60)))) | |
1309 (one-year-ago (timeclock-seconds-to-time | |
1310 (- (timeclock-time-to-seconds today) | |
1311 (* 365 24 60 60)))) | |
1312 (time-in (vector (list t) (list t) (list t) (list t) (list t))) | |
1313 (time-out (vector (list t) (list t) (list t) (list t) (list t))) | |
1314 (breaks (vector (list t) (list t) (list t) (list t) (list t))) | |
1315 (workday (vector (list t) (list t) (list t) (list t) (list t))) | |
1316 (lengths (vector '(0 0) thirty-days-ago three-months-ago | |
1317 six-months-ago one-year-ago))) | |
1318 ;; collect statistics from complete timelog | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1319 (dolist (day day-list) |
36851 | 1320 (let ((i 0) (l 5)) |
1321 (while (< i l) | |
55207
a3244da8e396
(timeclock-time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54704
diff
changeset
|
1322 (unless (time-less-p |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1323 (timeclock-day-begin day) |
36851 | 1324 (aref lengths i)) |
1325 (let ((base (timeclock-time-to-seconds | |
1326 (timeclock-day-base | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1327 (timeclock-day-begin day))))) |
36851 | 1328 (nconc (aref time-in i) |
1329 (list (- (timeclock-time-to-seconds | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1330 (timeclock-day-begin day)) |
36851 | 1331 base))) |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1332 (let ((span (timeclock-day-span day)) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1333 (len (timeclock-day-length day)) |
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1334 (req (timeclock-day-required day))) |
36851 | 1335 ;; If the day's actual work length is less than |
1336 ;; 70% of its span, then likely the exit time | |
1337 ;; and break amount are not worthwhile adding to | |
1338 ;; the statistic | |
1339 (when (and (> span 0) | |
1340 (> (/ (float len) (float span)) 0.70)) | |
1341 (nconc (aref time-out i) | |
1342 (list (- (timeclock-time-to-seconds | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1343 (timeclock-day-end day)) |
36851 | 1344 base))) |
1345 (nconc (aref breaks i) (list (- span len)))) | |
1346 (if req | |
1347 (setq len (+ len (- timeclock-workday req)))) | |
1348 (nconc (aref workday i) (list len))))) | |
92957
c3b09ba22de9
(timeclock-time-to-seconds, timeclock-log-data): Use nth.
Glenn Morris <rgm@gnu.org>
parents:
92669
diff
changeset
|
1349 (setq i (1+ i))))) |
36851 | 1350 ;; average statistics |
1351 (let ((i 0) (l 5)) | |
1352 (while (< i l) | |
77900
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1353 (aset time-in i (timeclock-mean (cdr (aref time-in i)))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1354 (aset time-out i (timeclock-mean (cdr (aref time-out i)))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1355 (aset breaks i (timeclock-mean (cdr (aref breaks i)))) |
2e526dc9c6b6
Update version number.
Chong Yidong <cyd@stupidchicken.com>
parents:
77671
diff
changeset
|
1356 (aset workday i (timeclock-mean (cdr (aref workday i)))) |
36851 | 1357 (setq i (1+ i)))) |
1358 ;; Output the HTML table | |
1359 (insert "<tr>\n") | |
1360 (insert "<td align=\"center\">Time in</td>\n") | |
1361 (let ((i 0) (l 5)) | |
1362 (while (< i l) | |
1363 (insert "<td align=\"right\">" | |
1364 (timeclock-seconds-to-string (aref time-in i)) | |
1365 "</td>\n") | |
1366 (setq i (1+ i)))) | |
1367 (insert "</tr>\n") | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1368 |
36851 | 1369 (insert "<tr>\n") |
1370 (insert "<td align=\"center\">Time out</td>\n") | |
1371 (let ((i 0) (l 5)) | |
1372 (while (< i l) | |
1373 (insert "<td align=\"right\">" | |
1374 (timeclock-seconds-to-string (aref time-out i)) | |
1375 "</td>\n") | |
1376 (setq i (1+ i)))) | |
1377 (insert "</tr>\n") | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1378 |
36851 | 1379 (insert "<tr>\n") |
1380 (insert "<td align=\"center\">Break</td>\n") | |
1381 (let ((i 0) (l 5)) | |
1382 (while (< i l) | |
1383 (insert "<td align=\"right\">" | |
1384 (timeclock-seconds-to-string (aref breaks i)) | |
1385 "</td>\n") | |
1386 (setq i (1+ i)))) | |
1387 (insert "</tr>\n") | |
37437
ed485de91fcf
(timeclock-day-required): If the time required for a particular day is
John Wiegley <johnw@newartisans.com>
parents:
37324
diff
changeset
|
1388 |
36851 | 1389 (insert "<tr>\n") |
1390 (insert "<td align=\"center\">Workday</td>\n") | |
1391 (let ((i 0) (l 5)) | |
1392 (while (< i l) | |
1393 (insert "<td align=\"right\">" | |
1394 (timeclock-seconds-to-string (aref workday i)) | |
1395 "</td>\n") | |
1396 (setq i (1+ i)))) | |
1397 (insert "</tr>\n")) | |
1398 (insert "<tfoot> | |
1399 <td colspan=\"6\" align=\"center\"> | |
1400 <i>These are approximate figures</i></td> | |
1401 </tfoot> | |
1402 </table> | |
1403 </td></table>"))))) | |
1404 | |
1405 ;;; A helpful little function | |
1406 | |
1407 (defun timeclock-visit-timelog () | |
51861
91e4e5fd11de
(timeclock-use-display-time, timeclock-day-over-hook)
Glenn Morris <rgm@gnu.org>
parents:
51549
diff
changeset
|
1408 "Open the file named by `timeclock-file' in another window." |
36851 | 1409 (interactive) |
1410 (find-file-other-window timeclock-file)) | |
30781 | 1411 |
1412 (provide 'timeclock) | |
1413 | |
1414 (run-hooks 'timeclock-load-hook) | |
1415 | |
1416 ;; make sure we know the list of reasons, projects, and have computed | |
1417 ;; the last event and current discrepancy. | |
1418 (if (file-readable-p timeclock-file) | |
1419 (timeclock-reread-log)) | |
1420 | |
92600 | 1421 ;; arch-tag: a0be3377-deb6-44ec-b9a2-a7be28436a40 |
30781 | 1422 ;;; timeclock.el ends here |