FastLocalDatetime.Table (FastLocalDatetime v1.0.1) 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
Specs
t()
Link to this section Functions
Specs
delete(t()) :: :ok
Deletes a previously created table.
iex> {:ok, table} = new("America/New_York")
iex> delete(table)
:ok
Specs
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"
Specs
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> {:ok, dt} = unix_to_datetime(table, 1522888537)
iex> dt
#DateTime<2018-04-04 20:35:37-04:00 EDT America/New_York>
iex> unix_to_datetime(table, -218937198213123)
{:error, :before_year_zero}
iex> {:ok, table} = new("Etc/GMT-5")
iex> {:ok, dt} = unix_to_datetime(table, 1522888537)
iex> dt
#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