std.time.map
from-map
added in 3.0
(from-map m opts fill)converts a map back to an instant type (from-map {:type java.lang.Long :year 1970, :month 1, :day 1, :hour 0, :minute 0 :second 0 :millisecond 0 :timezone “GMT”} {:timezone “Asia/Kolkata”} {}) => 0
(-> (from-map {:type java.util.Calendar :year 1970, :month 1, :day 1, :hour 0, :minute 0 :second 0 :millisecond 0 :timezone “GMT”} {:timezone “Asia/Kolkata”} {}) (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}
(to-map (common/calendar (Date. 0) (TimeZone/getTimeZone “EST”)) {:timezone “GMT”} :month :day :year) => {:type java.util.GregorianCalendar, :timezone “GMT”, :long 0, :year 1970 :month 1, :day 1}
to-map
added in 3.0
(to-map t opts)(to-map t {:keys [timezone], :as opts} ks)converts an instant to a map (to-map 0 {:timezone “GMT”} common/+default-keys+) => {:type java.lang.Long, :timezone “GMT”, :long 0 :year 1970, :month 1, :day 1, :hour 0, :minute 0 :second 0 :millisecond 0}
(to-map (Date. 0) {:timezone “EST”} :year :day :month) => {:type java.util.Date, :timezone “EST”, :long 0 :year 1969, :day 31, :month 12}
(to-map {:type java.lang.Long, :timezone “GMT”, :long 0 :year 1970, :month 1, :day 1, :hour 0, :minute 0 :second 0 :millisecond 0} {:timezone “EST”} common/+default-keys+)
with-timezone
added in 3.0
(with-timezone {:keys [long timezone], :as m} tz)adds the timezone to a Calendar object
(-> (to-map 0 {:timezone “EST”}) (with-timezone “GMT”) (dissoc :type)) => (-> (to-map 0 {:timezone “GMT”}) (dissoc :type))