TzWord v0.3.0 TzWorld View Source

Resolve a timezone name from coordinates.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Reload the timezone geo JSON data.

Returns the timezone name for the given coordinates specified as either a Geo.Point or as lng and lat parameters

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

handle_continue(atom, state)

View Source

Callback implementation for GenServer.handle_continue/2.

Callback implementation for GenServer.init/1.

Link to this function

reload_timezone_data()

View Source
reload_timezone_data() :: :ok

Reload the timezone geo JSON data.

This allows for the data to be reloaded, typically with a new release, without restarting the application.

Link to this function

timezone_at(point)

View Source
timezone_at(Geo.Point.t()) :: {:ok, String.t()} | {:error, String.t()}
timezone_at(Geo.PointZ.t()) :: {:ok, String.t()} | {:error, String.t()}

Returns the timezone name for the given coordinates specified as either a Geo.Point or as lng and lat parameters

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"}

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 nil if none of the timzones match.

Link to this function

timezone_at(lng, lat)

View Source
timezone_at(lng :: number(), lat :: number()) ::
  {:ok, String.t()} | {:error, String.t()}