Skip to content

Instantly share code, notes, and snippets.

@suhailshergill
Forked from nicferrier/gist:3466870
Created August 25, 2012 15:27
Show Gist options
  • Save suhailshergill/3467113 to your computer and use it in GitHub Desktop.
Save suhailshergill/3467113 to your computer and use it in GitHub Desktop.
converting a bson datetime to an elisp time
(defun bson-datetime-int64-to-time (byte-list)
(let ((calc-num
(concat
"16#"
(mapconcat
(lambda (x) (format "%02X" x))
byte-list ""))))
(list
(calc-eval
"rsh(and(idiv($,1000),16#ffff0000),16)"
'rawnum
calc-num)
(calc-eval
"and(idiv($,1000),16#ffff)"
'rawnum
calc-num))))
(format-time-string
"%D"
(bson-datetime-int64-to-time
(reverse (list #x40 #xa0 #x9f #xc3 #x2c #x01 #x00 #x00))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment