Mercurial > emacs
comparison lisp/calendar/timeclock.el @ 72331:4e0c58818901
(timeclock-use-elapsed): Added a new variable, which causes timeclock
to report elapsed time worked, instead of just work remaining.
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Wed, 09 Aug 2006 11:51:57 +0000 |
parents | 8daf7d9a0771 |
children | 7a3f13e2dd57 7f3f771c85fa |
comparison
equal
deleted
inserted
replaced
72330:33b020cae519 | 72331:4e0c58818901 |
---|---|
93 "*The length of a work period." | 93 "*The length of a work period." |
94 :type 'integer | 94 :type 'integer |
95 :group 'timeclock) | 95 :group 'timeclock) |
96 | 96 |
97 (defcustom timeclock-relative t | 97 (defcustom timeclock-relative t |
98 "*Whether to maken reported time relative to `timeclock-workday'. | 98 "*Whether to make reported time relative to `timeclock-workday'. |
99 For example, if the length of a normal workday is eight hours, and you | 99 For example, if the length of a normal workday is eight hours, and you |
100 work four hours on Monday, then the amount of time \"remaining\" on | 100 work four hours on Monday, then the amount of time \"remaining\" on |
101 Tuesday is twelve hours -- relative to an averaged work period of | 101 Tuesday is twelve hours -- relative to an averaged work period of |
102 eight hours -- or eight hours, non-relative. So relative time takes | 102 eight hours -- or eight hours, non-relative. So relative time takes |
103 into account any discrepancy of time under-worked or over-worked on | 103 into account any discrepancy of time under-worked or over-worked on |
249 (defvar timeclock-elapsed nil | 249 (defvar timeclock-elapsed nil |
250 "A variable containing the time elapsed for complete periods today. | 250 "A variable containing the time elapsed for complete periods today. |
251 This value is not accurate enough to be useful by itself. Rather, | 251 This value is not accurate enough to be useful by itself. Rather, |
252 call `timeclock-workday-elapsed', to determine how much time has been | 252 call `timeclock-workday-elapsed', to determine how much time has been |
253 worked so far today. Also, if `timeclock-relative' is nil, this value | 253 worked so far today. Also, if `timeclock-relative' is nil, this value |
254 will be the same as `timeclock-discrepancy'.") ; ? gm | 254 will be the same as `timeclock-discrepancy'.") |
255 | |
256 (defvar timeclock-use-elapsed nil | |
257 "Non-nil if the modeline should display time elapsed, not remaining.") | |
255 | 258 |
256 (defvar timeclock-last-period nil | 259 (defvar timeclock-last-period nil |
257 "Integer representing the number of seconds in the last period. | 260 "Integer representing the number of seconds in the last period. |
258 Note that you shouldn't access this value, but instead should use the | 261 Note that you shouldn't access this value, but instead should use the |
259 function `timeclock-last-period'.") | 262 function `timeclock-last-period'.") |
422 "Report the overall timeclock status at the present moment. | 425 "Report the overall timeclock status at the present moment. |
423 If SHOW-SECONDS is non-nil, display second resolution. | 426 If SHOW-SECONDS is non-nil, display second resolution. |
424 If TODAY-ONLY is non-nil, the display will be relative only to time | 427 If TODAY-ONLY is non-nil, the display will be relative only to time |
425 worked today, ignoring the time worked on previous days." | 428 worked today, ignoring the time worked on previous days." |
426 (interactive "P") | 429 (interactive "P") |
427 (let ((remainder (timeclock-workday-remaining)) ; today-only? | 430 (let ((remainder (timeclock-workday-remaining |
431 (or today-only | |
432 (not timeclock-relative)))) | |
428 (last-in (equal (car timeclock-last-event) "i")) | 433 (last-in (equal (car timeclock-last-event) "i")) |
429 status) | 434 status) |
430 (setq status | 435 (setq status |
431 (format "Currently %s since %s (%s), %s %s, leave at %s" | 436 (format "Currently %s since %s (%s), %s %s, leave at %s" |
432 (if last-in "IN" "OUT") | 437 (if last-in "IN" "OUT") |
617 (defun timeclock-update-modeline () | 622 (defun timeclock-update-modeline () |
618 "Update the `timeclock-mode-string' displayed in the modeline. | 623 "Update the `timeclock-mode-string' displayed in the modeline. |
619 The value of `timeclock-relative' affects the display as described in | 624 The value of `timeclock-relative' affects the display as described in |
620 that variable's documentation." | 625 that variable's documentation." |
621 (interactive) | 626 (interactive) |
622 (let ((remainder (timeclock-workday-remaining (not timeclock-relative))) | 627 (let ((remainder |
628 (if timeclock-use-elapsed | |
629 (timeclock-workday-elapsed) | |
630 (timeclock-workday-remaining (not timeclock-relative)))) | |
623 (last-in (equal (car timeclock-last-event) "i"))) | 631 (last-in (equal (car timeclock-last-event) "i"))) |
624 (when (and (< remainder 0) | 632 (when (and (< remainder 0) |
625 (not (and timeclock-day-over | 633 (not (and timeclock-day-over |
626 (equal timeclock-day-over | 634 (equal timeclock-day-over |
627 (timeclock-time-to-date | 635 (timeclock-time-to-date |