Updated compile-time value to be runtime
This commit is contained in:
parent
9eded87979
commit
1c2b867f3c
1 changed files with 4 additions and 1 deletions
|
|
@ -84,9 +84,12 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
||||||
"""
|
"""
|
||||||
attr :datetime, :any, required: true
|
attr :datetime, :any, required: true
|
||||||
attr :format, :string, default: "%Y-%m-%d %H:%M:%S"
|
attr :format, :string, default: "%Y-%m-%d %H:%M:%S"
|
||||||
attr :timezone, :string, default: Application.compile_env(:pinchflat, :timezone)
|
attr :timezone, :string, default: nil
|
||||||
|
|
||||||
def datetime_in_zone(assigns) do
|
def datetime_in_zone(assigns) do
|
||||||
|
timezone = assigns.timezone || Application.get_env(:pinchflat, :timezone)
|
||||||
|
assigns = Map.put(assigns, :timezone, timezone)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<time><%= Calendar.strftime(Timex.Timezone.convert(@datetime, @timezone), @format) %></time>
|
<time><%= Calendar.strftime(Timex.Timezone.convert(@datetime, @timezone), @format) %></time>
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue