emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/caml 353edf8: Port caml-types-time to future Emacs


From: Paul Eggert
Subject: [nongnu] elpa/caml 353edf8: Port caml-types-time to future Emacs
Date: Wed, 15 Dec 2021 13:11:11 -0500 (EST)

branch: elpa/caml
commit 353edf8e0d59f025f1da00da34266a4e4642c21f
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Port caml-types-time to future Emacs
    
    * caml-types.el (caml-types-time):
    Do not assume Emacs timestamp format, which is slated to change in
    future versions.  Instead, use time-convert to convert to milliseconds
    since the epoch modulo 1000000.  This is simpler and less glitchy than
    the old version anyway (millseconds since the epoch modulo 1000, plus
    1000 times seconds since the epoch modulo 65536 modulo 1000).
    This code uses fboundp to be portable to Emacs 26 and earlier,
    and can be simplified once we can assume Emacs 27.
---
 caml-types.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/caml-types.el b/caml-types.el
index c7c91a0..c03a72c 100644
--- a/caml-types.el
+++ b/caml-types.el
@@ -595,9 +595,11 @@ corresponding .annot file."
   nil)
 
 (defun caml-types-time ()
-  (let ((time (current-time)))
+  (if (fboundp 'time-convert)
+      (mod (car (time-convert nil 1000)) 1000000)
+    (let ((time (current-time)))
      (+ (* (mod (cadr time) 1000) 1000)
-                  (/ (cadr (cdr time)) 1000))))
+                  (/ (cadr (cdr time)) 1000)))))
 
 (defun caml--release-event-p (original event)
   (and (equal (event-basic-type original) (event-basic-type event))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]