package state import ( "fmt" "math" "time" ) const redisObjectExpire = 604800 const errInvalidValue = "invalid value %f" func FloatToBool(input float64) interface{} { return int(input) != 0 } func RoundMilli(input float64) interface{} { return math.Round(input*1000) / 1000 } func RoundGPS(input float64) interface{} { return math.Round(input*100000) / 100000 } func IntCeil(input float64) interface{} { return int(math.Ceil(input)) } func IntFloor(input float64) interface{} { return int(math.Floor(input)) } func Int(input float64) interface{} { return int(input) } // WHy does this return an array of bytes instead of a string, or a time.Time func SerializeTimestampUSec(timestampUSec int) ([]byte, error) { return time.UnixMicro(int64(timestampUSec)).UTC().MarshalJSON() } func GetMappedStrValues(valueMap map[float64]string) func(float64) interface{} { return func(input float64) interface{} { if value, ok := valueMap[input]; ok { return value } return fmt.Sprintf(errInvalidValue, input) } }