Browse Source

Slightly improve timestamps for old posts

master
Shadowfacts 1 year ago
parent
commit
0afe2d3b30
Signed by: shadowfacts GPG Key ID: 94A5AB95422746E5
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      lib/clacks_web/views/frontend_view.ex

+ 10
- 1
lib/clacks_web/views/frontend_view.ex 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


Loading…
Cancel
Save