progress switching to Timex and allowing user to set week_start_at in settings
This commit is contained in:
parent
4031640e1d
commit
235bcc5af3
17 changed files with 130 additions and 17 deletions
lib/shift73k
|
@ -462,4 +462,15 @@ defmodule Shift73k.Accounts do
|
|||
|> where(id: ^user_id)
|
||||
|> Repo.update_all(set: [fave_shift_template_id: nil])
|
||||
end
|
||||
|
||||
## Week Start at
|
||||
|
||||
@doc """
|
||||
Sets the "week start at" day for user
|
||||
"""
|
||||
def set_user_week_start_at(user_id, day) do
|
||||
User
|
||||
|> where(id: ^user_id)
|
||||
|> Repo.update_all(set: [week_start_at: day])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
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]
|
||||
@app_time_zone @app_vars[:time_zone]
|
||||
|
||||
def ndt_to_local(%NaiveDateTime{} = ndt), do: DateTime.from_naive(ndt, @time_zone)
|
||||
|
||||
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)
|
||||
def app_time_zone, do: @app_time_zone
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue