Skip to content

Commit

Permalink
Use erlang:system_time/1 on OTP 18+
Browse files Browse the repository at this point in the history
  • Loading branch information
yurrriq committed Oct 31, 2016
1 parent 96f58b8 commit 3f19fda
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/levaindoc-util.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
;; Conversions
(export (input-formats 0) (output-formats 0))
;; Random filename
(export (random-name 0)))
(export (random-name 0))
(import (rename erlang ((function_exported 3) exported?))))

;;; ================================================================= [ Macros ]

(defmacro timestamp ()
"Return the current timestamp, as a string."
`(integer_to_list
,(if (erlang:function_exported 'erlang 'system_time 1)
`(erlang:system_time 'seconds)
`(let ((`#(,megasec ,sec ,_microsec) (os:timestamp)))
(+ sec (* megasec 1000000))))))

;;; ============================================================ [ Conversions ]

Expand Down Expand Up @@ -83,9 +94,4 @@
(erlang:unique_integer))
(string:to_lower (integer_to_list (random:uniform #0x100000000000000) 36)))

(defun timestamp ()
"Return the current timestamp, as a string."
(let ((`#(,megasec ,sec ,_microsec) (os:timestamp)))
(integer_to_list (+ sec (* megasec 1000000)))))

;;; ==================================================================== [ EOF ]

0 comments on commit 3f19fda

Please sign in to comment.