mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
feat(binding): add global default time format
This commit is contained in:
parent
bb3519d26f
commit
843b01508c
@ -297,10 +297,12 @@ func setFloatField(val string, bitSize int, field reflect.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var DefaultTimeFormat = time.RFC3339
|
||||||
|
|
||||||
func setTimeField(val string, structField reflect.StructField, value reflect.Value) error {
|
func setTimeField(val string, structField reflect.StructField, value reflect.Value) error {
|
||||||
timeFormat := structField.Tag.Get("time_format")
|
timeFormat := structField.Tag.Get("time_format")
|
||||||
if timeFormat == "" {
|
if timeFormat == "" {
|
||||||
timeFormat = time.RFC3339
|
timeFormat = DefaultTimeFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
switch tf := strings.ToLower(timeFormat); tf {
|
switch tf := strings.ToLower(timeFormat); tf {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user