removing timex in favor of main library functions

This commit is contained in:
Adam Piontek 2021-03-06 00:42:13 -05:00
parent ed98c03fae
commit 5c4ae401d9
4 changed files with 7 additions and 4 deletions

View file

@ -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",

View file

@ -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

View file

@ -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

View file

@ -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