FastLocalDatetime v0.1.0 FastLocalDatetime View Source

Fast conversions of UTC epoch timestamps (Unix timestamps) into a local DateTime.

Link to this section Summary

Functions

Convert a UTC epoch timestamp (Unix timestamp) to a DateTime in the given timezone

Link to this section Functions

Link to this function unix_to_datetime(unix, timezone) View Source
unix_to_datetime(timestamp, timezone) ::
  {:ok, DateTime.t()} | {:error, :not_found}
when timestamp: integer(), timezone: String.t()

Convert a UTC epoch timestamp (Unix timestamp) to a DateTime in the given timezone.

iex> {:ok, dt} = unix_to_datetime(1522888537, "America/New_York")
iex> dt
#DateTime<2018-04-04 20:35:37-04:00 EDT America/New_York>

iex> unix_to_datetime(1522888537, "not found")
{:error, :not_found}