# HG changeset patch # User Aidan Kehoe # Date 1275228869 -3600 # Node ID 2157ecaedc1dc4a6ae53954fd1f732b66b7b104f # Parent 4f98237e23fcbfd1e9edb89cb90373d24dcae5f8 Add `float-time', implemented in Lisp. 2010-05-30 Aidan Kehoe * subr.el (float-time): Add this function, available in editfns.c in GNU. diff -r 4f98237e23fc -r 2157ecaedc1d lisp/ChangeLog --- 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 + + * subr.el (float-time): Add this function, available in editfns.c + in GNU. + 2010-05-16 Aidan Kehoe * files.el (default-file-system-ignore-case): diff -r 4f98237e23fc -r 2157ecaedc1d lisp/subr.el --- 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