diff options
author | dtluna <dtluna@openmailbox.org> | 2017-06-20 00:12:37 +0300 |
---|---|---|
committer | dtluna <dtluna@openmailbox.org> | 2017-06-20 00:12:37 +0300 |
commit | 069daf644d984c479eae6483595a3307e923950b (patch) | |
tree | 2832236b8a966d13061cdcc303b8c40c8a387aea /lib/pleroma/web/twitter_api/utils.ex | |
parent | 45c751985ee1612bd788c460ee1f6aca75f24464 (diff) | |
download | pleroma-069daf644d984c479eae6483595a3307e923950b.tar.gz |
Replace UserRepresenter with UserView
Diffstat (limited to 'lib/pleroma/web/twitter_api/utils.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/utils.ex | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/web/twitter_api/utils.ex b/lib/pleroma/web/twitter_api/utils.ex index 5cbe0cf9c..2c3507dfb 100644 --- a/lib/pleroma/web/twitter_api/utils.ex +++ b/lib/pleroma/web/twitter_api/utils.ex @@ -1,6 +1,7 @@ defmodule Pleroma.Web.TwitterAPI.Utils do alias Pleroma.{Repo, Object, Formatter, User, Activity} alias Pleroma.Web.ActivityPub.Utils + alias Calendar.Strftime def attachments_from_ids(ids) do Enum.map(ids || [], fn (media_id) -> @@ -72,4 +73,20 @@ defmodule Pleroma.Web.TwitterAPI.Utils do object end end + + def format_naive_asctime(date) do + date |> DateTime.from_naive!("Etc/UTC") |> format_asctime + end + + def format_asctime(date) do + Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y") + end + + def date_to_asctime(date) do + with {:ok, date, _offset} <- date |> DateTime.from_iso8601 do + format_asctime(date) + else _e -> + "" + end + end end |