Footer with souce code link & generation time

This commit is contained in:
William Bouzourène 2025-01-04 17:27:14 +01:00
parent 0aa5b42671
commit 8657bd26bd
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww
5 changed files with 61 additions and 7 deletions

19
helpers/templates.go Normal file
View file

@ -0,0 +1,19 @@
package helpers
import (
"time"
"github.com/flosch/pongo2/v6"
)
func TemplTimeDiff(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
if !in.IsTime() {
return pongo2.AsSafeValue("invalid time"), nil
}
start := in.Time()
now := time.Now()
diff := now.Sub(start)
return pongo2.AsSafeValue(diff.Milliseconds()), nil
}