summaryrefslogtreecommitdiff
path: root/lisp/calendar/timeclock.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-05-08 12:46:00 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-05-08 12:46:22 -0700
commite2f785991d0c696fbb2bc2f331f888d979b8da82 (patch)
treeba345e8547f4542bfe9bbb9ef311405bd519cd97 /lisp/calendar/timeclock.el
parent2eb6817ba971184cc109f8530f4b3b38f65650ea (diff)
downloademacs-e2f785991d0c696fbb2bc2f331f888d979b8da82.tar.gz
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."
(message "%s" string)
string)))
-(defalias 'timeclock-time-to-seconds (if (fboundp 'float-time) 'float-time
- 'time-to-seconds))
-
-(defalias 'timeclock-seconds-to-time 'seconds-to-time)
+(define-obsolete-function-alias 'timeclock-time-to-seconds 'float-time "26.1")
+(define-obsolete-function-alias 'timeclock-seconds-to-time 'seconds-to-time
+ "26.1")
;; Should today-only be removed in favor of timeclock-relative? - gm
(defsubst timeclock-when-to-leave (&optional today-only)
"Return a time value representing the end of today's workday.
If TODAY-ONLY is non-nil, the value returned will be relative only to
the time worked today, and not to past time."
- (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds)
+ (seconds-to-time
+ (- (float-time)
(let ((discrep (timeclock-find-discrep)))
(if discrep
(if today-only
@@ -686,9 +685,8 @@ being logged for. Normally only \"in\" events specify a project."
"\n")
(if (equal (downcase code) "o")
(setq timeclock-last-period
- (- (timeclock-time-to-seconds now)
- (timeclock-time-to-seconds
- (cadr timeclock-last-event)))
+ (- (float-time now)
+ (float-time (cadr timeclock-last-event)))
timeclock-discrepancy
(+ timeclock-discrepancy
timeclock-last-period)))
@@ -723,14 +721,14 @@ recorded to disk. If MOMENT is non-nil, use that as the current time.
This is only provided for coherency when used by
`timeclock-discrepancy'."
(if (equal (car timeclock-last-event) "i")
- (- (timeclock-time-to-seconds moment)
- (timeclock-time-to-seconds (cadr timeclock-last-event)))
+ (- (float-time moment)
+ (float-time (cadr timeclock-last-event)))
timeclock-last-period))
(defsubst timeclock-entry-length (entry)
"Return the length of ENTRY in seconds."
- (- (timeclock-time-to-seconds (cadr entry))
- (timeclock-time-to-seconds (car entry))))
+ (- (float-time (cadr entry))
+ (float-time (car entry))))
(defsubst timeclock-entry-begin (entry)
"Return the start time of ENTRY."
@@ -765,8 +763,8 @@ This is only provided for coherency when used by
(defsubst timeclock-entry-list-span (entry-list)
"Return the total time in seconds spanned by ENTRY-LIST."
- (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list))
- (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list))))
+ (- (float-time (timeclock-entry-list-end entry-list))
+ (float-time (timeclock-entry-list-begin entry-list))))
(defsubst timeclock-entry-list-break (entry-list)
"Return the total break time (span - length) in ENTRY-LIST."
@@ -1137,7 +1135,7 @@ discrepancy, today's discrepancy, and the time worked today."
last-date-limited nil)
(if beg
(error "Error in format of timelog file!")
- (setq beg (timeclock-time-to-seconds (cadr event))))))
+ (setq beg (float-time (cadr event))))))
((equal (downcase (car event)) "o")
(if (and (nth 2 event)
(> (length (nth 2 event)) 0))
@@ -1145,7 +1143,7 @@ discrepancy, today's discrepancy, and the time worked today."
(if (not beg)
(error "Error in format of timelog file!")
(setq timeclock-last-period
- (- (timeclock-time-to-seconds (cadr event)) beg)
+ (- (float-time (cadr event)) beg)
accum (+ timeclock-last-period accum)
beg nil))
(if (equal last-date todays-date)
@@ -1225,8 +1223,8 @@ HTML-P is non-nil, HTML markup is added."
(insert project "</b><br>\n")
(insert project "*\n"))
(let ((proj-data (cdr (assoc project (timeclock-project-alist log))))
- (two-weeks-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (two-weeks-ago (seconds-to-time
+ (- (float-time today)
(* 2 7 24 60 60))))
two-week-len today-len)
(while proj-data
@@ -1278,17 +1276,17 @@ HTML-P is non-nil, HTML markup is added."
<th>-1 year</th>
</tr>")
(let* ((day-list (timeclock-day-list))
- (thirty-days-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (thirty-days-ago (seconds-to-time
+ (- (float-time today)
(* 30 24 60 60))))
- (three-months-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (three-months-ago (seconds-to-time
+ (- (float-time today)
(* 90 24 60 60))))
- (six-months-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (six-months-ago (seconds-to-time
+ (- (float-time today)
(* 180 24 60 60))))
- (one-year-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (one-year-ago (seconds-to-time
+ (- (float-time today)
(* 365 24 60 60))))
(time-in (vector (list t) (list t) (list t) (list t) (list t)))
(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."
(unless (time-less-p
(timeclock-day-begin day)
(aref lengths i))
- (let ((base (timeclock-time-to-seconds
+ (let ((base (float-time
(timeclock-day-base
(timeclock-day-begin day)))))
(nconc (aref time-in i)
- (list (- (timeclock-time-to-seconds
- (timeclock-day-begin day))
+ (list (- (float-time (timeclock-day-begin day))
base)))
(let ((span (timeclock-day-span day))
(len (timeclock-day-length day))
@@ -1320,8 +1317,7 @@ HTML-P is non-nil, HTML markup is added."
(when (and (> span 0)
(> (/ (float len) (float span)) 0.70))
(nconc (aref time-out i)
- (list (- (timeclock-time-to-seconds
- (timeclock-day-end day))
+ (list (- (float-time (timeclock-day-end day))
base)))
(nconc (aref breaks i) (list (- span len))))
(if req