improve accuracy of timestamps
This commit is contained in:
@ -89,14 +89,14 @@ defmodule MemexWeb.CoreComponents do
|
||||
attr :datetime, :any, required: true, doc: "A `DateTime` struct or nil"
|
||||
|
||||
@doc """
|
||||
Phoenix.Component for a <time> element that renders the naivedatetime in the
|
||||
Phoenix.Component for a <time> element that renders the DateTime in the
|
||||
user's local timezone
|
||||
"""
|
||||
def datetime(assigns)
|
||||
|
||||
@spec cast_datetime(NaiveDateTime.t() | nil) :: String.t()
|
||||
defp cast_datetime(%NaiveDateTime{} = datetime) do
|
||||
datetime |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601(:extended)
|
||||
@spec cast_datetime(DateTime.t() | nil) :: String.t()
|
||||
defp cast_datetime(%DateTime{} = datetime) do
|
||||
datetime |> DateTime.to_iso8601(:extended)
|
||||
end
|
||||
|
||||
defp cast_datetime(_datetime), do: ""
|
||||
|
Reference in New Issue
Block a user