(coerce-instant value {:keys [type] :as opts})coerce-instant for java.time datastructures (coerce-instant 0 {:type Long :timezone "GMT"}) => 0
(-> (coerce-instant 0 {:type ZonedDateTime :timezone "GMT"}) (map/to-map {} common/+default-keys+)) => {:type ZonedDateTime :timezone "GMT", :long 0, :year 1970, :month 1, :day 1, :hour 0, :minute 0, :second 0 :millisecond 0}
(-> (time/-from-long 0 {:type ZonedDateTime :timezone "GMT"}) (coerce-instant {:type Clock :timezone "Asia/Kolkata"}) (map/to-map {} common/+default-keys+)) => {:type java.time.Clock$FixedClock, :timezone "Asia/Kolkata", :long 0, :year 1970, :month 1, :day 1, :hour 5, :minute 30, :second 0 :millisecond 0}
(-> (time/-from-long 0 {:type Clock :timezone "GMT"}) (coerce-instant {:type Calendar :timezone "Asia/Kolkata"}) (map/to-map {} common/+default-keys+)) => {:type java.util.GregorianCalendar :timezone "Asia/Kolkata", :long 0, :year 1970, :month 1, :day 1, :hour 5, :minute 30, :second 0 :millisecond 0}
coerce-instant for java.time datastructures
(coerce-instant 0 {:type Long
:timezone "GMT"})
=> 0
(-> (coerce-instant 0 {:type ZonedDateTime
:timezone "GMT"})
(map/to-map {} common/+default-keys+))
=> {:type ZonedDateTime
:timezone "GMT", :long 0,
:year 1970, :month 1, :day 1, :hour 0,
:minute 0, :second 0 :millisecond 0}
(-> (time/-from-long 0 {:type ZonedDateTime
:timezone "GMT"})
(coerce-instant {:type Clock
:timezone "Asia/Kolkata"})
(map/to-map {} common/+default-keys+))
=> {:type java.time.Clock$FixedClock,
:timezone "Asia/Kolkata", :long 0,
:year 1970, :month 1, :day 1, :hour 5,
:minute 30, :second 0 :millisecond 0}
(-> (time/-from-long 0 {:type Clock
:timezone "GMT"})
(coerce-instant {:type Calendar
:timezone "Asia/Kolkata"})
(map/to-map {} common/+default-keys+))
=> {:type java.util.GregorianCalendar
:timezone "Asia/Kolkata", :long 0,
:year 1970, :month 1, :day 1, :hour 5,
:minute 30, :second 0 :millisecond 0}(coerce-zone value {:keys [type] :as opts})coercion of one zone object to another (-> (coerce-zone "Asia/Kolkata" {:type TimeZone}) (string/-to-string)) => "Asia/Kolkata"
(-> (coerce-zone nil {:type TimeZone}) (string/-to-string)) => (-> (TimeZone/getDefault) (string/-to-string))
coercion of one zone object to another
(-> (coerce-zone "Asia/Kolkata" {:type TimeZone})
(string/-to-string))
=> "Asia/Kolkata"
(-> (coerce-zone nil {:type TimeZone})
(string/-to-string))
=> (-> (TimeZone/getDefault)
(string/-to-string))cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |