forked from gsn/predictor
20 lines
325 B
Go
20 lines
325 B
Go
package grib
|
|
|
|
import (
|
|
"fmt"
|
|
"hash/fnv"
|
|
"time"
|
|
)
|
|
|
|
func nearestRun(t time.Time) time.Time {
|
|
h := t.UTC().Hour() - t.UTC().Hour()%6
|
|
return time.Date(t.Year(), t.Month(), t.Day(), h, 0, 0, 0, time.UTC)
|
|
}
|
|
|
|
func encodeKey(a ...any) uint64 {
|
|
h := fnv.New64a()
|
|
for _, v := range a {
|
|
fmt.Fprint(h, v)
|
|
}
|
|
return h.Sum64()
|
|
}
|