diff options
| author | Paul Eggert | 2014-11-16 20:38:15 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-11-16 20:41:22 -0800 |
| commit | 0921dbc3ab4dcc6b291ef45e46a24b322bbcb885 (patch) | |
| tree | 0e320978c7d30af415bb7de6e0b8f6735a3ca3d1 /lisp | |
| parent | 058f56d24f776bdc25bcac86fe1f8969a78374e9 (diff) | |
| download | emacs-0921dbc3ab4dcc6b291ef45e46a24b322bbcb885.tar.gz emacs-0921dbc3ab4dcc6b291ef45e46a24b322bbcb885.zip | |
Improve time stamp handling, and be more consistent about it.
This implements a suggestion made in:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html
Among other things, this means timer.el no longer needs to
autoload the time-date module.
* doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Processor Run Time, Time Calculations):
Document the new behavior, plus be clearer about the old behavior.
(Idle Timers): Take advantage of new functionality.
* etc/NEWS: Document the changes.
* lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix.
* lisp/arc-mode.el (archive-ar-summarize):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since):
* lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler)
(run-at-time, with-timeout-suspend, with-timeout-unsuspend):
* lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract):
* lisp/proced.el (proced-time-lessp):
* lisp/timezone.el (timezone-time-from-absolute):
* lisp/type-break.el (type-break-schedule, type-break-time-sum):
Simplify by using new functionality.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
Do not return time values in obsolete and undocumented (HI . LO)
format; use (HI LO) instead.
* lisp/calendar/time-date.el (with-decoded-time-value):
Treat 'nil' as current time. This is mostly for XEmacs.
(encode-time-value, with-decoded-time-value): Obsolete.
(time-add, time-subtract, time-less-p): Use no-op autoloads, for
XEmacs. Define only if XEmacs, as they're now C builtins in Emacs.
* lisp/ldefs-boot.el: Update to match new time-date.el
* lisp/proced.el: Do not require time-date.
* src/editfns.c (invalid_time): New function.
Use it instead of 'error ("Invalid time specification")'.
(time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p)
(decode_float_time, lisp_to_timespec, lisp_time_struct):
New functions.
(make_time_tail, make_time): Remove. All uses changed to use
new functions or plain list4i.
(disassemble_lisp_time): Return effective length if successful.
Check that LOW is an integer, if it's combined with other components.
(decode_time_components): Decode into struct lisp_time, not
struct timespec, so that we can support a wide set of times
regardless of whether time_t is signed. Decode plain numbers
as seconds since the Epoch, and nil as the current time.
(lisp_time_argument, lisp_seconds_argument, Ffloat_time):
Reimplement in terms of new functions.
(Fencode_time): Just use list2i.
(syms_of_editfns): Add time-add, time-subtract, time-less-p.
* src/keyboard.c (decode_timer): Don't allow the new formats (floating
point or nil) in timers.
* src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in
place of the magic number '16'.
(struct lisp_time): New type.
(decode_time_components): Use it.
(lisp_to_timespec): New decl.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 28 | ||||
| -rw-r--r-- | lisp/allout-widgets.el | 4 | ||||
| -rw-r--r-- | lisp/arc-mode.el | 6 | ||||
| -rw-r--r-- | lisp/calendar/cal-dst.el | 1 | ||||
| -rw-r--r-- | lisp/calendar/time-date.el | 158 | ||||
| -rw-r--r-- | lisp/emacs-lisp/timer.el | 16 | ||||
| -rw-r--r-- | lisp/ldefs-boot.el | 21 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 14 | ||||
| -rw-r--r-- | lisp/proced.el | 15 | ||||
| -rw-r--r-- | lisp/timezone.el | 10 | ||||
| -rw-r--r-- | lisp/type-break.el | 17 |
11 files changed, 129 insertions, 161 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7659d3c2235..7e516b95c61 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,31 @@ | |||
| 1 | 2014-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Improve time stamp handling, and be more consistent about it. | ||
| 4 | This implements a suggestion made in: | ||
| 5 | http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html | ||
| 6 | Among other things, this means timer.el no longer needs to | ||
| 7 | autoload the time-date module. | ||
| 8 | * allout-widgets.el (allout-elapsed-time-seconds): Doc fix. | ||
| 9 | * arc-mode.el (archive-ar-summarize): | ||
| 10 | * calendar/time-date.el (seconds-to-time, days-to-time, time-since): | ||
| 11 | * emacs-lisp/timer.el (timer-relative-time, timer-event-handler) | ||
| 12 | (run-at-time, with-timeout-suspend, with-timeout-unsuspend): | ||
| 13 | * net/tramp.el (tramp-time-less-p, tramp-time-subtract): | ||
| 14 | * proced.el (proced-time-lessp): | ||
| 15 | * timezone.el (timezone-time-from-absolute): | ||
| 16 | * type-break.el (type-break-schedule, type-break-time-sum): | ||
| 17 | Simplify by using new functionality. | ||
| 18 | * calendar/cal-dst.el (calendar-next-time-zone-transition): | ||
| 19 | Do not return time values in obsolete and undocumented (HI . LO) | ||
| 20 | format; use (HI LO) instead. | ||
| 21 | * calendar/time-date.el (with-decoded-time-value): | ||
| 22 | Treat 'nil' as current time. This is mostly for XEmacs. | ||
| 23 | (encode-time-value, with-decoded-time-value): Obsolete. | ||
| 24 | (time-add, time-subtract, time-less-p): Use no-op autoloads, for | ||
| 25 | XEmacs. Define only if XEmacs, as they're now C builtins in Emacs. | ||
| 26 | * ldefs-boot.el: Update to match new time-date.el | ||
| 27 | * proced.el: Do not require time-date. | ||
| 28 | |||
| 1 | 2014-11-16 Lars Magne Ingebrigtsen <larsi@gnus.org> | 29 | 2014-11-16 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 30 | ||
| 3 | * net/eww.el (eww-mode): Make the buffer read-only. | 31 | * net/eww.el (eww-mode): Make the buffer read-only. |
diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el index f2dcdb40425..25abf3f9252 100644 --- a/lisp/allout-widgets.el +++ b/lisp/allout-widgets.el | |||
| @@ -2342,9 +2342,9 @@ We use a caching strategy, so the caller doesn't need to do so." | |||
| 2342 | got))) | 2342 | got))) |
| 2343 | 2343 | ||
| 2344 | ;;;_ : Miscellaneous | 2344 | ;;;_ : Miscellaneous |
| 2345 | ;;;_ > allout-elapsed-time-seconds (triple) | 2345 | ;;;_ > allout-elapsed-time-seconds (time-value time-value) |
| 2346 | (defun allout-elapsed-time-seconds (end start) | 2346 | (defun allout-elapsed-time-seconds (end start) |
| 2347 | "Return seconds between `current-time' style time START/END triples." | 2347 | "Return seconds between START/END time values." |
| 2348 | (let ((elapsed (time-subtract end start))) | 2348 | (let ((elapsed (time-subtract end start))) |
| 2349 | (float-time elapsed))) | 2349 | (float-time elapsed))) |
| 2350 | ;;;_ > allout-frame-property (frame property) | 2350 | ;;;_ > allout-frame-property (frame property) |
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index ef155ee2b99..a9f0ec71b51 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el | |||
| @@ -2181,11 +2181,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 2181 | (size (string-to-number (match-string 6)))) | 2181 | (size (string-to-number (match-string 6)))) |
| 2182 | ;; Move to the beginning of the data. | 2182 | ;; Move to the beginning of the data. |
| 2183 | (goto-char (match-end 0)) | 2183 | (goto-char (match-end 0)) |
| 2184 | (setq time | 2184 | (setq time (format-time-string "%Y-%m-%d %H:%M" time)) |
| 2185 | (format-time-string | ||
| 2186 | "%Y-%m-%d %H:%M" | ||
| 2187 | (let ((high (truncate (/ time 65536)))) | ||
| 2188 | (list high (truncate (- time (* 65536.0 high))))))) | ||
| 2189 | (setq extname | 2185 | (setq extname |
| 2190 | (cond ((equal name "// ") | 2186 | (cond ((equal name "// ") |
| 2191 | (propertize ".<ExtNamesTable>." 'face 'italic)) | 2187 | (propertize ".<ExtNamesTable>." 'face 'italic)) |
diff --git a/lisp/calendar/cal-dst.el b/lisp/calendar/cal-dst.el index e3cb690306e..2a9cdee301d 100644 --- a/lisp/calendar/cal-dst.el +++ b/lisp/calendar/cal-dst.el | |||
| @@ -179,6 +179,7 @@ Return nil if no such transition can be found." | |||
| 179 | (if (eq (car (current-time-zone probe)) hi-utc-diff) | 179 | (if (eq (car (current-time-zone probe)) hi-utc-diff) |
| 180 | (setq hi probe) | 180 | (setq hi probe) |
| 181 | (setq lo probe))) | 181 | (setq lo probe))) |
| 182 | (setcdr hi (list (cdr hi))) | ||
| 182 | hi)))) | 183 | hi)))) |
| 183 | 184 | ||
| 184 | (autoload 'calendar-persian-to-absolute "cal-persia") | 185 | (autoload 'calendar-persian-to-absolute "cal-persia") |
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 82bc05f299f..100e856469a 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el | |||
| @@ -30,10 +30,9 @@ | |||
| 30 | ;; value equal to HIGH * 2^16 + LOW + USEC * 10^-6 + PSEC * 10^-12 | 30 | ;; value equal to HIGH * 2^16 + LOW + USEC * 10^-6 + PSEC * 10^-12 |
| 31 | ;; seconds, where missing components are treated as zero. HIGH can be | 31 | ;; seconds, where missing components are treated as zero. HIGH can be |
| 32 | ;; negative, either because the value is a time difference, or because | 32 | ;; negative, either because the value is a time difference, or because |
| 33 | ;; the machine supports negative time stamps that fall before the epoch. | 33 | ;; it represents a time stamp before the epoch. Typically, there are |
| 34 | ;; The macro `with-decoded-time-value' and the function | 34 | ;; more time values than the underlying system time type supports, |
| 35 | ;; `encode-time-value' make it easier to deal with these formats. | 35 | ;; but the reverse can also be true. |
| 36 | ;; See `time-subtract' for an example of how to use them. | ||
| 37 | 36 | ||
| 38 | ;;; Code: | 37 | ;;; Code: |
| 39 | 38 | ||
| @@ -71,6 +70,7 @@ list (HIGH LOW MICRO PICO)." | |||
| 71 | ,low ,micro) | 70 | ,low ,micro) |
| 72 | (when pico `(,pico)) | 71 | (when pico `(,pico)) |
| 73 | (when type `(,type))) | 72 | (when type `(,type))) |
| 73 | (or ,gensym (setq ,gensym (current-time))) | ||
| 74 | (if (consp ,gensym) | 74 | (if (consp ,gensym) |
| 75 | (progn | 75 | (progn |
| 76 | (setq ,low (pop ,gensym)) | 76 | (setq ,low (pop ,gensym)) |
| @@ -108,6 +108,10 @@ it is assumed that PICO was omitted and should be treated as zero." | |||
| 108 | ((eq type 3) (list high low micro pico)) | 108 | ((eq type 3) (list high low micro pico)) |
| 109 | ((null type) (encode-time-value high low micro 0 pico)))) | 109 | ((null type) (encode-time-value high low micro 0 pico)))) |
| 110 | 110 | ||
| 111 | (when (featurep 'emacs) | ||
| 112 | (make-obsolete 'encode-time-value nil "25.1") | ||
| 113 | (make-obsolete 'with-decoded-time-value nil "25.1")) | ||
| 114 | |||
| 111 | (autoload 'parse-time-string "parse-time") | 115 | (autoload 'parse-time-string "parse-time") |
| 112 | (autoload 'timezone-make-date-arpa-standard "timezone") | 116 | (autoload 'timezone-make-date-arpa-standard "timezone") |
| 113 | 117 | ||
| @@ -158,47 +162,17 @@ TIME defaults to the current time." | |||
| 158 | 162 | ||
| 159 | ;;;###autoload | 163 | ;;;###autoload |
| 160 | (defun seconds-to-time (seconds) | 164 | (defun seconds-to-time (seconds) |
| 161 | "Convert SECONDS (a floating point number) to a time value." | 165 | "Convert SECONDS to a time value." |
| 162 | (let* ((usec (* 1000000 (mod seconds 1))) | 166 | (time-add 0 seconds)) |
| 163 | (ps (round (* 1000000 (mod usec 1)))) | ||
| 164 | (us (floor usec)) | ||
| 165 | (lo (floor (mod seconds 65536))) | ||
| 166 | (hi (floor seconds 65536))) | ||
| 167 | (if (eq ps 1000000) | ||
| 168 | (progn | ||
| 169 | (setq ps 0) | ||
| 170 | (setq us (1+ us)) | ||
| 171 | (if (eq us 1000000) | ||
| 172 | (progn | ||
| 173 | (setq us 0) | ||
| 174 | (setq lo (1+ lo)) | ||
| 175 | (if (eq lo 65536) | ||
| 176 | (progn | ||
| 177 | (setq lo 0) | ||
| 178 | (setq hi (1+ hi)))))))) | ||
| 179 | (list hi lo us ps))) | ||
| 180 | |||
| 181 | ;;;###autoload | ||
| 182 | (defun time-less-p (t1 t2) | ||
| 183 | "Return non-nil if time value T1 is earlier than time value T2." | ||
| 184 | (with-decoded-time-value ((high1 low1 micro1 pico1 type1 t1) | ||
| 185 | (high2 low2 micro2 pico2 type2 t2)) | ||
| 186 | (or (< high1 high2) | ||
| 187 | (and (= high1 high2) | ||
| 188 | (or (< low1 low2) | ||
| 189 | (and (= low1 low2) | ||
| 190 | (or (< micro1 micro2) | ||
| 191 | (and (= micro1 micro2) | ||
| 192 | (< pico1 pico2))))))))) | ||
| 193 | 167 | ||
| 194 | ;;;###autoload | 168 | ;;;###autoload |
| 195 | (defun days-to-time (days) | 169 | (defun days-to-time (days) |
| 196 | "Convert DAYS into a time value." | 170 | "Convert DAYS into a time value." |
| 197 | (let* ((seconds (* 1.0 days 60 60 24)) | 171 | (let ((time (condition-case nil (seconds-to-time (* 86400.0 days)) |
| 198 | (high (condition-case nil (floor (/ seconds 65536)) | 172 | (range-error (list most-positive-fixnum 65535))))) |
| 199 | (range-error most-positive-fixnum)))) | 173 | (if (integerp days) |
| 200 | (list high (condition-case nil (floor (- seconds (* 1.0 high 65536))) | 174 | (setcdr (cdr time) nil)) |
| 201 | (range-error 65535))))) | 175 | time)) |
| 202 | 176 | ||
| 203 | ;;;###autoload | 177 | ;;;###autoload |
| 204 | (defun time-since (time) | 178 | (defun time-since (time) |
| @@ -207,53 +181,71 @@ TIME should be either a time value or a date-time string." | |||
| 207 | (when (stringp time) | 181 | (when (stringp time) |
| 208 | ;; Convert date strings to internal time. | 182 | ;; Convert date strings to internal time. |
| 209 | (setq time (date-to-time time))) | 183 | (setq time (date-to-time time))) |
| 210 | (time-subtract (current-time) time)) | 184 | (time-subtract nil time)) |
| 211 | 185 | ||
| 212 | ;;;###autoload | 186 | ;;;###autoload |
| 213 | (defalias 'subtract-time 'time-subtract) | 187 | (defalias 'subtract-time 'time-subtract) |
| 214 | 188 | ||
| 215 | ;;;###autoload | 189 | ;; These autoloads do nothing in Emacs 25, where the functions are builtin. |
| 216 | (defun time-subtract (t1 t2) | 190 | ;;;###autoload(autoload 'time-add "time-date") |
| 217 | "Subtract two time values, T1 minus T2. | 191 | ;;;###autoload(autoload 'time-subtract "time-date") |
| 218 | Return the difference in the format of a time value." | 192 | ;;;###autoload(autoload 'time-less-p "time-date") |
| 219 | (with-decoded-time-value ((high low micro pico type t1) | ||
| 220 | (high2 low2 micro2 pico2 type2 t2)) | ||
| 221 | (setq high (- high high2) | ||
| 222 | low (- low low2) | ||
| 223 | micro (- micro micro2) | ||
| 224 | pico (- pico pico2) | ||
| 225 | type (max type type2)) | ||
| 226 | (when (< pico 0) | ||
| 227 | (setq micro (1- micro) | ||
| 228 | pico (+ pico 1000000))) | ||
| 229 | (when (< micro 0) | ||
| 230 | (setq low (1- low) | ||
| 231 | micro (+ micro 1000000))) | ||
| 232 | (when (< low 0) | ||
| 233 | (setq high (1- high) | ||
| 234 | low (+ low 65536))) | ||
| 235 | (encode-time-value high low micro pico type))) | ||
| 236 | 193 | ||
| 237 | ;;;###autoload | 194 | (eval-when-compile |
| 238 | (defun time-add (t1 t2) | 195 | (when (not (featurep 'emacs)) |
| 239 | "Add two time values T1 and T2. One should represent a time difference." | 196 | |
| 240 | (with-decoded-time-value ((high low micro pico type t1) | 197 | (defun time-add (t1 t2) |
| 241 | (high2 low2 micro2 pico2 type2 t2)) | 198 | "Add two time values T1 and T2. One should represent a time difference." |
| 242 | (setq high (+ high high2) | 199 | (with-decoded-time-value ((high low micro pico type t1) |
| 243 | low (+ low low2) | 200 | (high2 low2 micro2 pico2 type2 t2)) |
| 244 | micro (+ micro micro2) | 201 | (setq high (+ high high2) |
| 245 | pico (+ pico pico2) | 202 | low (+ low low2) |
| 246 | type (max type type2)) | 203 | micro (+ micro micro2) |
| 247 | (when (>= pico 1000000) | 204 | pico (+ pico pico2) |
| 248 | (setq micro (1+ micro) | 205 | type (max type type2)) |
| 249 | pico (- pico 1000000))) | 206 | (when (>= pico 1000000) |
| 250 | (when (>= micro 1000000) | 207 | (setq micro (1+ micro) |
| 251 | (setq low (1+ low) | 208 | pico (- pico 1000000))) |
| 252 | micro (- micro 1000000))) | 209 | (when (>= micro 1000000) |
| 253 | (when (>= low 65536) | 210 | (setq low (1+ low) |
| 254 | (setq high (1+ high) | 211 | micro (- micro 1000000))) |
| 255 | low (- low 65536))) | 212 | (when (>= low 65536) |
| 256 | (encode-time-value high low micro pico type))) | 213 | (setq high (1+ high) |
| 214 | low (- low 65536))) | ||
| 215 | (encode-time-value high low micro pico type))) | ||
| 216 | |||
| 217 | (defun time-subtract (t1 t2) | ||
| 218 | "Subtract two time values, T1 minus T2. | ||
| 219 | Return the difference in the format of a time value." | ||
| 220 | (with-decoded-time-value ((high low micro pico type t1) | ||
| 221 | (high2 low2 micro2 pico2 type2 t2)) | ||
| 222 | (setq high (- high high2) | ||
| 223 | low (- low low2) | ||
| 224 | micro (- micro micro2) | ||
| 225 | pico (- pico pico2) | ||
| 226 | type (max type type2)) | ||
| 227 | (when (< pico 0) | ||
| 228 | (setq micro (1- micro) | ||
| 229 | pico (+ pico 1000000))) | ||
| 230 | (when (< micro 0) | ||
| 231 | (setq low (1- low) | ||
| 232 | micro (+ micro 1000000))) | ||
| 233 | (when (< low 0) | ||
| 234 | (setq high (1- high) | ||
| 235 | low (+ low 65536))) | ||
| 236 | (encode-time-value high low micro pico type))) | ||
| 237 | |||
| 238 | (defun time-less-p (t1 t2) | ||
| 239 | "Return non-nil if time value T1 is earlier than time value T2." | ||
| 240 | (with-decoded-time-value ((high1 low1 micro1 pico1 type1 t1) | ||
| 241 | (high2 low2 micro2 pico2 type2 t2)) | ||
| 242 | (or (< high1 high2) | ||
| 243 | (and (= high1 high2) | ||
| 244 | (or (< low1 low2) | ||
| 245 | (and (= low1 low2) | ||
| 246 | (or (< micro1 micro2) | ||
| 247 | (and (= micro1 micro2) | ||
| 248 | (< pico1 pico2))))))))))) | ||
| 257 | 249 | ||
| 258 | ;;;###autoload | 250 | ;;;###autoload |
| 259 | (defun date-to-day (date) | 251 | (defun date-to-day (date) |
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index 7fc6bf7b920..a189d242ac4 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el | |||
| @@ -125,9 +125,7 @@ of SECS seconds since the epoch. SECS may be a fraction." | |||
| 125 | "Advance TIME by SECS seconds and optionally USECS microseconds | 125 | "Advance TIME by SECS seconds and optionally USECS microseconds |
| 126 | and PSECS picoseconds. SECS may be either an integer or a | 126 | and PSECS picoseconds. SECS may be either an integer or a |
| 127 | floating point number." | 127 | floating point number." |
| 128 | (let ((delta (if (floatp secs) | 128 | (let ((delta secs)) |
| 129 | (seconds-to-time secs) | ||
| 130 | (list (floor secs 65536) (mod secs 65536))))) | ||
| 131 | (if (or usecs psecs) | 129 | (if (or usecs psecs) |
| 132 | (setq delta (time-add delta (list 0 0 (or usecs 0) (or psecs 0))))) | 130 | (setq delta (time-add delta (list 0 0 (or usecs 0) (or psecs 0))))) |
| 133 | (time-add time delta))) | 131 | (time-add time delta))) |
| @@ -307,8 +305,8 @@ This function is called, by name, directly by the C code." | |||
| 307 | ;; perhaps because Emacs was suspended for a long time, | 305 | ;; perhaps because Emacs was suspended for a long time, |
| 308 | ;; limit how many times things get repeated. | 306 | ;; limit how many times things get repeated. |
| 309 | (if (and (numberp timer-max-repeats) | 307 | (if (and (numberp timer-max-repeats) |
| 310 | (< 0 (timer-until timer (current-time)))) | 308 | (< 0 (timer-until timer nil))) |
| 311 | (let ((repeats (/ (timer-until timer (current-time)) | 309 | (let ((repeats (/ (timer-until timer nil) |
| 312 | (timer--repeat-delay timer)))) | 310 | (timer--repeat-delay timer)))) |
| 313 | (if (> repeats timer-max-repeats) | 311 | (if (> repeats timer-max-repeats) |
| 314 | (timer-inc-time timer (* (timer--repeat-delay timer) | 312 | (timer-inc-time timer (* (timer--repeat-delay timer) |
| @@ -374,13 +372,13 @@ This function returns a timer object which you can use in `cancel-timer'." | |||
| 374 | 372 | ||
| 375 | ;; Handle numbers as relative times in seconds. | 373 | ;; Handle numbers as relative times in seconds. |
| 376 | (if (numberp time) | 374 | (if (numberp time) |
| 377 | (setq time (timer-relative-time (current-time) time))) | 375 | (setq time (timer-relative-time nil time))) |
| 378 | 376 | ||
| 379 | ;; Handle relative times like "2 hours 35 minutes" | 377 | ;; Handle relative times like "2 hours 35 minutes" |
| 380 | (if (stringp time) | 378 | (if (stringp time) |
| 381 | (let ((secs (timer-duration time))) | 379 | (let ((secs (timer-duration time))) |
| 382 | (if secs | 380 | (if secs |
| 383 | (setq time (timer-relative-time (current-time) secs))))) | 381 | (setq time (timer-relative-time nil secs))))) |
| 384 | 382 | ||
| 385 | ;; Handle "11:23pm" and the like. Interpret it as meaning today | 383 | ;; Handle "11:23pm" and the like. Interpret it as meaning today |
| 386 | ;; which admittedly is rather stupid if we have passed that time | 384 | ;; which admittedly is rather stupid if we have passed that time |
| @@ -486,7 +484,7 @@ The value is a list that the debugger can pass to `with-timeout-unsuspend' | |||
| 486 | when it exits, to make these timers start counting again." | 484 | when it exits, to make these timers start counting again." |
| 487 | (mapcar (lambda (timer) | 485 | (mapcar (lambda (timer) |
| 488 | (cancel-timer timer) | 486 | (cancel-timer timer) |
| 489 | (list timer (time-subtract (timer--time timer) (current-time)))) | 487 | (list timer (time-subtract (timer--time timer) nil))) |
| 490 | with-timeout-timers)) | 488 | with-timeout-timers)) |
| 491 | 489 | ||
| 492 | (defun with-timeout-unsuspend (timer-spec-list) | 490 | (defun with-timeout-unsuspend (timer-spec-list) |
| @@ -495,7 +493,7 @@ The argument should be a value previously returned by `with-timeout-suspend'." | |||
| 495 | (dolist (elt timer-spec-list) | 493 | (dolist (elt timer-spec-list) |
| 496 | (let ((timer (car elt)) | 494 | (let ((timer (car elt)) |
| 497 | (delay (cadr elt))) | 495 | (delay (cadr elt))) |
| 498 | (timer-set-time timer (time-add (current-time) delay)) | 496 | (timer-set-time timer (time-add nil delay)) |
| 499 | (timer-activate timer)))) | 497 | (timer-activate timer)))) |
| 500 | 498 | ||
| 501 | (defun y-or-n-p-with-timeout (prompt seconds default-value) | 499 | (defun y-or-n-p-with-timeout (prompt seconds default-value) |
diff --git a/lisp/ldefs-boot.el b/lisp/ldefs-boot.el index b78c906b450..f60d6608f7e 100644 --- a/lisp/ldefs-boot.el +++ b/lisp/ldefs-boot.el | |||
| @@ -27478,15 +27478,10 @@ If DATE lacks timezone information, GMT is assumed. | |||
| 27478 | (autoload 'time-to-seconds "time-date")) | 27478 | (autoload 'time-to-seconds "time-date")) |
| 27479 | 27479 | ||
| 27480 | (autoload 'seconds-to-time "time-date" "\ | 27480 | (autoload 'seconds-to-time "time-date" "\ |
| 27481 | Convert SECONDS (a floating point number) to a time value. | 27481 | Convert SECONDS to a time value. |
| 27482 | 27482 | ||
| 27483 | \(fn SECONDS)" nil nil) | 27483 | \(fn SECONDS)" nil nil) |
| 27484 | 27484 | ||
| 27485 | (autoload 'time-less-p "time-date" "\ | ||
| 27486 | Return non-nil if time value T1 is earlier than time value T2. | ||
| 27487 | |||
| 27488 | \(fn T1 T2)" nil nil) | ||
| 27489 | |||
| 27490 | (autoload 'days-to-time "time-date" "\ | 27485 | (autoload 'days-to-time "time-date" "\ |
| 27491 | Convert DAYS into a time value. | 27486 | Convert DAYS into a time value. |
| 27492 | 27487 | ||
| @@ -27499,17 +27494,9 @@ TIME should be either a time value or a date-time string. | |||
| 27499 | \(fn TIME)" nil nil) | 27494 | \(fn TIME)" nil nil) |
| 27500 | 27495 | ||
| 27501 | (defalias 'subtract-time 'time-subtract) | 27496 | (defalias 'subtract-time 'time-subtract) |
| 27502 | 27497 | (autoload 'time-add "time-date") | |
| 27503 | (autoload 'time-subtract "time-date" "\ | 27498 | (autoload 'time-subtract "time-date") |
| 27504 | Subtract two time values, T1 minus T2. | 27499 | (autoload 'time-less-p "time-date") |
| 27505 | Return the difference in the format of a time value. | ||
| 27506 | |||
| 27507 | \(fn T1 T2)" nil nil) | ||
| 27508 | |||
| 27509 | (autoload 'time-add "time-date" "\ | ||
| 27510 | Add two time values T1 and T2. One should represent a time difference. | ||
| 27511 | |||
| 27512 | \(fn T1 T2)" nil nil) | ||
| 27513 | 27500 | ||
| 27514 | (autoload 'date-to-day "time-date" "\ | 27501 | (autoload 'date-to-day "time-date" "\ |
| 27515 | Return the number of days between year 1 and DATE. | 27502 | Return the number of days between year 1 and DATE. |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 5889743e28b..01cd8191169 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -4236,25 +4236,15 @@ Invokes `password-read' if available, `read-passwd' else." | |||
| 4236 | ("oct" . 10) ("nov" . 11) ("dec" . 12)) | 4236 | ("oct" . 10) ("nov" . 11) ("dec" . 12)) |
| 4237 | "Alist mapping month names to integers.") | 4237 | "Alist mapping month names to integers.") |
| 4238 | 4238 | ||
| 4239 | ;; FIXME: Shouldn't this also look at any subseconds parts of T1 and T2? | ||
| 4240 | ;;;###tramp-autoload | 4239 | ;;;###tramp-autoload |
| 4241 | (defun tramp-time-less-p (t1 t2) | 4240 | (defun tramp-time-less-p (t1 t2) |
| 4242 | "Say whether time value T1 is less than time value T2." | 4241 | "Say whether time value T1 is less than time value T2." |
| 4243 | (unless t1 (setq t1 '(0 0))) | 4242 | (time-less-p (or t1 0) (or t2 0))) |
| 4244 | (unless t2 (setq t2 '(0 0))) | ||
| 4245 | (or (< (car t1) (car t2)) | ||
| 4246 | (and (= (car t1) (car t2)) | ||
| 4247 | (< (nth 1 t1) (nth 1 t2))))) | ||
| 4248 | 4243 | ||
| 4249 | ;; FIXME: Shouldn't this also look at any subseconds parts of T1 and T2? | ||
| 4250 | (defun tramp-time-subtract (t1 t2) | 4244 | (defun tramp-time-subtract (t1 t2) |
| 4251 | "Subtract two time values. | 4245 | "Subtract two time values. |
| 4252 | Return the difference in the format of a time value." | 4246 | Return the difference in the format of a time value." |
| 4253 | (unless t1 (setq t1 '(0 0))) | 4247 | (time-subtract (or t1 0) (or t2 0))) |
| 4254 | (unless t2 (setq t2 '(0 0))) | ||
| 4255 | (let ((borrow (< (cadr t1) (cadr t2)))) | ||
| 4256 | (list (- (car t1) (car t2) (if borrow 1 0)) | ||
| 4257 | (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2))))) | ||
| 4258 | 4248 | ||
| 4259 | ;;;###tramp-autoload | 4249 | ;;;###tramp-autoload |
| 4260 | (defun tramp-time-diff (t1 t2) | 4250 | (defun tramp-time-diff (t1 t2) |
diff --git a/lisp/proced.el b/lisp/proced.el index 592c0d066c7..188b8c354c6 100644 --- a/lisp/proced.el +++ b/lisp/proced.el | |||
| @@ -49,8 +49,6 @@ | |||
| 49 | 49 | ||
| 50 | ;;; Code: | 50 | ;;; Code: |
| 51 | 51 | ||
| 52 | (require 'time-date) ; for `with-decoded-time-value' | ||
| 53 | |||
| 54 | (defgroup proced nil | 52 | (defgroup proced nil |
| 55 | "Proced mode." | 53 | "Proced mode." |
| 56 | :group 'processes | 54 | :group 'processes |
| @@ -1186,17 +1184,8 @@ Return nil otherwise." | |||
| 1186 | (defun proced-time-lessp (t1 t2) | 1184 | (defun proced-time-lessp (t1 t2) |
| 1187 | "Return t if time value T1 is less than time value T2. | 1185 | "Return t if time value T1 is less than time value T2. |
| 1188 | Return `equal' if T1 equals T2. Return nil otherwise." | 1186 | Return `equal' if T1 equals T2. Return nil otherwise." |
| 1189 | (with-decoded-time-value ((high1 low1 micro1 pico1 type1 t1) | 1187 | (or (time-less-p t1 t2) |
| 1190 | (high2 low2 micro2 pico2 type2 t2)) | 1188 | (if (not (time-less-p t2 t1)) 'equal))) |
| 1191 | (cond ((< high1 high2)) | ||
| 1192 | ((< high2 high1) nil) | ||
| 1193 | ((< low1 low2)) | ||
| 1194 | ((< low2 low1) nil) | ||
| 1195 | ((< micro1 micro2)) | ||
| 1196 | ((< micro2 micro1) nil) | ||
| 1197 | ((< pico1 pico2)) | ||
| 1198 | ((< pico2 pico1) nil) | ||
| 1199 | (t 'equal)))) | ||
| 1200 | 1189 | ||
| 1201 | ;;; Sorting | 1190 | ;;; Sorting |
| 1202 | 1191 | ||
diff --git a/lisp/timezone.el b/lisp/timezone.el index 1135092b039..8ff43966f69 100644 --- a/lisp/timezone.el +++ b/lisp/timezone.el | |||
| @@ -295,13 +295,9 @@ Gregorian date Sunday, December 31, 1 BC." | |||
| 295 | ;; (timezone-absolute-from-gregorian 1 1 1970) | 295 | ;; (timezone-absolute-from-gregorian 1 1 1970) |
| 296 | (days (- date current-time-origin)) | 296 | (days (- date current-time-origin)) |
| 297 | (seconds-per-day (float 86400)) | 297 | (seconds-per-day (float 86400)) |
| 298 | (seconds (+ seconds (* days seconds-per-day))) | 298 | (day-seconds (* days seconds-per-day))) |
| 299 | (current-time-arithmetic-base (float 65536)) | 299 | (condition-case nil (time-add day-seconds seconds) |
| 300 | (hi (floor (/ seconds current-time-arithmetic-base))) | 300 | (range-error)))) |
| 301 | (hibase (* hi current-time-arithmetic-base)) | ||
| 302 | (lo (floor (- seconds hibase)))) | ||
| 303 | (and (< (abs (- seconds (+ hibase lo))) 2) ;; Check for integer overflow. | ||
| 304 | (cons hi lo)))) | ||
| 305 | 301 | ||
| 306 | (defun timezone-time-zone-from-absolute (date seconds) | 302 | (defun timezone-time-zone-from-absolute (date seconds) |
| 307 | "Compute the local time zone for DATE at time SECONDS after midnight. | 303 | "Compute the local time zone for DATE at time SECONDS after midnight. |
diff --git a/lisp/type-break.el b/lisp/type-break.el index f954e5d1c26..a3af407bf17 100644 --- a/lisp/type-break.el +++ b/lisp/type-break.el | |||
| @@ -604,8 +604,7 @@ INTERVAL is the full length of an interval (defaults to TIME)." | |||
| 604 | (type-break-time-warning-schedule time 'reset) | 604 | (type-break-time-warning-schedule time 'reset) |
| 605 | (type-break-run-at-time (max 1 time) nil 'type-break-alarm) | 605 | (type-break-run-at-time (max 1 time) nil 'type-break-alarm) |
| 606 | (setq type-break-time-next-break | 606 | (setq type-break-time-next-break |
| 607 | (type-break-time-sum (or start (current-time)) | 607 | (type-break-time-sum start (or interval time)))) |
| 608 | (or interval time)))) | ||
| 609 | 608 | ||
| 610 | (defun type-break-cancel-schedule () | 609 | (defun type-break-cancel-schedule () |
| 611 | (type-break-cancel-time-warning-schedule) | 610 | (type-break-cancel-time-warning-schedule) |
| @@ -961,19 +960,11 @@ FRAC should be the inverse of the fractional value; for example, a value of | |||
| 961 | (defun type-break-time-difference (a b) | 960 | (defun type-break-time-difference (a b) |
| 962 | (round (float-time (time-subtract b a)))) | 961 | (round (float-time (time-subtract b a)))) |
| 963 | 962 | ||
| 964 | ;; Return (in a new list the same in structure to that returned by | 963 | ;; Return a time value that is the sum of the time-value arguments. |
| 965 | ;; `current-time') the sum of the arguments. Each argument may be a time | ||
| 966 | ;; list or a single integer, a number of seconds. | ||
| 967 | ;; This function keeps the high and low 16 bits of the seconds properly | ||
| 968 | ;; balanced so that the lower value never exceeds 16 bits. Otherwise, when | ||
| 969 | ;; the result is passed to `current-time-string' it will toss some of the | ||
| 970 | ;; "low" bits and format the time incorrectly. | ||
| 971 | (defun type-break-time-sum (&rest tmlist) | 964 | (defun type-break-time-sum (&rest tmlist) |
| 972 | (let ((sum '(0 0 0))) | 965 | (let ((sum '(0 0))) |
| 973 | (dolist (tem tmlist) | 966 | (dolist (tem tmlist) |
| 974 | (setq sum (time-add sum (if (integerp tem) | 967 | (setq sum (time-add sum tem))) |
| 975 | (list (floor tem 65536) (mod tem 65536)) | ||
| 976 | tem)))) | ||
| 977 | sum)) | 968 | sum)) |
| 978 | 969 | ||
| 979 | (defun type-break-time-stamp (&optional when) | 970 | (defun type-break-time-stamp (&optional when) |