Footer with souce code link & generation time
This commit is contained in:
parent
da0114fbcb
commit
fdc1740126
5 changed files with 61 additions and 7 deletions
19
helpers/templates.go
Normal file
19
helpers/templates.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue