Fix precision error in `db/ntp-to-time'
A curcial step in the conversion, namly the computation of the actual time from the seconds since the epoch, had been conducted with too little precision. Now the precision is fixed to a high value throughout the whole computation, and the tests succeed again.
This commit is contained in:
parent
b5ed51d8e8
commit
f1932e7032
|
@ -15,6 +15,10 @@
|
||||||
(should (equal (db/ntp-to-time #xbd5927ee #xbc616000)
|
(should (equal (db/ntp-to-time #xbd5927ee #xbc616000)
|
||||||
"2000-08-31T18:52:30.735860824Z"))
|
"2000-08-31T18:52:30.735860824Z"))
|
||||||
(should (equal (db/ntp-to-time #x00000000 #x0000000)
|
(should (equal (db/ntp-to-time #x00000000 #x0000000)
|
||||||
"1900-01-01T00:00:00.000000000Z")))
|
"1900-01-01T00:00:00.000000000Z"))
|
||||||
|
(should (equal (db/ntp-to-time #xd36968b7 #xe74172bf)
|
||||||
|
"2012-05-25T02:11:03.903342410Z"))
|
||||||
|
(should (equal (db/ntp-to-time #xe2a16f23 #x80270e76)
|
||||||
|
"2020-06-27T07:09:23.500595954Z")))
|
||||||
|
|
||||||
;;; db-utils-test.el ends here
|
;;; db-utils-test.el ends here
|
||||||
|
|
|
@ -16,16 +16,12 @@
|
||||||
(require 'term)
|
(require 'term)
|
||||||
(require 'nsm)
|
(require 'nsm)
|
||||||
(require 'compile)
|
(require 'compile)
|
||||||
|
(require 'calc)
|
||||||
|
(require 'calc-forms)
|
||||||
|
|
||||||
(autoload 'async-start "async")
|
(autoload 'async-start "async")
|
||||||
(autoload 'lispy-mode "lispy")
|
(autoload 'lispy-mode "lispy")
|
||||||
(autoload 'ldap-search "ldap")
|
(autoload 'ldap-search "ldap")
|
||||||
(autoload 'calcFunc-unixtime "calc-forms")
|
|
||||||
(autoload 'calcFunc-year "calc-forms")
|
|
||||||
(autoload 'calcFunc-month "calc-forms")
|
|
||||||
(autoload 'calcFunc-day "calc-forms")
|
|
||||||
(autoload 'calcFunc-hour "calc-forms")
|
|
||||||
(autoload 'calcFunc-minute "calc-forms")
|
|
||||||
|
|
||||||
|
|
||||||
;;; Application Shortcuts
|
;;; Application Shortcuts
|
||||||
|
@ -198,7 +194,8 @@ FORMAT-STRING defaults to some ISO 8601-like format."
|
||||||
(string-to-number input-proper 16)))))
|
(string-to-number input-proper 16)))))
|
||||||
(list (read-hex "High (hex): ")
|
(list (read-hex "High (hex): ")
|
||||||
(read-hex "Low (hex): "))))
|
(read-hex "Low (hex): "))))
|
||||||
(let* ((unix-time (calcFunc-unixtime (calc-eval (format "%s - 2208988800 + (%s/4294967296)" high low)
|
(let* ((calc-internal-prec 30)
|
||||||
|
(unix-time (calcFunc-unixtime (calc-eval (format "%s - 2208988800 + (%s/4294967296)" high low)
|
||||||
'raw)
|
'raw)
|
||||||
;; we explicitly call `calcFunc-unixtime'
|
;; we explicitly call `calcFunc-unixtime'
|
||||||
;; here to set the time zone to UTC
|
;; here to set the time zone to UTC
|
||||||
|
@ -216,8 +213,7 @@ FORMAT-STRING defaults to some ISO 8601-like format."
|
||||||
;; is what has been done in the test example we use in the
|
;; is what has been done in the test example we use in the
|
||||||
;; corresponding regression test …
|
;; corresponding regression test …
|
||||||
(string-to-number
|
(string-to-number
|
||||||
(calc-eval '("trunc(second($), 9)" calc-internal-prec 30)
|
(calc-eval "trunc(second($), 9)" 'num unix-time)))))
|
||||||
'num unix-time)))))
|
|
||||||
|
|
||||||
(defun conditionally-enable-lispy ()
|
(defun conditionally-enable-lispy ()
|
||||||
"Enable lispy-mode when in `eval-expression’ or in
|
"Enable lispy-mode when in `eval-expression’ or in
|
||||||
|
|
Loading…
Reference in New Issue