From 0afe2d3b30baab8daf6f5d8f08c19844c35a3939 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 18 May 2020 22:30:16 -0400 Subject: [PATCH] Slightly improve timestamps for old posts --- lib/clacks_web/views/frontend_view.ex | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/clacks_web/views/frontend_view.ex b/lib/clacks_web/views/frontend_view.ex index 9c39124..a11439a 100644 --- a/lib/clacks_web/views/frontend_view.ex +++ b/lib/clacks_web/views/frontend_view.ex @@ -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