Commit 89c63b35 authored by Paul Eggert's avatar Paul Eggert

New function time-convert

This replaces the awkward reuse of encode-time to both convert
calendrical timestamps to Lisp timestamps, and to convert Lisp
timestamps to other forms.  Now, encode-time does just the
former and the new function does just the latter.
The new function builds on a suggestion by Lars Ingebrigtsen in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html
and refined by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html
* doc/lispref/os.texi (Time of Day, Time Conversion):
* doc/misc/emacs-mime.texi (time-date):
* etc/NEWS: Update documentation.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-add-item):
* lisp/emacs-lisp/cl-extra.el (cl--random-time):
* lisp/emacs-lisp/timer.el (timer--time-setter)
(timer-next-integral-multiple-of-time):
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-diary.el (gnus-user-format-function-d):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
* lisp/gnus/nnrss.el (nnrss-normalize-date):
* lisp/gnus/nnspool.el (nnspool-request-newgroups):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/net/pop3.el (pop3-uidl-dele):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-clock-in)
(org-clock-out, org-clock-sum):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cc-cmds.el (c-progress-init)
(c-progress-update):
* lisp/progmodes/cperl-mode.el (cperl-time-fontification):
* lisp/progmodes/flymake.el (flymake--schedule-timer-maybe):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
* lisp/tar-mode.el (tar-octal-time):
* lisp/time.el (emacs-uptime):
* lisp/url/url-auth.el (url-digest-auth-make-cnonce):
* lisp/url/url-util.el (url-lazy-message):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg-state-fast):
* lisp/xt-mouse.el (xterm-mouse-event):
* test/lisp/emacs-lisp/timer-tests.el:
(timer-next-integral-multiple-of-time-2):
Use time-convert, not encode-time.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Don’t use now-removed FORM argument for encode-time.
It wasn’t crucial anyway.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert.
* lisp/emacs-lisp/elint.el (elint-unknown-builtin-args):
Update encode-time signature to match current arg set.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Use timer-convert with t rather than doing it by hand.
* src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp):
Remove; no longer needed.
(decode_lisp_time): Rturn the form instead of having a *PFORM arg.
All uses changed.
(time_arith): Just return TICKS if HZ is 1.
(Fencode_time): Remove argument FORM.  All callers changed.
Do not attempt to encode time values; just encode
decoded (calendrical) times.
Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1.
(Ftime_convert): New function, which does the time value
conversion that bleeding-edge encode-time formerly did.
Return TIME if it is easy to see that it is already
of the correct form.
(Fcurrent_time): Mention in doc that the form is planned to change.
* test/src/timefns-tests.el (decode-then-encode-time):
Don’t use (encode-time nil).
parent c6ba8100
......@@ -1536,10 +1536,8 @@ Operating System Interface
* System Environment:: Distinguish the name and kind of system.
* User Identification:: Finding the name and user id of the user.
* Time of Day:: Getting the current time.
* Time Conversion:: Converting a time from numeric form to
calendrical data and vice versa.
* Time Parsing:: Converting a time from numeric form to text
and vice versa.
* Time Conversion:: Converting among timestamp forms.
* Time Parsing:: Converting timestamps to text and vice versa.
* Processor Run Time:: Getting the run time used by Emacs.
* Time Calculations:: Adding, subtracting, comparing times, etc.
* Timers:: Setting a timer to call a function at a
......
......@@ -20,10 +20,8 @@ terminal and the screen.
* User Identification:: Finding the name and user id of the user.
* Time of Day:: Getting the current time.
* Time Zone Rules:: Rules for time zones and daylight saving time.
* Time Conversion:: Converting a time from numeric form to
calendrical data and vice versa.
* Time Parsing:: Converting a time from numeric form to text
and vice versa.
* Time Conversion:: Converting among timestamp forms.
* Time Parsing:: Converting timestamps to text and vice versa.
* Processor Run Time:: Getting the run time used by Emacs.
* Time Calculations:: Adding, subtracting, comparing times, etc.
* Timers:: Setting a timer to call a function at a certain time.
......@@ -1253,7 +1251,7 @@ represent absolute time by counting seconds since the @dfn{epoch} of
Although traditionally Lisp timestamps were integer pairs, their
form has evolved and programs ordinarily should not depend on the
current default form. If your program needs a particular timestamp
form, you can use the @code{encode-time} function to convert it to the
form, you can use the @code{time-convert} function to convert it to the
needed form. @xref{Time Conversion}.
@cindex epoch
......@@ -1304,7 +1302,7 @@ time, a single floating-point number for seconds, or a list
@var{low})} that is a truncated list timestamp with missing elements
taken to be zero. You can convert a time value into
a human-readable string using @code{format-time-string}, into a Lisp
timestamp using @code{encode-time}, and into other forms using
timestamp using @code{time-convert}, and into other forms using
@code{decode-time} and @code{float-time}. These functions are
described in the following sections.
......@@ -1334,6 +1332,11 @@ defaults to the current time zone rule. @xref{Time Zone Rules}.
@defun current-time
This function returns the current time as a Lisp timestamp.
Although the timestamp takes the form @code{(@var{high} @var{low}
@var{micro} @var{pico})} in the current Emacs release, this is
planned to change in a future Emacs version. You can use the
@code{time-convert} function to convert a timestamp to some other
form. @xref{Time Conversion}.
@end defun
@defun float-time &optional time
......@@ -1411,8 +1414,8 @@ defaults to the current time zone rule.
@cindex calendrical information
@cindex time conversion
These functions convert time values (@pxref{Time of Day}) into
calendrical information and vice versa.
These functions convert time values (@pxref{Time of Day}) to Lisp
timestamps, or into calendrical information and vice versa.
Many 32-bit operating systems are limited to system times containing
32 bits of information in their seconds component; these systems
......@@ -1421,12 +1424,60 @@ typically handle only the times from 1901-12-13 20:45:52 through
systems have larger seconds components, and can represent times far in
the past or future.
Time conversion functions always use the Gregorian calendar, even
Calendrical conversion functions always use the Gregorian calendar, even
for dates before the Gregorian calendar was introduced. Year numbers
count the number of years since the year 1 B.C., and do not skip zero
as traditional Gregorian years do; for example, the year number
@minus{}37 represents the Gregorian year 38 B.C@.
@defun time-convert time &optional form
This function converts a time value into a Lisp timestamp.
If the time cannot be represented exactly, it is truncated
toward minus infinity.
The optional @var{form} argument specifies the timestamp form to be
returned. If @var{form} is the symbol @code{integer}, this function
returns an integer count of seconds. If @var{form} is a positive
integer, it specifies a clock frequency and this function returns an
integer-pair timestamp @code{(@var{ticks}
. @var{form})}.@footnote{Currently a positive integer @var{form}
should be at least 65536 if the returned value is intended to be given
to standard functions expecting Lisp timestamps.} If @var{form} is
@code{t}, this function treats it as a positive integer suitable for
representing the timestamp; for example, it is treated as 1000000000
if @var{time} is nil and the platform timestamp has nanosecond
resolution. If @var{form} is @code{list}, this function returns an
integer list @code{(@var{high} @var{low} @var{micro} @var{pico})}.
Although an omitted or @code{nil} @var{form} currently acts like
@code{list}, this is planned to change in a future Emacs version, so
callers requiring list timestamps should pass @code{list} explicitly.
If @var{time} already has the proper form, this function might yield
@var{time} rather than a copy.
Although @code{(time-convert nil nil)} is equivalent to
@code{(current-time)}, the latter may be a bit faster.
@example
@group
(setq a (time-convert nil t))
@result{} (1564826753904873156 . 1000000000)
@end group
@group
(time-convert a 100000)
@result{} (156482675390487 . 100000)
@end group
@group
(time-convert a 'integer)
@result{} 1564826753
@end group
@group
(time-convert a 'list)
@result{} (23877 23681 904873 156000)
@end group
@end example
@end defun
@defun decode-time &optional time zone
This function converts a time value into calendrical information. If
you don't specify @var{time}, it decodes the current time, and similarly
......@@ -1522,37 +1573,17 @@ that represents ``two months'', you could say:
@end lisp
@end defun
@defun encode-time &optional time form &rest obsolescent-arguments
@defun encode-time time &rest obsolescent-arguments
This function converts @var{time} to a Lisp timestamp.
It can act as the inverse of @code{decode-time}.
The first argument can be a time value such as a number of seconds, a
pair @code{(@var{ticks} . @var{hz})}, a list @code{(@var{high}
@var{low} @var{micro} @var{pico})}, or @code{nil} (the default) for
the current time (@pxref{Time of Day}). It can also be a list
Ordinarily the first argument is a list
@code{(@var{second} @var{minute} @var{hour} @var{day} @var{month}
@var{year} @var{ignored} @var{dst} @var{zone})} that specifies a
decoded time in the style of @code{decode-time}, so that
@code{(encode-time (decode-time ...))} works. For the meanings of
these list members, see the table under @code{decode-time}.
The optional @var{form} argument specifies the desired timestamp form
to be returned. If @var{form} is the symbol @code{integer}, this
function returns an integer count of seconds. If @var{form} is a
positive integer, it specifies a clock frequency and this function
returns an integer-pair timestamp @code{(@var{ticks}
. @var{form})}.@footnote{Currently a positive integer @var{form}
should be at least 65536 if the returned value is intended to be given
to standard functions expecting Lisp timestamps.} If @var{form} is
@code{t}, this function treats it as a positive integer suitable for
representing the timestamp; for example, it is treated as 1000000000
if the platform timestamp has nanosecond resolution. If @var{form} is
@code{list}, this function returns an integer list @code{(@var{high}
@var{low} @var{micro} @var{pico})}. Although an omitted or @code{nil}
@var{form} currently acts like @code{list}, this is planned to change
in a future Emacs version, so callers requiring list timestamps should
pass @code{list} explicitly.
As an obsolescent calling convention, this function can be given six
or more arguments. The first six arguments @var{second},
@var{minute}, @var{hour}, @var{day}, @var{month}, and @var{year}
......
......@@ -1537,24 +1537,25 @@ Here's a bunch of time/date/second/day examples:
(parse-time-string "Sat Sep 12 12:21:54 1998 +0200")
@result{} (54 21 12 12 9 1998 6 -1 7200)
(encode-time (date-to-time "Sat Sep 12 12:21:54 1998 +0200")
1000000)
@result{} (905595714000000 . 1000000)
(time-convert
(date-to-time "Sat Sep 12 12:21:54 1998 +0200")
'integer)
@result{} 905595714
(float-time '(905595714000000 . 1000000))
@result{} 905595714.0
(encode-time 905595714.0 1000000)
(time-convert 905595714.0 1000000)
@result{} (905595714000000 . 1000000)
(time-to-days '(905595714000000 . 1000000))
@result{} 729644
(encode-time (days-to-time 729644) 1000000)
@result{} (63041241600000000 . 1000000)
(time-convert (days-to-time 729644) 'integer)
@result{} 63041241600
(encode-time (time-since '(905595714000000 . 1000000))
1000000)
(time-convert (time-since '(905595714000000 . 1000000))
1000000)
@result{} (631963244775642171 . 1000000000)
(time-less-p '(905595714000000 . 1000000)
......@@ -1622,12 +1623,14 @@ These are the functions available:
@item date-to-time
Take a date and return a time.
@item time-convert
Take a time and return a timestamp in a specified form.
@item float-time
Take a time and return seconds.
@item encode-time
Take seconds (and other ways to represent time, notably decoded time
lists), and return a time.
Take a decoded time and return a timestamp.
@item time-to-days
Take a time and return days.
......
......@@ -2077,21 +2077,24 @@ functions like 'process-id' that compute process IDs, and functions like
** Time values
+++
*** New function time 'time-convert' converts Lisp time values
to Lisp timestamps of various forms, including a new timestamp form
(TICKS . HZ) where TICKS is an integer and HZ a positive integer
denoting a clock frequency.
+++
*** Although the default timestamp format is still '(HI LO US PS)',
it is planned to change in a future Emacs version, to exploit bignums.
The documentation has been updated to mention that the timestamp
format may change and that programs should use functions like
'format-time-string', 'decode-time', and 'encode-time' rather than
'format-time-string', 'decode-time', and 'time-convert' rather than
probing the innards of a timestamp directly, or creating a timestamp
by hand.
+++
*** 'encode-time' supports a new API '(encode-time TIME &optional FORM)'.
This can convert decoded times and Lisp time values to Lisp timestamps
of various forms, including a new timestamp form '(TICKS . HZ)', where
TICKS is an integer and HZ is a positive integer denoting a clock
frequency. The old 'encode-time' API is still supported.
*** 'encode-time' supports a new API '(encode-time TIME)'.
The old 'encode-time' API is still supported.
+++
*** A new package to parse ISO 8601 time, date, durations and
......
......@@ -127,7 +127,7 @@ after midnight UTC on absolute date ABS-DATE."
"Return the time of the next time zone transition after TIME.
Both TIME and the result are acceptable arguments to `current-time-zone'.
Return nil if no such transition can be found."
(let* ((time (encode-time time 'integer))
(let* ((time (time-convert time 'integer))
(time-zone (current-time-zone time))
(time-utc-diff (car time-zone))
hi
......
......@@ -646,7 +646,7 @@ FIXME: multiple comma-separated values should be allowed!"
(let ((decoded-time (list second minute hour day month year
nil -1 zone)))
(condition-case nil
(decode-time (encode-time decoded-time 'integer))
(decode-time (encode-time decoded-time))
(error
(message "Cannot decode \"%s\"" isodatetimestring)
;; Hope for the best....
......
......@@ -171,14 +171,14 @@ If DATE lacks timezone information, GMT is assumed."
(defalias 'time-to-seconds 'float-time)
;;;###autoload
(defalias 'seconds-to-time 'encode-time)
(defalias 'seconds-to-time 'time-convert)
;;;###autoload
(defun days-to-time (days)
"Convert DAYS into a time value."
(let ((time (encode-time (* 86400 days))))
(let ((time (time-convert (* 86400 days))))
;; Traditionally, this returned a two-element list if DAYS was an integer.
;; Keep that tradition if encode-time outputs timestamps in list form.
;; Keep that tradition if time-convert outputs timestamps in list form.
(if (and (integerp days) (consp (cdr time)))
(setcdr (cdr time) nil))
time))
......
......@@ -515,7 +515,7 @@ non-nil, the amount returned will be relative to past time worked."
string)))
(define-obsolete-function-alias 'timeclock-time-to-seconds 'float-time "26.1")
(define-obsolete-function-alias 'timeclock-seconds-to-time 'encode-time "26.1")
(define-obsolete-function-alias 'timeclock-seconds-to-time 'time-convert "26.1")
;; Should today-only be removed in favor of timeclock-relative? - gm
(defsubst timeclock-when-to-leave (&optional today-only)
......
......@@ -200,7 +200,7 @@ Return a cons cell:
(ans (ede-detect-directory-for-project default-directory)))
(if ans
(message "Project found in %d sec @ %s of type %s"
(encode-time (time-since start) 'integer)
(time-convert (time-since start) 'integer)
(car ans)
(eieio-object-name-string (cdr ans)))
(message "No Project found.") )))
......
......@@ -432,7 +432,7 @@ Used to decide whether to save completions.")
(defun cmpl-hours-since-origin ()
(floor (encode-time nil 'integer) 3600))
(floor (time-convert nil 'integer) 3600))
;;---------------------------------------------------------------------------
;; "Symbol" parsing functions
......
......@@ -96,7 +96,7 @@ string that was matched."
(defun ecomplete-add-item (type key text)
"Add item TEXT of TYPE to the database, using KEY as the identifier."
(let ((elems (assq type ecomplete-database))
(now (encode-time nil 'integer))
(now (time-convert nil 'integer))
entry)
(unless elems
(push (setq elems (list type)) ecomplete-database))
......
......@@ -1234,7 +1234,7 @@
symbol-function symbol-name symbol-plist symbol-value string-make-unibyte
string-make-multibyte string-as-multibyte string-as-unibyte
string-to-multibyte
tan truncate
tan time-convert truncate
unibyte-char-to-multibyte upcase user-full-name
user-login-name user-original-login-name custom-variable-p
vconcat
......
......@@ -437,7 +437,7 @@ as an integer unless JUNK-ALLOWED is non-nil."
;; Random numbers.
(defun cl--random-time ()
(car (encode-time nil t)))
(car (time-convert nil t)))
;;;###autoload (autoload 'cl-random-state-p "cl-extra")
(cl-defstruct (cl--random-state
......
......@@ -141,7 +141,7 @@ Set by `elint-initialize', if `elint-scan-preloaded' is non-nil.")
(defconst elint-unknown-builtin-args
;; encode-time allows extra arguments for use with decode-time.
;; For some reason, some people seem to like to use them in other cases.
'((encode-time second minute hour day month year &rest zone))
'((encode-time time &rest obsolescent-arguments))
"Those built-ins for which we can't find arguments, if any.")
(defvar elint-extra-errors '(file-locked file-supersession ftp-error)
......
......@@ -57,7 +57,7 @@
(defun timer--time-setter (timer time)
(timer--check timer)
(let ((lt (encode-time time 'list)))
(let ((lt (time-convert time 'list)))
(setf (timer--high-seconds timer) (nth 0 lt))
(setf (timer--low-seconds timer) (nth 1 lt))
(setf (timer--usecs timer) (nth 2 lt))
......@@ -96,10 +96,7 @@ fire each time Emacs is idle for that many seconds."
"Yield the next value after TIME that is an integral multiple of SECS.
More precisely, the next value, after TIME, that is an integral multiple
of SECS seconds since the epoch. SECS may be a fraction."
(let* ((ticks-hz (if (and (consp time) (integerp (car time))
(integerp (cdr time)) (< 0 (cdr time)))
time
(encode-time time 1000000000000)))
(let* ((ticks-hz (time-convert time t))
(ticks (car ticks-hz))
(hz (cdr ticks-hz))
trunc-s-ticks)
......@@ -109,7 +106,7 @@ of SECS seconds since the epoch. SECS may be a fraction."
(setq ticks (ash ticks 1))
(setq hz (ash hz 1)))
(let ((more-ticks (+ ticks trunc-s-ticks)))
(encode-time (cons (- more-ticks (% more-ticks trunc-s-ticks)) hz)))))
(time-convert (cons (- more-ticks (% more-ticks trunc-s-ticks)) hz)))))
(defun timer-relative-time (time secs &optional usecs psecs)
"Advance TIME by SECS seconds and optionally USECS microseconds
......
......@@ -342,7 +342,7 @@ list of ls option letters of which c and u are recognized). Use
the same method as \"ls\" to decide whether to show time-of-day or
year, depending on distance between file date and NOW."
(let* ((time (nth (find-lisp-time-index switches) file-attr))
(diff (encode-time (time-subtract time now) 'integer))
(diff (time-convert (time-subtract time now) 'integer))
(past-cutoff -15778476) ; 1/2 of a Gregorian year
(future-cutoff (* 60 60))) ; 1 hour
(format-time-string
......
......@@ -161,7 +161,7 @@ There are currently two built-in format functions:
(now (current-time))
(occur (nndiary-next-occurrence sched now))
(real-time (time-subtract occur now)))
(let* ((sec (encode-time real-time 'integer))
(let* ((sec (time-convert real-time 'integer))
(past (< sec 0))
delay)
(and past (setq sec (- sec)))
......
......@@ -4533,7 +4533,7 @@ and the second element is the address."
This function can be used in hooks like `gnus-select-group-hook'
or `gnus-group-catchup-group-hook'."
(when gnus-newsgroup-name
(let ((time (encode-time nil 'integer)))
(let ((time (time-convert nil 'integer)))
(gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
(defsubst gnus-group-timestamp (group)
......
......@@ -650,7 +650,7 @@ is searched."
(defun gnus-icalendar-show-org-agenda (event)
(let* ((time-delta (time-subtract (gnus-icalendar-event:end-time event)
(gnus-icalendar-event:start-time event)))
(duration-days (1+ (floor (encode-time time-delta 'integer) 86400))))
(duration-days (1+ (floor (time-convert time-delta 'integer) 86400))))
(org-agenda-list nil (gnus-icalendar-event:start event) duration-days)))
(cl-defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-request) reply-status)
......
......@@ -455,7 +455,7 @@ which RSS 2.0 allows."
(cond ((null date)) ; do nothing for this case
;; if the date is just digits (unix time stamp):
((string-match "^[0-9]+$" date)
(setq given (encode-time (string-to-number date))))
(setq given (time-convert (string-to-number date))))
;; RFC 822
((string-match " [0-9]+ " date)
(setq vector (timezone-parse-date date)
......
......@@ -305,7 +305,7 @@ there.")
(while (and (not (looking-at
"\\([^ ]+\\) +\\([0-9]+\\)[0-9][0-9][0-9] "))
(zerop (forward-line -1))))
(let ((seconds (encode-time (date-to-time date) 'integer))
(let ((seconds (time-convert (date-to-time date) 'integer))
groups)
;; Go through lines and add the latest groups to a list.
(while (and (looking-at "\\([^ ]+\\) +[0-9]+ ")
......
......@@ -151,7 +151,7 @@ signed integer."
;; tenths of microseconds between
;; 1601-01-01 and 1970-01-01
"116444736000000000)")
'rawnum (encode-time nil 'list)))
'rawnum (time-convert nil 'list)))
result-bytes)
(dotimes (_byte 8)
(push (calc-eval "and($1,16#FF)" 'rawnum tenths-of-us-since-jan-1-1601)
......
......@@ -379,7 +379,7 @@ Use streaming commands."
(defun pop3-uidl-dele (process)
"Delete messages according to `pop3-leave-mail-on-server'.
Return non-nil if it is necessary to update the local UIDL file."
(let* ((ctime (encode-time nil 'list))
(let* ((ctime (time-convert nil 'list))
(age-limit (and (numberp pop3-leave-mail-on-server)
(* 86400 pop3-leave-mail-on-server)))
(srvr (assoc pop3-mailhost pop3-uidl-saved))
......
......@@ -133,7 +133,7 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
(file-error (insert (format "%s <%s> %s"
(current-time-string)
user-mail-address
(+ (% (car (encode-time nil 1000000))
(+ (% (car (time-convert nil 1000000))
1000000)
(buffer-size)))))))
(comment-region beg (point))))
......
......@@ -723,7 +723,7 @@ menu\nmouse-2 will jump to task"))
The time returned includes the time spent on this task in
previous clocking intervals."
(let ((currently-clocked-time
(floor (encode-time (time-since org-clock-start-time) 'integer)
(floor (time-convert (time-since org-clock-start-time) 'integer)
60)))
(+ currently-clocked-time (or org-clock-total-time 0))))
......@@ -1033,7 +1033,7 @@ to be CLOCKED OUT."))))
nil 45)))
(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
(default
(floor (encode-time (time-since last-valid) 'integer)
(floor (time-convert (time-since last-valid) 'integer)
60))
(keep
(and (memq ch '(?k ?K))
......@@ -1102,8 +1102,8 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
(lambda (clock)
(format
"Dangling clock started %d mins ago"
(floor (encode-time (time-since (cdr clock))
'integer)
(floor (time-convert (time-since (cdr clock))
'integer)
60)))))
(or last-valid
(cdr clock)))))))))))
......@@ -1321,7 +1321,7 @@ the default behavior."
(y-or-n-p
(format
"You stopped another clock %d mins ago; start this one from then? "
(/ (encode-time
(/ (time-convert
(time-subtract
(org-current-time org-clock-rounding-minutes t)
leftover)
......@@ -1576,10 +1576,10 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
(delete-region (point) (point-at-eol))
(insert "--")
(setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
(setq s (encode-time (time-subtract
(org-time-string-to-time te)
(org-time-string-to-time ts))
'integer)
(setq s (time-convert (time-subtract
(org-time-string-to-time te)
(org-time-string-to-time ts))
'integer)
h (floor s 3600)
m (floor (mod s 3600) 60))
(insert " => " (format "%2d:%02d" h m))
......@@ -1833,7 +1833,7 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
tend
(>= (float-time org-clock-start-time) tstart)
(<= (float-time org-clock-start-time) tend))
(let ((time (floor (encode-time
(let ((time (floor (time-convert
(time-since org-clock-start-time)
'integer)
60)))
......
......@@ -356,7 +356,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
"Return string with random (version 4) UUID."
(let ((rnd (md5 (format "%s%s%s%s%s%s%s"
(random)
(encode-time nil 'list)
(time-convert nil 'list)
(user-uid)
(emacs-pid)
(user-full-name)
......@@ -418,7 +418,7 @@ using `org-id-decode'."
;; FIXME: If TIME represents N seconds after the epoch, then
;; this encoding assumes 0 <= N < 110075314176 = (* (expt 36 4) 65536),
;; i.e., that TIME is from 1970-01-01 00:00:00 to 5458-02-23 20:09:36 UTC.
(setq time (encode-time time 'list))
(setq time (time-convert time 'list))
(concat (org-id-int-to-b36 (nth 0 time) 4)
(org-id-int-to-b36 (nth 1 time) 4)
(org-id-int-to-b36 (nth 2 time) 4)))
......
......@@ -1348,7 +1348,7 @@ does not exist."
(expand-file-name (or (file-symlink-p file) file)
(file-name-directory file)))))
(if (not attr) (error "No such file: \"%s\"" file)
(encode-time (file-attribute-modification-time attr) 'integer))))
(time-convert (file-attribute-modification-time attr) 'integer))))
(provide 'ox-publish)
......
......@@ -1348,7 +1348,7 @@ Prefix ARG controls sort order, see `proced-sort-interactive'."
(defun proced-format-time (time)
"Format time interval TIME."
(let* ((ftime (encode-time time 'integer))
(let* ((ftime (time-convert time 'integer))
(days (truncate ftime 86400))
(ftime (mod ftime 86400))
(hours (truncate ftime 3600))
......
......@@ -3611,7 +3611,7 @@ Otherwise reindent just the current line."
(save-excursion
(goto-char end)
(point-marker))
(encode-time nil 'integer)
(time-convert nil 'integer)
context))
(message "Indenting region..."))
))
......@@ -3619,7 +3619,7 @@ Otherwise reindent just the current line."
(defun c-progress-update ()
(if (not (and c-progress-info c-progress-interval))
nil
(let ((now (encode-time nil 'integer))
(let ((now (time-convert nil 'integer))
(start (aref c-progress-info 0))
(end (aref c-progress-info 1))
(lastsecs (aref c-progress-info 2)))
......
......@@ -8600,7 +8600,7 @@ start with default arguments, then refine the slowdown regions."
(or l (setq l 1))
(or step (setq step 500))
(or lim (setq lim 40))
(let* ((timems (function (lambda () (car (encode-time nil 1000)))))
(let* ((timems (function (lambda () (car (time-convert nil 1000)))))
(tt (funcall timems)) (c 0) delta tot)
(goto-char (point-min))
(forward-line (1- l))
......
......@@ -1022,7 +1022,7 @@ Do it only if `flymake-no-changes-timeout' is non-nil."
(setq
flymake-timer
(run-with-idle-timer
;; This can use encode-time instead of seconds-to-time,
;; This can use time-convert instead of seconds-to-time,
;; once we can assume Emacs 27 or later.
(seconds-to-time flymake-no-changes-timeout)
nil
......
......@@ -7403,7 +7403,7 @@ only-lines."
100
(floor (* 100.0 (- pos (aref vhdl-progress-info 0)))
delta))))
(aset vhdl-progress-info 2 (encode-time nil 'integer))))
(aset vhdl-progress-info 2 (time-convert nil 'integer))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Indentation commands
......@@ -8149,7 +8149,7 @@ depending on parameter UPPER-CASE."
(message "Fixing case... (%2d%s)"
(+ (* count 20) (/ (* 20 (- (point) beg)) (- end beg)))
"%")
(setq last-update (encode-time nil 'integer))))
(setq last-update (time-convert nil 'integer))))
(goto-char end)))))
(defun vhdl-fix-case-region (beg end &optional arg)
......
......@@ -1271,7 +1271,7 @@ for this to be permanent."
(defun tar-octal-time (timeval)
;; Format a timestamp as 11 octal digits.
(format "%011o" (encode-time timeval 'integer)))
(format "%011o" (time-convert timeval 'integer)))
(defun tar-subfile-save-buffer ()
"In tar subfile mode, save this buffer into its parent tar-file buffer.
......
......@@ -572,7 +572,7 @@ For example, the Unix uptime command format is \"%D, %z%2h:%.2m\"."
(interactive)
(let ((str
(