diff options
| author | Glenn Morris | 2003-06-12 17:28:48 +0000 |
|---|---|---|
| committer | Glenn Morris | 2003-06-12 17:28:48 +0000 |
| commit | b9c3a97d1d50163776b7c5b221b308fe3d1104e6 (patch) | |
| tree | f4d6eba78778b88ff2b3fe1935dd028fe31882fd | |
| parent | c110d2729c757e642c9ef64b7c3f594c8deccfc2 (diff) | |
| download | emacs-b9c3a97d1d50163776b7c5b221b308fe3d1104e6.tar.gz emacs-b9c3a97d1d50163776b7c5b221b308fe3d1104e6.zip | |
(display-time-hook, timeclock-modeline-display): Define for byte-compiler.
(timeclock-time-to-date, timeclock-workday-remaining)
(timeclock-time-to-seconds, timeclock-seconds-to-time): Move earlier
in the file so defined before used.
(timeclock-status-string): No need for `let*' so use `let'.
(timeclock-query-out): Always return a non-nil value.
| -rw-r--r-- | lisp/calendar/timeclock.el | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index 010a5aa89cc..49af1a82409 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el | |||
| @@ -144,6 +144,10 @@ that day has a different length from the norm." | |||
| 144 | (defvar timeclock-update-timer nil | 144 | (defvar timeclock-update-timer nil |
| 145 | "The timer used to update `timeclock-mode-string'.") | 145 | "The timer used to update `timeclock-mode-string'.") |
| 146 | 146 | ||
| 147 | ;; For byte-compiler. | ||
| 148 | (defvar display-time-hook) | ||
| 149 | (defvar timeclock-modeline-display) | ||
| 150 | |||
| 147 | (defcustom timeclock-use-display-time t | 151 | (defcustom timeclock-use-display-time t |
| 148 | "*If non-nil, use `display-time-hook' for doing modeline updates. | 152 | "*If non-nil, use `display-time-hook' for doing modeline updates. |
| 149 | The advantage to this is that it means one less timer has to be set | 153 | The advantage to this is that it means one less timer has to be set |
| @@ -321,6 +325,10 @@ You must modify via \\[customize] for this variable to have an effect." | |||
| 321 | :group 'timeclock | 325 | :group 'timeclock |
| 322 | :require 'timeclock) | 326 | :require 'timeclock) |
| 323 | 327 | ||
| 328 | (defsubst timeclock-time-to-date (time) | ||
| 329 | "Convert the TIME value to a textual date string." | ||
| 330 | (format-time-string "%Y/%m/%d" time)) | ||
| 331 | |||
| 324 | ;;;###autoload | 332 | ;;;###autoload |
| 325 | (defun timeclock-in (&optional arg project find-project) | 333 | (defun timeclock-in (&optional arg project find-project) |
| 326 | "Clock in, recording the current time moment in the timelog. | 334 | "Clock in, recording the current time moment in the timelog. |
| @@ -392,13 +400,26 @@ discover the reason." | |||
| 392 | (if arg | 400 | (if arg |
| 393 | (run-hooks 'timeclock-done-hook)))) | 401 | (run-hooks 'timeclock-done-hook)))) |
| 394 | 402 | ||
| 403 | (defsubst timeclock-workday-remaining (&optional today-only) | ||
| 404 | "Return the number of seconds until the workday is complete. | ||
| 405 | The amount returned is relative to the value of `timeclock-workday'. | ||
| 406 | If TODAY-ONLY is non-nil, the value returned will be relative only to | ||
| 407 | the time worked today, and not to past time. This argument only makes | ||
| 408 | a difference if `timeclock-relative' is non-nil." | ||
| 409 | (let ((discrep (timeclock-find-discrep))) | ||
| 410 | (if discrep | ||
| 411 | (if today-only | ||
| 412 | (- (cadr discrep)) | ||
| 413 | (- (car discrep))) | ||
| 414 | 0.0))) | ||
| 415 | |||
| 395 | ;;;###autoload | 416 | ;;;###autoload |
| 396 | (defun timeclock-status-string (&optional show-seconds today-only) | 417 | (defun timeclock-status-string (&optional show-seconds today-only) |
| 397 | "Report the overall timeclock status at the present moment." | 418 | "Report the overall timeclock status at the present moment." |
| 398 | (interactive "P") | 419 | (interactive "P") |
| 399 | (let* ((remainder (timeclock-workday-remaining)) | 420 | (let ((remainder (timeclock-workday-remaining)) |
| 400 | (last-in (equal (car timeclock-last-event) "i")) | 421 | (last-in (equal (car timeclock-last-event) "i")) |
| 401 | status) | 422 | status) |
| 402 | (setq status | 423 | (setq status |
| 403 | (format "Currently %s since %s (%s), %s %s, leave at %s" | 424 | (format "Currently %s since %s (%s), %s %s, leave at %s" |
| 404 | (if last-in "IN" "OUT") | 425 | (if last-in "IN" "OUT") |
| @@ -431,9 +452,11 @@ project you were working on." | |||
| 431 | (defun timeclock-query-out () | 452 | (defun timeclock-query-out () |
| 432 | "Ask the user before clocking out. | 453 | "Ask the user before clocking out. |
| 433 | This is a useful function for adding to `kill-emacs-query-functions'." | 454 | This is a useful function for adding to `kill-emacs-query-functions'." |
| 434 | (if (and (equal (car timeclock-last-event) "i") | 455 | (and (equal (car timeclock-last-event) "i") |
| 435 | (y-or-n-p "You're currently clocking time, clock out? ")) | 456 | (y-or-n-p "You're currently clocking time, clock out? ") |
| 436 | (timeclock-out))) | 457 | (timeclock-out)) |
| 458 | ;; Unconditionally return t for `kill-emacs-query-functions'. | ||
| 459 | t) | ||
| 437 | 460 | ||
| 438 | ;;;###autoload | 461 | ;;;###autoload |
| 439 | (defun timeclock-reread-log () | 462 | (defun timeclock-reread-log () |
| @@ -465,19 +488,6 @@ as with time remaining, where negative time really means overtime)." | |||
| 465 | (truncate (/ (abs seconds) 60 60)) | 488 | (truncate (/ (abs seconds) 60 60)) |
| 466 | (% (truncate (/ (abs seconds) 60)) 60)))) | 489 | (% (truncate (/ (abs seconds) 60)) 60)))) |
| 467 | 490 | ||
| 468 | (defsubst timeclock-workday-remaining (&optional today-only) | ||
| 469 | "Return the number of seconds until the workday is complete. | ||
| 470 | The amount returned is relative to the value of `timeclock-workday'. | ||
| 471 | If TODAY-ONLY is non-nil, the value returned will be relative only to | ||
| 472 | the time worked today, and not to past time. This argument only makes | ||
| 473 | a difference if `timeclock-relative' is non-nil." | ||
| 474 | (let ((discrep (timeclock-find-discrep))) | ||
| 475 | (if discrep | ||
| 476 | (if today-only | ||
| 477 | (- (cadr discrep)) | ||
| 478 | (- (car discrep))) | ||
| 479 | 0.0))) | ||
| 480 | |||
| 481 | (defsubst timeclock-currently-in-p () | 491 | (defsubst timeclock-currently-in-p () |
| 482 | "Return non-nil if the user is currently clocked in." | 492 | "Return non-nil if the user is currently clocked in." |
| 483 | (equal (car timeclock-last-event) "i")) | 493 | (equal (car timeclock-last-event) "i")) |
| @@ -520,6 +530,18 @@ non-nil, the amount returned will be relative to past time worked." | |||
| 520 | (message string) | 530 | (message string) |
| 521 | string))) | 531 | string))) |
| 522 | 532 | ||
| 533 | (defsubst timeclock-time-to-seconds (time) | ||
| 534 | "Convert TIME to a floating point number." | ||
| 535 | (+ (* (car time) 65536.0) | ||
| 536 | (cadr time) | ||
| 537 | (/ (or (car (cdr (cdr time))) 0) 1000000.0))) | ||
| 538 | |||
| 539 | (defsubst timeclock-seconds-to-time (seconds) | ||
| 540 | "Convert SECONDS (a floating point number) to an Emacs time structure." | ||
| 541 | (list (floor seconds 65536) | ||
| 542 | (floor (mod seconds 65536)) | ||
| 543 | (floor (* (- seconds (ffloor seconds)) 1000000)))) | ||
| 544 | |||
| 523 | (defsubst timeclock-when-to-leave (&optional today-only) | 545 | (defsubst timeclock-when-to-leave (&optional today-only) |
| 524 | "Return a time value representing at when the workday ends today. | 546 | "Return a time value representing at when the workday ends today. |
| 525 | If TODAY-ONLY is non-nil, the value returned will be relative only to | 547 | If TODAY-ONLY is non-nil, the value returned will be relative only to |
| @@ -657,22 +679,6 @@ being logged for. Normally only \"in\" events specify a project." | |||
| 657 | (project (match-string 8))) | 679 | (project (match-string 8))) |
| 658 | (list code (encode-time sec min hour mday mon year) project)))) | 680 | (list code (encode-time sec min hour mday mon year) project)))) |
| 659 | 681 | ||
| 660 | (defsubst timeclock-time-to-seconds (time) | ||
| 661 | "Convert TIME to a floating point number." | ||
| 662 | (+ (* (car time) 65536.0) | ||
| 663 | (cadr time) | ||
| 664 | (/ (or (car (cdr (cdr time))) 0) 1000000.0))) | ||
| 665 | |||
| 666 | (defsubst timeclock-seconds-to-time (seconds) | ||
| 667 | "Convert SECONDS (a floating point number) to an Emacs time structure." | ||
| 668 | (list (floor seconds 65536) | ||
| 669 | (floor (mod seconds 65536)) | ||
| 670 | (floor (* (- seconds (ffloor seconds)) 1000000)))) | ||
| 671 | |||
| 672 | (defsubst timeclock-time-to-date (time) | ||
| 673 | "Convert the TIME value to a textual date string." | ||
| 674 | (format-time-string "%Y/%m/%d" time)) | ||
| 675 | |||
| 676 | (defun timeclock-last-period (&optional moment) | 682 | (defun timeclock-last-period (&optional moment) |
| 677 | "Return the value of the last event period. | 683 | "Return the value of the last event period. |
| 678 | If the last event was a clock-in, the period will be open ended, and | 684 | If the last event was a clock-in, the period will be open ended, and |