fix apparent skew

This commit is contained in:
byte[] 2019-11-11 12:07:09 -05:00
parent f21eaa87bb
commit a86be3b17c

View file

@ -18,6 +18,7 @@ defmodule PhilomenaWeb.AppView do
def pretty_time(time) do def pretty_time(time) do
seconds = NaiveDateTime.diff(NaiveDateTime.utc_now(), time, :second) seconds = NaiveDateTime.diff(NaiveDateTime.utc_now(), time, :second)
relation = if seconds < 0, do: "from now", else: "ago" relation = if seconds < 0, do: "from now", else: "ago"
time = time |> DateTime.from_naive!("Etc/UTC")
seconds = abs(seconds) seconds = abs(seconds)
minutes = abs(div(seconds, 60)) minutes = abs(div(seconds, 60))
@ -41,7 +42,7 @@ defmodule PhilomenaWeb.AppView do
true -> String.replace(@time_strings[:years], "%d", to_string(years)) true -> String.replace(@time_strings[:years], "%d", to_string(years))
end end
content_tag(:time, "#{words} #{relation}", datetime: time |> NaiveDateTime.to_iso8601()) content_tag(:time, "#{words} #{relation}", datetime: time |> DateTime.to_iso8601())
end end
def can?(conn, action, model) do def can?(conn, action, model) do