Liking cljdoc? Tell your friends :D

hara.time.data.format


+format-cache+clj


+parse-cache+clj


cacheclj

(cache cache constructor ks flag)

helper function to access formatters by keyword

(f/cache f/+format-cache+ nil [java.text.SimpleDateFormat "HH MM dd Z"] true)

helper function to access formatters by keyword

(f/cache f/+format-cache+
        nil
         [java.text.SimpleDateFormat "HH MM dd Z"]
         true)
raw docstring

formatclj

(format t pattern)
(format t pattern {:keys [cached] :as opts})

converts a date into a string

(f/format (Date. 0) "HH MM dd Z" {:timezone "GMT" :cached true}) => "00 01 01 +0000"

(f/format (common/calendar (Date. 0) (TimeZone/getTimeZone "GMT")) "HH MM dd Z" {}) => "00 01 01 +0000"

(f/format (Timestamp. 0) "HH MM dd Z" {:timezone "PST"}) => "16 12 31 -0800"

(f/format (Date. 0) "HH MM dd Z") => string?

converts a date into a string

(f/format (Date. 0) "HH MM dd Z" {:timezone "GMT" :cached true})
=> "00 01 01 +0000"

(f/format (common/calendar (Date. 0)
                           (TimeZone/getTimeZone "GMT"))
          "HH MM dd Z"
          {})
=> "00 01 01 +0000"

(f/format (Timestamp. 0)
          "HH MM dd Z"
          {:timezone "PST"})
=> "16 12 31 -0800"

(f/format (Date. 0) "HH MM dd Z")
=> string?
raw docstring

parseclj

(parse s pattern)
(parse s pattern {:keys [cached] :as opts})

converts a string into a date (f/parse "00 00 01 01 01 1989 +0000" "ss mm HH dd MM yyyy Z" {:type Date :timezone "GMT"}) => #inst "1989-01-01T01:00:00.000-00:00"

(-> (f/parse "00 00 01 01 01 1989 -0800" "ss mm HH dd MM yyyy Z" {:type Calendar}) (map/to-map {:timezone "GMT"} common/+default-keys+)) => {:type java.util.GregorianCalendar, :timezone "GMT", :long 599648400000, :year 1989, :month 1, :day 1, :hour 9, :minute 0, :second 0, :millisecond 0}

(-> (f/parse "00 00 01 01 01 1989 +0000" "ss mm HH dd MM yyyy Z" {:type Timestamp}) (map/to-map {:timezone "Asia/Kolkata"} common/+default-keys+)) => {:type java.sql.Timestamp, :timezone "Asia/Kolkata", :long 599619600000, :year 1989, :month 1, :day 1, :hour 6, :minute 30, :second 0, :millisecond 0}

converts a string into a date
(f/parse "00 00 01 01 01 1989 +0000"
         "ss mm HH dd MM yyyy Z"
         {:type Date :timezone "GMT"})
=> #inst "1989-01-01T01:00:00.000-00:00"

(-> (f/parse "00 00 01 01 01 1989 -0800"
             "ss mm HH dd MM yyyy Z"
             {:type Calendar})
    (map/to-map {:timezone "GMT"}
                common/+default-keys+))
=> {:type java.util.GregorianCalendar,
    :timezone "GMT",
    :long 599648400000,
    :year 1989,
    :month 1, :day 1,
    :hour 9, :minute 0,
    :second 0, :millisecond 0}


(-> (f/parse "00 00 01 01 01 1989 +0000"
             "ss mm HH dd MM yyyy Z"
             {:type Timestamp})
    (map/to-map {:timezone "Asia/Kolkata"}
                common/+default-keys+))
=> {:type java.sql.Timestamp,
   :timezone "Asia/Kolkata",
    :long 599619600000,
    :year 1989,
    :month 1, :day 1,
    :hour 6, :minute 30,
    :second 0, :millisecond 0}

raw docstring

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

× close