diff --git a/config/config.exs b/config/config.exs index 83f8b26b..37bf20e0 100644 --- a/config/config.exs +++ b/config/config.exs @@ -10,6 +10,9 @@ use Mix.Config config :shift73k, ecto_repos: [Shift73k.Repo] +# Configure the time zone database +config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase + # Custom application global variables config :shift73k, :app_global_vars, time_zone: "America/New_York", diff --git a/lib/shift73k/util/dt.ex b/lib/shift73k/util/dt.ex index 9287b4a5..31c8c0e8 100644 --- a/lib/shift73k/util/dt.ex +++ b/lib/shift73k/util/dt.ex @@ -2,9 +2,9 @@ defmodule Shift73k.Util.Dt do @app_vars Application.get_env(:shift73k, :app_global_vars, time_zone: "America/New_York") @time_zone @app_vars[:time_zone] - def ndt_to_local(%NaiveDateTime{} = ndt), do: Timex.to_datetime(ndt, @time_zone) + def ndt_to_local(%NaiveDateTime{} = ndt), do: DateTime.from_naive(ndt, @time_zone) - def format_dt_local(dt_local, fstr), do: Timex.format!(dt_local, fstr) + def format_dt_local({:ok, dt_local}, fstr), do: Calendar.strftime(dt_local, fstr) def format_ndt(%NaiveDateTime{} = ndt, fstr), do: ndt |> ndt_to_local() |> format_dt_local(fstr) end diff --git a/lib/shift73k_web/live/user_management/index.ex b/lib/shift73k_web/live/user_management/index.ex index 4fefe001..1b92e9b4 100644 --- a/lib/shift73k_web/live/user_management/index.ex +++ b/lib/shift73k_web/live/user_management/index.ex @@ -187,5 +187,5 @@ defmodule Shift73kWeb.UserManagementLive.Index do ] end - def dt_out(ndt), do: format_ndt(ndt, "{YYYY} {Mshort} {0D}, {h12}:{0m} {am}") + def dt_out(ndt), do: format_ndt(ndt, "%Y %b %d, %I:%M %p") end diff --git a/mix.exs b/mix.exs index 6b83d8a8..3bc90306 100644 --- a/mix.exs +++ b/mix.exs @@ -52,7 +52,7 @@ defmodule Shift73k.MixProject do {:bamboo, "~> 2.0"}, {:bamboo_smtp, "~> 4.0"}, {:scrivener_ecto, "~> 2.0"}, - {:timex, "~> 3.6"} + {:tzdata, "~> 1.1"} ] end