Skip to content

Commit

Permalink
Merge pull request #225 from L-e-x-o-n/rel-time-2
Browse files Browse the repository at this point in the history
Use relative timestamps for moderation bot posts
  • Loading branch information
Beherith authored Mar 14, 2024
2 parents 4bc1b90 + d22ade8 commit 1d9124b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/teiserver/helpers/timex_helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ defmodule Teiserver.Helper.TimexHelper do
end
end

@spec date_to_discord_str(DateTime.t()) :: String.t()
def date_to_discord_str(the_time) do
"<t:#{Timex.to_unix(the_time)}:f>"
end

@spec date_to_str(DateTime.t()) :: String.t()
@spec date_to_str(DateTime.t(), list) :: String.t()
def date_to_str(the_time), do: date_to_str(the_time, [])
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/moderation/libs/action_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ defmodule Teiserver.Moderation.ActionLib do
if action do
until =
if action.expires do
"Until: " <> TimexHelper.date_to_str(action.expires, format: :ymd_hms) <> " (UTC)"
"Until: " <> TimexHelper.date_to_discord_str(action.expires)
else
"Permanent"
end
Expand Down

0 comments on commit 1d9124b

Please sign in to comment.