* Current time as floating point number
@ 2005-10-18 13:45 Hrvoje Niksic
2005-10-19 2:43 ` Richard M. Stallman
0 siblings, 1 reply; 3+ messages in thread
From: Hrvoje Niksic @ 2005-10-18 13:45 UTC (permalink / raw)
For a while now I've been using the following function:
(defun current-time-as-float ()
(let ((tm (current-time)))
(+
(* 65536.0 (nth 0 tm))
(nth 1 tm)
(/ (nth 2 tm) 1000000.0))))
(current-time-as-float)
--> 1129642168.966545
It returns the current time as a single floating-point number. I find
it very convenient because its return value can be manipulated with
normal arithmetic functions, such as subtraction. This is useful for
measuring of passage of time, as well as for recording time stamps.
The truncated value can also be passed to external code that expects
the Unix-style number of seconds since Epoch.
While the above function wasn't hard to write for me, it probably
would be for a beginner. I'm not proposing that you include the above
function as-is, but such functionality in some form, either as
an optional argument to current-time, or as a separate (more
aptly-named) function would be useful.
Later, functions like format-time-string could start accepting such
floating-point arguments as well.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Current time as floating point number
2005-10-18 13:45 Current time as floating point number Hrvoje Niksic
@ 2005-10-19 2:43 ` Richard M. Stallman
2005-10-19 8:02 ` Hrvoje Niksic
0 siblings, 1 reply; 3+ messages in thread
From: Richard M. Stallman @ 2005-10-19 2:43 UTC (permalink / raw)
Cc: emacs-devel
Isn't float-time what you want?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Current time as floating point number
2005-10-19 2:43 ` Richard M. Stallman
@ 2005-10-19 8:02 ` Hrvoje Niksic
0 siblings, 0 replies; 3+ messages in thread
From: Hrvoje Niksic @ 2005-10-19 8:02 UTC (permalink / raw)
Cc: emacs-devel
"Richard M. Stallman" <rms@gnu.org> writes:
> Isn't float-time what you want?
It is, thanks. Sorry about the noise.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-10-19 8:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-18 13:45 Current time as floating point number Hrvoje Niksic
2005-10-19 2:43 ` Richard M. Stallman
2005-10-19 8:02 ` Hrvoje Niksic
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).