mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 13:22:09 +08:00
refactor(binding): simplify unix timestamp parsing
This commit is contained in:
parent
b57163a0e4
commit
499edccfea
@ -302,12 +302,11 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
|
||||
return err
|
||||
}
|
||||
|
||||
d := time.Duration(1)
|
||||
if tf == "unixnano" {
|
||||
d = time.Second
|
||||
t := time.Unix(0, tv)
|
||||
if tf == "unix" {
|
||||
t = time.Unix(tv, 0)
|
||||
}
|
||||
|
||||
t := time.Unix(tv/int64(d), tv%int64(d))
|
||||
value.Set(reflect.ValueOf(t))
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user