Liking cljdoc? Tell your friends :D

std.time.map


arraymap-metaclj


from-mapclj

(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}

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}
raw docstring

hashmap-metaclj


to-mapclj

(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+)

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+)
raw docstring

with-timezoneclj

(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))

adds the timezone to a Calendar object

(-> (to-map 0 {:timezone "EST"})
    (with-timezone "GMT")
    (dissoc :type))
=> (-> (to-map 0 {:timezone "GMT"})
       (dissoc :type))
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close