Add support for $gt, $ge, $lt, $le operators for netquery. Update DatetimeEncoder to support values specified in seconds

This commit is contained in:
Patrick Pacher 2023-09-06 17:08:04 +02:00
parent b35e4b9b72
commit d96f841bef
2 changed files with 53 additions and 7 deletions

View file

@ -156,6 +156,8 @@ func DatetimeEncoder(loc *time.Location) EncodeFunc {
val = reflect.Indirect(val)
}
normalizedKind := normalizeKind(valType.Kind())
// we only care about "time.Time" here
var t time.Time
switch {
@ -179,6 +181,9 @@ func DatetimeEncoder(loc *time.Location) EncodeFunc {
return nil, false, fmt.Errorf("failed to parse time as RFC3339: %w", err)
}
case (normalizedKind == reflect.Int || normalizedKind == reflect.Uint || normalizedKind == reflect.Float32) && colDef.IsTime:
t = time.Unix(val.Int(), 0)
default:
// we don't care ...
return nil, false, nil