removing timex in favor of main library functions
This commit is contained in:
parent
ed98c03fae
commit
5c4ae401d9
4 changed files with 7 additions and 4 deletions
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
mix.exs
2
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue