FastLocalDatetime v0.1.0 FastLocalDatetime.Table View Source
Maintains a table of timezone periods for a given timezone, and allows those timezones to convert a UTC epoch timestamp into a DateTime.
Link to this section Summary
Functions
Deletes a previously created table
Creates a new table for epoch conversions
Returns the timezone of the table
Convert a given UTC epoch timestamp to a local datetime
Returns true if the ETS table backing the table is still present
Link to this section Types
Link to this section Functions
Deletes a previously created table.
iex> {:ok, table} = new("America/New_York")
iex> delete(table)
:ok
Creates a new table for epoch conversions.
Returns {:ok, table}
on success, or {:error, :not_found}
if the
timezone doesn’t exist.
iex> {:ok, table} = new("America/New_York")
iex> table
#FastLocalDatetime.Table<America/New_York>
iex> new("not found")
{:error, :not_found}
Returns the timezone of the table.
iex> {:ok, table} = new("America/New_York")
iex> timezone(table)
"America/New_York"
Link to this function
unix_to_datetime(table, unix)
View Source
unix_to_datetime(t(), integer()) :: DateTime.t()
Convert a given UTC epoch timestamp to a local datetime.
iex> {:ok, table} = new("America/New_York")
iex> unix_to_datetime(table, 1522888537)
#DateTime<2018-04-04 20:35:37-04:00 EDT America/New_York>
iex> {:ok, table} = new("Etc/GMT-5")
iex> unix_to_datetime(table, 1522888537)
#DateTime<2018-04-05 05:35:37+05:00 +05 Etc/GMT-5>
Returns true if the ETS table backing the table is still present.
iex> {:ok, table} = new("America/New_York")
iex> valid?(table)
true
iex> delete(table)
:ok
iex> valid?(table)
false