refactor(binding): simplify unix timestamp parsing

This commit is contained in:
Yichao 'Peak' Ji 2022-07-28 18:13:14 +08:00
parent b57163a0e4
commit 499edccfea

View File

@ -302,12 +302,11 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
return err return err
} }
d := time.Duration(1) t := time.Unix(0, tv)
if tf == "unixnano" { if tf == "unix" {
d = time.Second t = time.Unix(tv, 0)
} }
t := time.Unix(tv/int64(d), tv%int64(d))
value.Set(reflect.ValueOf(t)) value.Set(reflect.ValueOf(t))
return nil return nil
} }