mirror of
https://github.com/penpot/penpot.git
synced 2026-04-03 18:02:39 +02:00
✨ Add helper for define clock in millis precision
This commit is contained in:
@@ -90,13 +90,22 @@
|
||||
(Clock/fixed ^Instant (inst instant)
|
||||
^ZoneId (ZoneId/of "Z"))))
|
||||
|
||||
|
||||
|
||||
(defn now
|
||||
[]
|
||||
#?(:clj (Instant/now *clock*)
|
||||
:cljs (new js/Date)))
|
||||
|
||||
#?(:clj
|
||||
(defn tick-millis-clock
|
||||
"Alternate clock with a resolution of milliseconds instead of the default nanoseconds of the Java clock.
|
||||
This may be useful if the instant is going to be serialized to DB with fressian (that does not have
|
||||
resolution enough to store all precission) and need to compare the deserialized value for equality.
|
||||
|
||||
You can replace the global clock (for example in unit tests) with
|
||||
(alter-var-root #'ct/*clock* (constantly (ct/tick-millis-clock)))"
|
||||
[]
|
||||
(Clock/tickMillis (ZoneId/of "Z"))))
|
||||
|
||||
;; --- DURATION
|
||||
|
||||
(defn- resolve-temporal-unit
|
||||
|
||||
Reference in New Issue
Block a user