TzWorld (TzWord v1.1.0) View Source
Resolve a timezone name from coordinates.
Link to this section Summary
Functions
Returns all timezone name found for the given
coordinates specified as either a Geo.Point
,
a Geo.PointZ
or a tuple {lng, lat}
Returns the OTP app name of :tz_world
Reload the timezone geometry data.
Returns the first timezone name found for the given
coordinates specified as either a Geo.Point
,
a Geo.PointZ
or a tuple {lng, lat}
Returns the installed version of time zone data
Link to this section Types
Specs
backend() :: module()
Link to this section Functions
Specs
all_timezones_at(Geo.Point.t(), backend()) :: {:ok, [String.t()]}
all_timezones_at(Geo.PointZ.t(), backend()) :: {:ok, [String.t()]}
all_timezones_at({lng :: number(), lat :: number()}, backend()) :: {:ok, [String.t()]}
Returns all timezone name found for the given
coordinates specified as either a Geo.Point
,
a Geo.PointZ
or a tuple {lng, lat}
Arguments
point
is aGeo.Point.t()
aGeo.PointZ.t()
or a tuple{lng, lat}
backend
is any backend access module.
Returns
{:ok, timezone}
or{:error, :time_zone_not_found}
Notes
Note that the point is always expressed as
lng
followed by lat
.
Examples
iex> TzWorld.all_timezones_at(%Geo.Point{coordinates: {3.2, 45.32}})
{:ok, ["Europe/Paris"]}
iex> TzWorld.all_timezones_at({3.2, 45.32})
{:ok, ["Europe/Paris"]}
iex> TzWorld.all_timezones_at({0.0, 0.0})
{:ok, []}
The algorithm starts by filtering out timezones whose bounding box does not contain the given point.
Once filtered, all timezones which contains the given point is returned, or an error tuple if none of the timezones match.
In rare cases, typically due to territorial disputes, one or more timezones may apply to a given location. This function returns all time zones that match.
Returns the OTP app name of :tz_world
Reload the timezone geometry data.
This allows for the data to be reloaded, typically with a new release, without restarting the application.
Specs
timezone_at(Geo.Point.t(), backend()) :: {:ok, String.t()} | {:error, atom()}
timezone_at(Geo.PointZ.t(), backend()) :: {:ok, String.t()} | {:error, atom()}
timezone_at({lng :: number(), lat :: number()}, backend()) :: {:ok, String.t()} | {:error, atom()}
Returns the first timezone name found for the given
coordinates specified as either a Geo.Point
,
a Geo.PointZ
or a tuple {lng, lat}
Arguments
point
is aGeo.Point.t()
aGeo.PointZ.t()
or a tuple{lng, lat}
backend
is any backend access module.
Returns
{:ok, timezone}
or{:error, :time_zone_not_found}
Notes
Note that the point is always expressed as
lng
followed by lat
.
Examples
iex> TzWorld.timezone_at(%Geo.Point{coordinates: {3.2, 45.32}})
{:ok, "Europe/Paris"}
iex> TzWorld.timezone_at({3.2, 45.32})
{:ok, "Europe/Paris"}
iex> TzWorld.timezone_at({0.0, 0.0})
{:error, :time_zone_not_found}
The algorithm starts by filtering out timezones whose bounding box does not contain the given point.
Once filtered, the first timezone which contains the given point is returned, or an error tuple if none of the timezones match.
In rare cases, typically due to territorial disputes, one or more timezones may apply to a given location. This function returns the first time zone that matches.
Specs
version() :: {:ok, String.t()} | {:error, :enoent}
Returns the installed version of time zone data
Example
TzWorld.version
=> {:ok, "2020d"}