(ns Time "Elixir Time module — time-of-day operations. In CljElixir: (Time/utc-now), (Time/new 12 30 0), etc.") (defn utc-now "Returns the current UTC time. (Time/utc-now) ;=> ~T[12:30:00]" ([]) ([calendar])) (defn new "Creates a new time. (Time/new 12 30 0) ;=> {:ok ~T[12:30:00]}" ([hour minute second]) ([hour minute second microsecond]) ([hour minute second microsecond calendar])) (defn new! "Creates a new time. Raises on error. (Time/new! 12 30 0) ;=> ~T[12:30:00]" ([hour minute second]) ([hour minute second microsecond]) ([hour minute second microsecond calendar])) (defn from-iso8601 "Parses ISO 8601 time. Returns {:ok time} or {:error reason}. (Time/from-iso8601 \"12:30:00\") ;=> {:ok ~T[12:30:00]}" ([string]) ([string calendar])) (defn from-iso8601! "Parses ISO 8601 time. Raises on error." ([string]) ([string calendar])) (defn to-iso8601 "Converts to ISO 8601 string. (Time/to-iso8601 time) ;=> \"12:30:00\"" ([time]) ([time format])) (defn to-string "Converts to string. (Time/to-string time) ;=> \"12:30:00\"" [time]) (defn add "Adds `amount` of time. (Time/add time 3600) ;=> +1 hour (Time/add time 30 :minute)" ([time amount]) ([time amount unit])) (defn diff "Returns difference between two times. (Time/diff t1 t2) ;=> seconds" ([time1 time2]) ([time1 time2 unit])) (defn truncate "Truncates to given precision. (Time/truncate time :second)" [time precision]) (defn compare "Compares two times. Returns :lt, :eq, or :gt." [time1 time2]) (defn before? "Returns true if `time1` is before `time2`." [time1 time2]) (defn after? "Returns true if `time1` is after `time2`." [time1 time2]) (defn shift "Shifts time by a duration. (Time/shift time :hour 1 :minute -15)" [time duration]) (defn from-erl "Converts Erlang time tuple. (Time/from-erl {12 30 0}) ;=> {:ok ~T[12:30:00]}" ([tuple]) ([tuple microsecond]) ([tuple microsecond calendar])) (defn from-erl! "Converts Erlang time tuple. Raises on error." ([tuple]) ([tuple microsecond]) ([tuple microsecond calendar])) (defn to-erl "Converts to Erlang time tuple. (Time/to-erl time) ;=> {12 30 0}" [time]) (defn from-seconds-after-midnight "Creates time from seconds after midnight. (Time/from-seconds-after-midnight 45000) ;=> {:ok ~T[12:30:00]}" ([seconds]) ([seconds microsecond]) ([seconds microsecond calendar])) (defn to-seconds-after-midnight "Returns seconds since midnight. (Time/to-seconds-after-midnight time) ;=> 45000" [time])