mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 05:42: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
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user