Added time of day to tracking page.

This commit is contained in:
Marvin Blum
2020-09-24 19:55:22 +02:00
committed by Marvin Blum
parent 991ff57254
commit b6eb05e90c
4 changed files with 93 additions and 41 deletions

View File

@@ -40,6 +40,7 @@ func (cache *Cache) load() {
"format": func(t time.Time, layout string) string { return t.Format(layout) },
"multiply": func(f, x float64) float64 { return f * x },
"round": func(f float64) string { return fmt.Sprintf("%.2f", f) },
"intRange": intRange,
}
var err error
cache.tpl, err = template.New("").Funcs(funcMap).ParseGlob(templateDir)
@@ -100,3 +101,17 @@ func (cache *Cache) Clear() {
defer cache.m.Unlock()
cache.cache = make(map[string][]byte)
}
func intRange(start, end int) []int {
if end-start < 0 {
return []int{}
}
r := make([]int, end-start)
for i := 0; i < end-start; i++ {
r[i] = start + i
}
return r
}