diff options
| author | John Wiegley | 2001-05-08 21:12:41 +0000 |
|---|---|---|
| committer | John Wiegley | 2001-05-08 21:12:41 +0000 |
| commit | 1c8c9fb88e1f8d75feb70b57c0e8c7fc5615b335 (patch) | |
| tree | a943d69553357c8d15d73e576b1b7ea8cfcc44e1 | |
| parent | d1f08d85033a1e9ef07ac7f2887f64bff27834f4 (diff) | |
| download | emacs-1c8c9fb88e1f8d75feb70b57c0e8c7fc5615b335.tar.gz emacs-1c8c9fb88e1f8d75feb70b57c0e8c7fc5615b335.zip | |
(timeclock-workday-remaining): Changed logic for determining how much
time is remaining.
(timeclock-workday-elapsed): Don't accept a "relative" argument for
the current day's elapsed time. What could that have meant?
(timeclock-workday-elapsed-string): No "relative" argument anymore.
(timeclock-when-to-leave): Changed logic, similarly to what was done
for `timeclock-workday-remaining'.
(timeclock-find-discrep): Removed "today-only" argument, which had no
meaning. Fixed some more math problems. The function now returns a
three member list: (TOTAL-TIME-DISCREPANCY TODAYS-TIME-DISCREPANCY
TODAYS-ELAPSED-TIME).
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/calendar/timeclock.el | 84 |
2 files changed, 58 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f3c8755b3a8..413f767b58b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2001-05-08 John Wiegley <johnw@gnu.org> | ||
| 2 | |||
| 3 | * calendar/timeclock.el (timeclock-workday-remaining): Changed | ||
| 4 | logic for determining how much time is remaining. | ||
| 5 | (timeclock-workday-elapsed): Don't accept a "relative" argument | ||
| 6 | for the current day's elapsed time. What could that have meant? | ||
| 7 | (timeclock-workday-elapsed-string): No "relative" argument | ||
| 8 | anymore. | ||
| 9 | (timeclock-when-to-leave): Changed logic, similarly to what was | ||
| 10 | done for `timeclock-workday-remaining'. | ||
| 11 | (timeclock-find-discrep): Removed "today-only" argument, which had | ||
| 12 | no meaning. Fixed some more math problems. The function now | ||
| 13 | returns a three member list: (TOTAL-TIME-DISCREPANCY | ||
| 14 | TODAYS-TIME-DISCREPANCY TODAYS-ELAPSED-TIME). | ||
| 15 | |||
| 1 | 2001-05-08 Eli Zaretskii <eliz@is.elta.co.il> | 16 | 2001-05-08 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 17 | ||
| 3 | * w32-fns.el (convert-standard-filename): Start replacing slashes | 18 | * w32-fns.el (convert-standard-filename): Start replacing slashes |
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index bb4976a1ca2..7592d63427c 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: John Wiegley <johnw@gnu.org> | 5 | ;; Author: John Wiegley <johnw@gnu.org> |
| 6 | ;; Created: 25 Mar 1999 | 6 | ;; Created: 25 Mar 1999 |
| 7 | ;; Version: 2.4 | 7 | ;; Version: 2.5 |
| 8 | ;; Keywords: calendar data | 8 | ;; Keywords: calendar data |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -461,8 +461,12 @@ The amount returned is relative to the value of `timeclock-workday'. | |||
| 461 | If TODAY-ONLY is non-nil, the value returned will be relative only to | 461 | If TODAY-ONLY is non-nil, the value returned will be relative only to |
| 462 | the time worked today, and not to past time. This argument only makes | 462 | the time worked today, and not to past time. This argument only makes |
| 463 | a difference if `timeclock-relative' is non-nil." | 463 | a difference if `timeclock-relative' is non-nil." |
| 464 | (let ((discrep (timeclock-find-discrep today-only))) | 464 | (let ((discrep (timeclock-find-discrep))) |
| 465 | (or (and discrep (- discrep)) 0.0))) | 465 | (if discrep |
| 466 | (if today-only | ||
| 467 | (- (cadr discrep)) | ||
| 468 | (- (car discrep))) | ||
| 469 | 0.0))) | ||
| 466 | 470 | ||
| 467 | (defsubst timeclock-currently-in-p () | 471 | (defsubst timeclock-currently-in-p () |
| 468 | "Return non-nil if the user is currently clocked in." | 472 | "Return non-nil if the user is currently clocked in." |
| @@ -484,24 +488,24 @@ See `timeclock-relative' for more information about the meaning of | |||
| 484 | (message string) | 488 | (message string) |
| 485 | string))) | 489 | string))) |
| 486 | 490 | ||
| 487 | (defsubst timeclock-workday-elapsed (&optional relative) | 491 | (defsubst timeclock-workday-elapsed () |
| 488 | "Return a the number of seconds worked so far today. | 492 | "Return a the number of seconds worked so far today. |
| 489 | If RELATIVE is non-nil, the amount returned will be relative to past | 493 | If RELATIVE is non-nil, the amount returned will be relative to past |
| 490 | time worked. The default is to return only the time that has elapsed | 494 | time worked. The default is to return only the time that has elapsed |
| 491 | so far today." | 495 | so far today." |
| 492 | (+ timeclock-workday | 496 | (let ((discrep (timeclock-find-discrep))) |
| 493 | (timeclock-find-discrep (not relative)))) | 497 | (if discrep |
| 498 | (nth 2 discrep) | ||
| 499 | 0.0))) | ||
| 494 | 500 | ||
| 495 | ;;;###autoload | 501 | ;;;###autoload |
| 496 | (defun timeclock-workday-elapsed-string (&optional show-seconds | 502 | (defun timeclock-workday-elapsed-string (&optional show-seconds) |
| 497 | relative) | ||
| 498 | "Return a string representing the amount of time worked today. | 503 | "Return a string representing the amount of time worked today. |
| 499 | Display seconds resolution if SHOW-SECONDS is non-nil. If RELATIVE is | 504 | Display seconds resolution if SHOW-SECONDS is non-nil. If RELATIVE is |
| 500 | non-nil, the amount returned will be relative to past time worked." | 505 | non-nil, the amount returned will be relative to past time worked." |
| 501 | (interactive) | 506 | (interactive) |
| 502 | (let ((string (timeclock-seconds-to-string | 507 | (let ((string (timeclock-seconds-to-string (timeclock-workday-elapsed) |
| 503 | (timeclock-workday-elapsed relative) | 508 | show-seconds))) |
| 504 | show-seconds))) | ||
| 505 | (if (interactive-p) | 509 | (if (interactive-p) |
| 506 | (message string) | 510 | (message string) |
| 507 | string))) | 511 | string))) |
| @@ -513,7 +517,12 @@ the time worked today, and not to past time. This argument only makes | |||
| 513 | a difference if `timeclock-relative' is non-nil." | 517 | a difference if `timeclock-relative' is non-nil." |
| 514 | (timeclock-seconds-to-time | 518 | (timeclock-seconds-to-time |
| 515 | (- (timeclock-time-to-seconds (current-time)) | 519 | (- (timeclock-time-to-seconds (current-time)) |
| 516 | (timeclock-find-discrep today-only)))) | 520 | (let ((discrep (timeclock-find-discrep))) |
| 521 | (if discrep | ||
| 522 | (if today-only | ||
| 523 | (cadr discrep) | ||
| 524 | (car discrep)) | ||
| 525 | 0.0))))) | ||
| 517 | 526 | ||
| 518 | ;;;###autoload | 527 | ;;;###autoload |
| 519 | (defun timeclock-when-to-leave-string (&optional show-seconds | 528 | (defun timeclock-when-to-leave-string (&optional show-seconds |
| @@ -991,11 +1000,8 @@ See the documentation for the given function if more info is needed." | |||
| 991 | (cadr log-data)))) | 1000 | (cadr log-data)))) |
| 992 | log-data))) | 1001 | log-data))) |
| 993 | 1002 | ||
| 994 | (defun timeclock-find-discrep (&optional today-only) | 1003 | (defun timeclock-find-discrep () |
| 995 | "Find overall discrepancy from `timeclock-workday' (in seconds). | 1004 | "Find overall discrepancy from `timeclock-workday' (in seconds)." |
| 996 | If TODAY-ONLY is non-nil, the discrepancy will be not be relative, and | ||
| 997 | will correspond only to the amount of time elapsed today. This is | ||
| 998 | identical to what would be return if `timeclock-relative' were nil." | ||
| 999 | ;; This is not implemented in terms of the functions above, because | 1005 | ;; This is not implemented in terms of the functions above, because |
| 1000 | ;; it's a bit wasteful to read all of that data in, just to throw | 1006 | ;; it's a bit wasteful to read all of that data in, just to throw |
| 1001 | ;; away more than 90% of the information afterwards. | 1007 | ;; away more than 90% of the information afterwards. |
| @@ -1011,7 +1017,7 @@ identical to what would be return if `timeclock-relative' were nil." | |||
| 1011 | ;; total) | 1017 | ;; total) |
| 1012 | (let* ((now (current-time)) | 1018 | (let* ((now (current-time)) |
| 1013 | (todays-date (timeclock-time-to-date now)) | 1019 | (todays-date (timeclock-time-to-date now)) |
| 1014 | (first t) (accum 0) | 1020 | (first t) (accum 0) elapsed |
| 1015 | event beg last-date avg | 1021 | event beg last-date avg |
| 1016 | last-date-limited last-date-seconds) | 1022 | last-date-limited last-date-seconds) |
| 1017 | (unless timeclock-discrepancy | 1023 | (unless timeclock-discrepancy |
| @@ -1039,16 +1045,13 @@ identical to what would be return if `timeclock-relative' were nil." | |||
| 1039 | (add-to-list 'timeclock-project-list (nth 2 event)) | 1045 | (add-to-list 'timeclock-project-list (nth 2 event)) |
| 1040 | (setq timeclock-last-project (nth 2 event))) | 1046 | (setq timeclock-last-project (nth 2 event))) |
| 1041 | (let ((date (timeclock-time-to-date (cadr event)))) | 1047 | (let ((date (timeclock-time-to-date (cadr event)))) |
| 1042 | (if (if timeclock-relative | 1048 | (if (if last-date |
| 1043 | (if last-date | 1049 | (not (equal date last-date)) |
| 1044 | (not (equal date last-date)) | 1050 | first) |
| 1045 | first) | ||
| 1046 | (equal date todays-date)) | ||
| 1047 | (setq first nil | 1051 | (setq first nil |
| 1048 | accum (- accum | 1052 | accum (- accum (if last-date-limited |
| 1049 | (if last-date-limited | 1053 | last-date-seconds |
| 1050 | last-date-seconds | 1054 | timeclock-workday)))) |
| 1051 | timeclock-workday)))) | ||
| 1052 | (setq last-date date | 1055 | (setq last-date date |
| 1053 | last-date-limited nil) | 1056 | last-date-limited nil) |
| 1054 | (if beg | 1057 | (if beg |
| @@ -1058,15 +1061,12 @@ identical to what would be return if `timeclock-relative' were nil." | |||
| 1058 | (if (and (nth 2 event) | 1061 | (if (and (nth 2 event) |
| 1059 | (> (length (nth 2 event)) 0)) | 1062 | (> (length (nth 2 event)) 0)) |
| 1060 | (add-to-list 'timeclock-reason-list (nth 2 event))) | 1063 | (add-to-list 'timeclock-reason-list (nth 2 event))) |
| 1061 | (if (or timeclock-relative | 1064 | (if (not beg) |
| 1062 | (equal last-date todays-date)) | 1065 | (error "Error in format of timelog file!") |
| 1063 | (if (not beg) | 1066 | (setq timeclock-last-period |
| 1064 | (error "Error in format of timelog file!") | 1067 | (- (timeclock-time-to-seconds (cadr event)) beg) |
| 1065 | (setq timeclock-last-period | 1068 | accum (+ timeclock-last-period accum) |
| 1066 | (- (timeclock-time-to-seconds (cadr event)) beg) | 1069 | beg nil)) |
| 1067 | accum (+ timeclock-last-period accum) | ||
| 1068 | beg nil)) | ||
| 1069 | (setq beg nil)) | ||
| 1070 | (if (equal last-date todays-date) | 1070 | (if (equal last-date todays-date) |
| 1071 | (setq timeclock-elapsed | 1071 | (setq timeclock-elapsed |
| 1072 | (+ timeclock-last-period timeclock-elapsed))))) | 1072 | (+ timeclock-last-period timeclock-elapsed))))) |
| @@ -1077,17 +1077,19 @@ identical to what would be return if `timeclock-relative' were nil." | |||
| 1077 | timeclock-workday)) | 1077 | timeclock-workday)) |
| 1078 | (forward-line)) | 1078 | (forward-line)) |
| 1079 | (setq timeclock-discrepancy accum)))) | 1079 | (setq timeclock-discrepancy accum)))) |
| 1080 | (setq accum (if today-only | 1080 | (setq accum timeclock-discrepancy |
| 1081 | timeclock-elapsed | 1081 | elapsed timeclock-elapsed) |
| 1082 | timeclock-discrepancy)) | ||
| 1083 | (if timeclock-last-event | 1082 | (if timeclock-last-event |
| 1084 | (if (equal (car timeclock-last-event) "i") | 1083 | (if (equal (car timeclock-last-event) "i") |
| 1085 | (setq accum (+ accum (timeclock-last-period now))) | 1084 | (let ((last-period (timeclock-last-period now))) |
| 1085 | (setq accum (+ accum last-period) | ||
| 1086 | elapsed (+ elapsed last-period))) | ||
| 1086 | (if (not (equal (timeclock-time-to-date | 1087 | (if (not (equal (timeclock-time-to-date |
| 1087 | (cadr timeclock-last-event)) | 1088 | (cadr timeclock-last-event)) |
| 1088 | (timeclock-time-to-date now))) | 1089 | (timeclock-time-to-date now))) |
| 1089 | (setq accum (- accum timeclock-last-event-workday))))) | 1090 | (setq accum (- accum timeclock-last-event-workday))))) |
| 1090 | accum)) | 1091 | (list accum (- elapsed timeclock-last-event-workday) |
| 1092 | elapsed))) | ||
| 1091 | 1093 | ||
| 1092 | ;;; A reporting function that uses timeclock-log-data | 1094 | ;;; A reporting function that uses timeclock-log-data |
| 1093 | 1095 | ||