diff options
| author | EuAndreh <eu@euandre.org> | 2025-12-05 19:57:57 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-12-05 19:57:57 -0300 |
| commit | e1b99db2364971d456a62e8ec7567e6b5250d004 (patch) | |
| tree | 8b1b7772cc44d90b97856d5d02481f3649e65908 /src/com/github/ivarref/yoltq/ext_sys.clj | |
| parent | rm -rf *: setup change to Clojure (diff) | |
| parent | Update for release (diff) | |
| download | fiinha-e1b99db2364971d456a62e8ec7567e6b5250d004.tar.gz fiinha-e1b99db2364971d456a62e8ec7567e6b5250d004.tar.xz | |
Merge remote-tracking branch 'upstream/main', where "upstream" is yoltq.
Diffstat (limited to 'src/com/github/ivarref/yoltq/ext_sys.clj')
| -rw-r--r-- | src/com/github/ivarref/yoltq/ext_sys.clj | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/com/github/ivarref/yoltq/ext_sys.clj b/src/com/github/ivarref/yoltq/ext_sys.clj new file mode 100644 index 0000000..692b934 --- /dev/null +++ b/src/com/github/ivarref/yoltq/ext_sys.clj @@ -0,0 +1,27 @@ +(ns com.github.ivarref.yoltq.ext-sys + (:require [datomic.api :as d]) + (:refer-clojure :exclude [random-uuid]) + (:import (java.util UUID))) + + +(def ^:dynamic *now-ms-atom* nil) +(def ^:dynamic *squuid-atom* nil) +(def ^:dynamic *random-atom* nil) + + +(defn now-ms [] + (if *now-ms-atom* + @*now-ms-atom* + (System/currentTimeMillis))) + + +(defn squuid [] + (if *squuid-atom* + (UUID/fromString (str "00000000-0000-0000-0000-" (format "%012d" (swap! *squuid-atom* inc)))) + (d/squuid))) + + +(defn random-uuid [] + (if *random-atom* + (UUID/fromString (str "00000000-0000-0000-0000-" (format "%012d" (swap! *random-atom* inc)))) + (UUID/randomUUID))) |
