Handle dates in the Unix timestamp format (Fixes #763)
This commit is contained in:
parent
d976cc5df7
commit
b6f9f7b8aa
2 changed files with 53 additions and 1 deletions
|
|
@ -240,8 +240,23 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y")
|
||||
end
|
||||
|
||||
def date_to_asctime(date) when is_float(date) do
|
||||
date
|
||||
|> trunc()
|
||||
|> date_to_asctime()
|
||||
end
|
||||
|
||||
def date_to_asctime(date) when is_integer(date) do
|
||||
with {:ok, date} <- DateTime.from_unix(date) do
|
||||
format_asctime(date)
|
||||
else
|
||||
_e ->
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def date_to_asctime(date) do
|
||||
with {:ok, date, _offset} <- date |> DateTime.from_iso8601() do
|
||||
with {:ok, date, _offset} <- DateTime.from_iso8601(date) do
|
||||
format_asctime(date)
|
||||
else
|
||||
_e ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue