TzWord v0.4.0 TzWorld 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}
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
Link to this section Functions
all_timezones_at(point, backend \\ fetch_backend())
View Sourceall_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.
Reload the timezone geometry data.
This allows for the data to be reloaded, typically with a new release, without restarting the application.
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.
Returns the installed version of time zone data
Example
iex> TzWorld.version
{:ok, "2020a"}