summaryrefslogtreecommitdiff
path: root/lisp/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/cal-dst.el2
-rw-r--r--lisp/calendar/icalendar.el20
-rw-r--r--lisp/calendar/timeclock.el57
3 files changed, 35 insertions, 44 deletions
diff --git a/lisp/calendar/cal-dst.el b/lisp/calendar/cal-dst.el
index 57747c64f66..2126cfdadb1 100644
--- a/lisp/calendar/cal-dst.el
+++ b/lisp/calendar/cal-dst.el
@@ -231,7 +231,7 @@ The result has the proper form for `calendar-daylight-savings-starts'."
;; https://lists.gnu.org/r/emacs-pretest-bug/2006-11/msg00060.html
(defun calendar-dst-find-data (&optional time)
"Find data on the first daylight saving time transitions after TIME.
-TIME defaults to `current-time'. Return value is as described
+TIME defaults to the current time. Return value is as described
for `calendar-current-time-zone'."
(let* ((t0 (or time (current-time)))
(t0-zone (current-time-zone t0))
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 31ace6fb9be..a8fd765129e 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -643,12 +643,14 @@ FIXME: multiple comma-separated values should be allowed!"
(setq year (nth 2 mdy))))
;; create the decoded date-time
;; FIXME!?!
- (condition-case nil
- (decode-time (encode-time second minute hour day month year zone))
- (error
- (message "Cannot decode \"%s\"" isodatetimestring)
- ;; hope for the best...
- (list second minute hour day month year 0 nil 0))))
+ (let ((decoded-time (list second minute hour day month year
+ nil -1 zone)))
+ (condition-case nil
+ (decode-time (encode-time decoded-time 'integer))
+ (error
+ (message "Cannot decode \"%s\"" isodatetimestring)
+ ;; Hope for the best....
+ decoded-time))))
;; isodatetimestring == nil
nil))
@@ -1596,8 +1598,7 @@ regular expression matching the start of non-marking entries.
ENTRY-MAIN is the first line of the diary entry.
Optional argument START determines the first day of the
-enumeration, given as a time value, in same format as returned by
-`current-time' -- used for test purposes."
+enumeration, given as a Lisp time value -- used for test purposes."
(cond ((string-match (concat nonmarker
"%%(and \\(([^)]+)\\))\\(\\s-*.*?\\) ?$")
entry-main)
@@ -1621,8 +1622,7 @@ enumeration, given as a time value, in same format as returned by
(mapcar
(lambda (offset)
(let* ((day (decode-time (time-add now
- (encode-time
- (* offset 60 60 24)))))
+ (* 60 60 24 offset))))
(d (nth 3 day))
(m (nth 4 day))
(y (nth 5 day))
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index 5c3580dd848..a896df5e57c 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -467,16 +467,10 @@ include the second count. If REVERSE-LEADER is non-nil, it means to
output a \"+\" if the time value is negative, rather than a \"-\".
This is used when negative time values have an inverted meaning (such
as with time remaining, where negative time really means overtime)."
- (if show-seconds
- (format "%s%d:%02d:%02d"
- (if (< seconds 0) (if reverse-leader "+" "-") "")
- (truncate (/ (abs seconds) 60 60))
- (% (truncate (/ (abs seconds) 60)) 60)
- (% (truncate (abs seconds)) 60))
- (format "%s%d:%02d"
+ (let ((s (abs (truncate seconds))))
+ (format (if show-seconds "%s%d:%02d:%02d" "%s%d:%02d")
(if (< seconds 0) (if reverse-leader "+" "-") "")
- (truncate (/ (abs seconds) 60 60))
- (% (truncate (/ (abs seconds) 60)) 60))))
+ (/ s 3600) (% (/ s 60) 60) (% s 60))))
(defsubst timeclock-currently-in-p ()
"Return non-nil if the user is currently clocked in."
@@ -528,13 +522,12 @@ non-nil, the amount returned will be relative to past time worked."
"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."
- (time-subtract nil
- (let ((discrep (timeclock-find-discrep)))
- (if discrep
- (if today-only
- (cadr discrep)
- (car discrep))
- 0))))
+ (time-since (let ((discrep (timeclock-find-discrep)))
+ (if discrep
+ (if today-only
+ (cadr discrep)
+ (car discrep))
+ 0))))
;;;###autoload
(defun timeclock-when-to-leave-string (&optional show-seconds
@@ -671,8 +664,8 @@ being logged for. Normally only \"in\" events specify a project."
"\n")
(if (equal (downcase code) "o")
(setq timeclock-last-period
- (- (float-time now)
- (float-time (cadr timeclock-last-event)))
+ (float-time
+ (time-subtract now (cadr timeclock-last-event)))
timeclock-discrepancy
(+ timeclock-discrepancy
timeclock-last-period)))
@@ -707,8 +700,7 @@ 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")
- (- (float-time moment)
- (float-time (cadr timeclock-last-event)))
+ (float-time (time-subtract moment (cadr timeclock-last-event)))
timeclock-last-period))
(cl-defstruct (timeclock-entry
@@ -721,8 +713,7 @@ This is only provided for coherency when used by
(defsubst timeclock-entry-length (entry)
"Return the length of ENTRY in seconds."
- (- (float-time (cadr entry))
- (float-time (car entry))))
+ (float-time (time-subtract (cadr entry) (car entry))))
(defsubst timeclock-entry-list-length (entry-list)
"Return the total length of ENTRY-LIST in seconds."
@@ -741,8 +732,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."
- (- (float-time (timeclock-entry-list-end entry-list))
- (float-time (timeclock-entry-list-begin entry-list))))
+ (float-time (time-subtract (timeclock-entry-list-end entry-list)
+ (timeclock-entry-list-begin entry-list))))
(defsubst timeclock-entry-list-break (entry-list)
"Return the total break time (span - length) in ENTRY-LIST."
@@ -1109,7 +1100,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 (float-time (cadr event))))))
+ (setq beg (cadr event)))))
((equal (downcase (car event)) "o")
(if (and (nth 2 event)
(> (length (nth 2 event)) 0))
@@ -1117,7 +1108,7 @@ discrepancy, today's discrepancy, and the time worked today."
(if (not beg)
(error "Error in format of timelog file!")
(setq timeclock-last-period
- (- (float-time (cadr event)) beg)
+ (float-time (time-subtract (cadr event) beg))
accum (+ timeclock-last-period accum)
beg nil))
(if (equal last-date todays-date)
@@ -1262,12 +1253,11 @@ HTML-P is non-nil, HTML markup is added."
(unless (time-less-p
(timeclock-day-begin day)
(aref lengths i))
- (let ((base (float-time
- (timeclock-day-base
- (timeclock-day-begin day)))))
+ (let ((base (timeclock-day-base (timeclock-day-begin day))))
(nconc (aref time-in i)
- (list (- (float-time (timeclock-day-begin day))
- base)))
+ (list (float-time (time-subtract
+ (timeclock-day-begin day)
+ base))))
(let ((span (timeclock-day-span day))
(len (timeclock-day-length day))
(req (timeclock-day-required day)))
@@ -1278,8 +1268,9 @@ 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 (- (float-time (timeclock-day-end day))
- base)))
+ (list (float-time (time-subtract
+ (timeclock-day-end day)
+ base))))
(nconc (aref breaks i) (list (- span len))))
(if req
(setq len (+ len (- timeclock-workday req))))