flounder

A simple gemini site builder
git clone git://git.alexwennerberg.com/flounder
Log | Files | Refs | README | LICENSE

commit 3154f9c73f92f3feaa1802f98dd824b5ab5f9f09
parent b69154c45fe6546994b2375aeb0e92481978fdad
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Tue, 11 Jan 2022 13:01:02 -0800

add years to timeago

Diffstat:
Mutils.go | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/utils.go b/utils.go @@ -99,6 +99,8 @@ func isGemini(filename string) bool { return extension == ".gmi" || extension == ".gemini" } +const solarYearSecs = 31556926 + func timeago(t *time.Time) string { d := time.Since(*t) var metric string @@ -112,9 +114,12 @@ func timeago(t *time.Time) string { } else if d.Hours() < 24 { amount = int(d.Hours()) metric = "hour" - } else { + } else if d.Seconds() < solarYearSecs { amount = int(d.Hours()) / 24 metric = "day" + } else { + amount = int(d.Seconds()) / solarYearSecs + metric = "year" } if amount == 1 { return fmt.Sprintf("%d %s ago", amount, metric)