diff options
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 3f5348d66..0bf4de2f6 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -15,6 +15,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do alias Pleroma.Web.Endpoint alias Pleroma.Web.MediaProxy + require Logger + # This is a hack for twidere. def get_by_id_or_ap_id(id) do activity = @@ -240,28 +242,19 @@ 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 + def date_to_asctime(date) when is_binary(date) do + with {:ok, date, _offset} <- DateTime.from_iso8601(date) do format_asctime(date) else _e -> + Logger.warn("Date #{date} in wrong format, must be ISO 8601") "" end end def date_to_asctime(date) do - with {:ok, date, _offset} <- DateTime.from_iso8601(date) do - format_asctime(date) - else - _e -> - "" - end + Logger.warn("Date #{date} in wrong format, must be ISO 8601") + "" end def to_masto_date(%NaiveDateTime{} = date) do |