changeset 5220:2157ecaedc1d

Add `float-time', implemented in Lisp. 2010-05-30 Aidan Kehoe <kehoea@parhasard.net> * subr.el (float-time): Add this function, available in editfns.c in GNU.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 30 May 2010 15:14:29 +0100
parents 4f98237e23fc
children ac6846067766
files lisp/ChangeLog lisp/subr.el
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun May 16 12:49:49 2010 +0100
+++ b/lisp/ChangeLog	Sun May 30 15:14:29 2010 +0100
@@ -1,3 +1,8 @@
+2010-05-30  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* subr.el (float-time): Add this function, available in editfns.c
+	in GNU.
+
 2010-05-16  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* files.el (default-file-system-ignore-case):
--- a/lisp/subr.el	Sun May 16 12:49:49 2010 +0100
+++ b/lisp/subr.el	Sun May 30 15:14:29 2010 +0100
@@ -1794,4 +1794,23 @@
   "Return t if (cdr A) is numerically less than (cdr B)."
   (< (cdr a) (cdr b)))
 
+;; XEmacs; this is in editfns.c in GNU.
+(defun float-time (&optional specified-time)
+  "Convert time value SPECIFIED-TIME to a floating point number.
+
+See `current-time'.  Since the result is a floating-point number, this may
+not have the same accuracy as does the result of `current-time'.
+
+If not supplied, SPECIFIED-TIME defaults to the result of `current-time'."
+  (or specified-time (setq specified-time (current-time)))
+  (+ (* (pop specified-time) (+ #x10000 0.0))
+     (if (consp specified-time)
+	 (pop specified-time)
+       (prog1
+	   specified-time
+	 (setq specified-time nil)))
+     (or (and specified-time
+	      (/ (car specified-time) 1000000.0))
+	 0.0)))
+
 ;;; subr.el ends here