summaryrefslogtreecommitdiff
path: root/internal/template/functions.go
diff options
context:
space:
mode:
authorGravatar jvoisin <julien.voisin@dustri.org> 2024-02-27 20:40:16 +0100
committerGravatar Frédéric Guillot <f@miniflux.net> 2024-02-28 19:32:38 -0800
commit9a4a942cc44223126c084952938aead01d95b68e (patch)
tree6c758616f119df89e6dd955d100d55517762bbac /internal/template/functions.go
parent6b3b8e8c9b9a73338be1d4137289f6653d9de595 (diff)
downloadv2-9a4a942cc44223126c084952938aead01d95b68e.tar.gz
v2-9a4a942cc44223126c084952938aead01d95b68e.tar.zst
v2-9a4a942cc44223126c084952938aead01d95b68e.zip
Simplify durationImpl
Diffstat (limited to 'internal/template/functions.go')
-rw-r--r--internal/template/functions.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/internal/template/functions.go b/internal/template/functions.go
index e050ffaa..5b4018a1 100644
--- a/internal/template/functions.go
+++ b/internal/template/functions.go
@@ -156,14 +156,11 @@ func durationImpl(t time.Time, now time.Time) string {
return ""
}
- diff := t.Sub(now)
-
- if diff < 0 {
- return ""
+ if diff := t.Sub(now); diff >= 0 {
+ // Round to nearest second to get e.g. "14m56s" rather than "14m56.245483933s"
+ return diff.Round(time.Second).String()
}
-
- // Round to nearest second to get e.g. "14m56s" rather than "14m56.245483933s"
- return diff.Round(time.Second).String()
+ return ""
}
func elapsedTime(printer *locale.Printer, tz string, t time.Time) string {