Slightly improve timestamps for old posts

This commit is contained in:
Shadowfacts 2020-05-18 22:30:16 -04:00
parent 4733aa23ab
commit 0afe2d3b30
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 10 additions and 1 deletions

View File

@ -46,8 +46,17 @@ defmodule ClacksWeb.FrontendView do
# less than a week, days
"#{Integer.floor_div(diff, 60 * 60 * 24)}d"
diff < 60 * 60 * 24 * 30 ->
# less than a month(ish), weeks
"#{Integer.floor_div(diff, 60 * 60 * 24 * 7)}wk"
diff < 60 * 60 * 24 * 365 ->
# less than a year, months(ish)
# todo: figure out actually how many months
"#{Integer.floor_div(diff, 60 * 60 * 24 * 30)}mo"
true ->
Timex.format!(datetime, "%FT%T%:z", :strftime)
Timex.format!(datetime, "%F", :strftime)
end
end