Add timezone handling

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-10-10 16:25:50 +02:00
parent eba3c70c9b
commit d58ca5743d
49 changed files with 1218 additions and 429 deletions

View File

@@ -79,6 +79,19 @@ defmodule Mobilizon.Service.Geospatial.Provider do
def coordinates(_), do: nil
@doc """
Returns the timezone for a Geo.Point
"""
@spec timezone(nil | Geo.Point.t()) :: nil | String.t()
def timezone(nil), do: nil
def timezone(%Geo.Point{} = point) do
case TzWorld.timezone_at(point) do
{:ok, tz} -> tz
{:error, _err} -> nil
end
end
@spec endpoint(atom()) :: String.t()
def endpoint(provider) do
Application.get_env(:mobilizon, provider) |> get_in([:endpoint])