View Source ExKits.Utils.Time (ex_kits v0.2.7)
时间相关工具
Summary
Functions
get current timestamp
Functions
@spec china_now() :: {:ok, DateTime.t()}
@spec china_today() :: Date.t()
@spec date_to_datetime(Date.t(), binary()) :: DateTime.t()
@spec datetime_to_naive(DateTime.t()) :: NaiveDateTime.t()
@spec datetime_to_str(DateTime.t(), String.t()) :: String.t()
@spec datetime_to_ts(DateTime.t()) :: integer()
@spec naive_now(atom()) :: NaiveDateTime.t()
@spec naive_to_datetime(NaiveDateTime.t(), Calendar.time_zone()) :: {:ok, DateTime.t()}
@spec naive_to_datetime!(NaiveDateTime.t(), Calendar.time_zone()) :: DateTime.t()
@spec now(Calendar.time_zone()) :: {:ok, DateTime.t()}
@spec now!(Calendar.time_zone()) :: DateTime.t()
@spec str_to_datetime(String.t(), String.t()) :: {:ok, DateTime.t()}
get current timestamp
Example
iex> Common.TimeTool.timestamp(:seconds) 1534466694 iex> Common.TimeTool.timestamp(:milli_seconds) 1534466732335 iex> Common.TimeTool.timestamp(:micro_seconds) 1534466750683862 iex> Common.TimeTool.timestamp(:nano_seconds) 1534466778949821000
@spec ts_to_datetime(integer(), Calendar.time_zone()) :: {:ok, DateTime.t()}