aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/calendar/timeclock.el
diff options
context:
space:
mode:
authorPaul Eggert2016-05-08 12:46:00 -0700
committerPaul Eggert2016-05-08 12:46:22 -0700
commite2f785991d0c696fbb2bc2f331f888d979b8da82 (patch)
treeba345e8547f4542bfe9bbb9ef311405bd519cd97 /lisp/calendar/timeclock.el
parent2eb6817ba971184cc109f8530f4b3b38f65650ea (diff)
downloademacs-e2f785991d0c696fbb2bc2f331f888d979b8da82.tar.gz
emacs-e2f785991d0c696fbb2bc2f331f888d979b8da82.zip
Simplify now that float-time etc. are built-in
This was prompted by warnings about calls to now-obsolete functions. * lisp/calendar/time-date.el (encode-time-value): Use setq rather than a recursive call, to avoid a warning about calling this obsolete function. * lisp/calendar/time-date.el (encode-time-value) (with-decoded-time-value, time-to-seconds, time-to-number-of-days): * lisp/erc/erc.el (erc-emacs-time-to-erc-time): * lisp/net/rcirc.el (rcirc-float-time): * lisp/org/org-compat.el (org-float-time): Simplify now that time-add and float-time are now built-in. * lisp/calendar/time-date.el (time-add, time-subtract, time-less-p): * lisp/net/newst-backend.el (time-add): * lisp/org/org.el (time-subtract): Remove backward-compatibility definitions; they are now built-in. * lisp/calendar/timeclock.el (timeclock-time-to-seconds) (timeclock-seconds-to-time): * lisp/net/rcirc.el (rcirc-float-time): * lisp/org/org-compat.el (org-float-time): Now obsolete, since callers can just use float-time and seconds-to-time. All uses changed. * lisp/emacs-lisp/ert.el (ert-results-pop-to-timings): * lisp/gnus/gnus-art.el (article-lapsed-string): * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): * lisp/gnus/gnus-group.el (gnus-group-timestamp-delta): * lisp/gnus/nndiary.el (nndiary-compute-reminders): * lisp/net/tramp.el (tramp-time-diff): * lisp/org/org-clock.el (org-clock-timestamps-change): Prefer the time-subtract builtin to the subtract-time alias. * lisp/files.el (dir-locals-find-file, dir-locals-read-from-dir): * test/lisp/character-fold-tests.el (character-fold--speed-test): Prefer the float-time builtin to the time-to-seconds alias. * lisp/org/org-agenda.el, lisp/org/org-clock.el, lisp/org/org-list.el: * lisp/org/org-timer.el, lisp/org/org.el: Adjust to org-float-time deprecation.
Diffstat (limited to 'lisp/calendar/timeclock.el')
-rw-r--r--lisp/calendar/timeclock.el60
1 files changed, 28 insertions, 32 deletions
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index 2bdfd98344a..3d9e2462224 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -532,18 +532,17 @@ non-nil, the amount returned will be relative to past time worked."
532 (message "%s" string) 532 (message "%s" string)
533 string))) 533 string)))
534 534
535(defalias 'timeclock-time-to-seconds (if (fboundp 'float-time) 'float-time 535(define-obsolete-function-alias 'timeclock-time-to-seconds 'float-time "26.1")
536 'time-to-seconds)) 536(define-obsolete-function-alias 'timeclock-seconds-to-time 'seconds-to-time
537 537 "26.1")
538(defalias 'timeclock-seconds-to-time 'seconds-to-time)
539 538
540;; Should today-only be removed in favor of timeclock-relative? - gm 539;; Should today-only be removed in favor of timeclock-relative? - gm
541(defsubst timeclock-when-to-leave (&optional today-only) 540(defsubst timeclock-when-to-leave (&optional today-only)
542 "Return a time value representing the end of today's workday. 541 "Return a time value representing the end of today's workday.
543If TODAY-ONLY is non-nil, the value returned will be relative only to 542If TODAY-ONLY is non-nil, the value returned will be relative only to
544the time worked today, and not to past time." 543the time worked today, and not to past time."
545 (timeclock-seconds-to-time 544 (seconds-to-time
546 (- (timeclock-time-to-seconds) 545 (- (float-time)
547 (let ((discrep (timeclock-find-discrep))) 546 (let ((discrep (timeclock-find-discrep)))
548 (if discrep 547 (if discrep
549 (if today-only 548 (if today-only
@@ -686,9 +685,8 @@ being logged for. Normally only \"in\" events specify a project."
686 "\n") 685 "\n")
687 (if (equal (downcase code) "o") 686 (if (equal (downcase code) "o")
688 (setq timeclock-last-period 687 (setq timeclock-last-period
689 (- (timeclock-time-to-seconds now) 688 (- (float-time now)
690 (timeclock-time-to-seconds 689 (float-time (cadr timeclock-last-event)))
691 (cadr timeclock-last-event)))
692 timeclock-discrepancy 690 timeclock-discrepancy
693 (+ timeclock-discrepancy 691 (+ timeclock-discrepancy
694 timeclock-last-period))) 692 timeclock-last-period)))
@@ -723,14 +721,14 @@ recorded to disk. If MOMENT is non-nil, use that as the current time.
723This is only provided for coherency when used by 721This is only provided for coherency when used by
724`timeclock-discrepancy'." 722`timeclock-discrepancy'."
725 (if (equal (car timeclock-last-event) "i") 723 (if (equal (car timeclock-last-event) "i")
726 (- (timeclock-time-to-seconds moment) 724 (- (float-time moment)
727 (timeclock-time-to-seconds (cadr timeclock-last-event))) 725 (float-time (cadr timeclock-last-event)))
728 timeclock-last-period)) 726 timeclock-last-period))
729 727
730(defsubst timeclock-entry-length (entry) 728(defsubst timeclock-entry-length (entry)
731 "Return the length of ENTRY in seconds." 729 "Return the length of ENTRY in seconds."
732 (- (timeclock-time-to-seconds (cadr entry)) 730 (- (float-time (cadr entry))
733 (timeclock-time-to-seconds (car entry)))) 731 (float-time (car entry))))
734 732
735(defsubst timeclock-entry-begin (entry) 733(defsubst timeclock-entry-begin (entry)
736 "Return the start time of ENTRY." 734 "Return the start time of ENTRY."
@@ -765,8 +763,8 @@ This is only provided for coherency when used by
765 763
766(defsubst timeclock-entry-list-span (entry-list) 764(defsubst timeclock-entry-list-span (entry-list)
767 "Return the total time in seconds spanned by ENTRY-LIST." 765 "Return the total time in seconds spanned by ENTRY-LIST."
768 (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list)) 766 (- (float-time (timeclock-entry-list-end entry-list))
769 (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list)))) 767 (float-time (timeclock-entry-list-begin entry-list))))
770 768
771(defsubst timeclock-entry-list-break (entry-list) 769(defsubst timeclock-entry-list-break (entry-list)
772 "Return the total break time (span - length) in ENTRY-LIST." 770 "Return the total break time (span - length) in ENTRY-LIST."
@@ -1137,7 +1135,7 @@ discrepancy, today's discrepancy, and the time worked today."
1137 last-date-limited nil) 1135 last-date-limited nil)
1138 (if beg 1136 (if beg
1139 (error "Error in format of timelog file!") 1137 (error "Error in format of timelog file!")
1140 (setq beg (timeclock-time-to-seconds (cadr event)))))) 1138 (setq beg (float-time (cadr event))))))
1141 ((equal (downcase (car event)) "o") 1139 ((equal (downcase (car event)) "o")
1142 (if (and (nth 2 event) 1140 (if (and (nth 2 event)
1143 (> (length (nth 2 event)) 0)) 1141 (> (length (nth 2 event)) 0))
@@ -1145,7 +1143,7 @@ discrepancy, today's discrepancy, and the time worked today."
1145 (if (not beg) 1143 (if (not beg)
1146 (error "Error in format of timelog file!") 1144 (error "Error in format of timelog file!")
1147 (setq timeclock-last-period 1145 (setq timeclock-last-period
1148 (- (timeclock-time-to-seconds (cadr event)) beg) 1146 (- (float-time (cadr event)) beg)
1149 accum (+ timeclock-last-period accum) 1147 accum (+ timeclock-last-period accum)
1150 beg nil)) 1148 beg nil))
1151 (if (equal last-date todays-date) 1149 (if (equal last-date todays-date)
@@ -1225,8 +1223,8 @@ HTML-P is non-nil, HTML markup is added."
1225 (insert project "</b><br>\n") 1223 (insert project "</b><br>\n")
1226 (insert project "*\n")) 1224 (insert project "*\n"))
1227 (let ((proj-data (cdr (assoc project (timeclock-project-alist log)))) 1225 (let ((proj-data (cdr (assoc project (timeclock-project-alist log))))
1228 (two-weeks-ago (timeclock-seconds-to-time 1226 (two-weeks-ago (seconds-to-time
1229 (- (timeclock-time-to-seconds today) 1227 (- (float-time today)
1230 (* 2 7 24 60 60)))) 1228 (* 2 7 24 60 60))))
1231 two-week-len today-len) 1229 two-week-len today-len)
1232 (while proj-data 1230 (while proj-data
@@ -1278,17 +1276,17 @@ HTML-P is non-nil, HTML markup is added."
1278 <th>-1 year</th> 1276 <th>-1 year</th>
1279</tr>") 1277</tr>")
1280 (let* ((day-list (timeclock-day-list)) 1278 (let* ((day-list (timeclock-day-list))
1281 (thirty-days-ago (timeclock-seconds-to-time 1279 (thirty-days-ago (seconds-to-time
1282 (- (timeclock-time-to-seconds today) 1280 (- (float-time today)
1283 (* 30 24 60 60)))) 1281 (* 30 24 60 60))))
1284 (three-months-ago (timeclock-seconds-to-time 1282 (three-months-ago (seconds-to-time
1285 (- (timeclock-time-to-seconds today) 1283 (- (float-time today)
1286 (* 90 24 60 60)))) 1284 (* 90 24 60 60))))
1287 (six-months-ago (timeclock-seconds-to-time 1285 (six-months-ago (seconds-to-time
1288 (- (timeclock-time-to-seconds today) 1286 (- (float-time today)
1289 (* 180 24 60 60)))) 1287 (* 180 24 60 60))))
1290 (one-year-ago (timeclock-seconds-to-time 1288 (one-year-ago (seconds-to-time
1291 (- (timeclock-time-to-seconds today) 1289 (- (float-time today)
1292 (* 365 24 60 60)))) 1290 (* 365 24 60 60))))
1293 (time-in (vector (list t) (list t) (list t) (list t) (list t))) 1291 (time-in (vector (list t) (list t) (list t) (list t) (list t)))
1294 (time-out (vector (list t) (list t) (list t) (list t) (list t))) 1292 (time-out (vector (list t) (list t) (list t) (list t) (list t)))
@@ -1303,12 +1301,11 @@ HTML-P is non-nil, HTML markup is added."
1303 (unless (time-less-p 1301 (unless (time-less-p
1304 (timeclock-day-begin day) 1302 (timeclock-day-begin day)
1305 (aref lengths i)) 1303 (aref lengths i))
1306 (let ((base (timeclock-time-to-seconds 1304 (let ((base (float-time
1307 (timeclock-day-base 1305 (timeclock-day-base
1308 (timeclock-day-begin day))))) 1306 (timeclock-day-begin day)))))
1309 (nconc (aref time-in i) 1307 (nconc (aref time-in i)
1310 (list (- (timeclock-time-to-seconds 1308 (list (- (float-time (timeclock-day-begin day))
1311 (timeclock-day-begin day))
1312 base))) 1309 base)))
1313 (let ((span (timeclock-day-span day)) 1310 (let ((span (timeclock-day-span day))
1314 (len (timeclock-day-length day)) 1311 (len (timeclock-day-length day))
@@ -1320,8 +1317,7 @@ HTML-P is non-nil, HTML markup is added."
1320 (when (and (> span 0) 1317 (when (and (> span 0)
1321 (> (/ (float len) (float span)) 0.70)) 1318 (> (/ (float len) (float span)) 0.70))
1322 (nconc (aref time-out i) 1319 (nconc (aref time-out i)
1323 (list (- (timeclock-time-to-seconds 1320 (list (- (float-time (timeclock-day-end day))
1324 (timeclock-day-end day))
1325 base))) 1321 base)))
1326 (nconc (aref breaks i) (list (- span len)))) 1322 (nconc (aref breaks i) (list (- span len))))
1327 (if req 1323 (if req