mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 10:18:40 +00:00
htime: Set zone of datetime from from go-toml
`go-toml/v2`'s unmarshaler does not specify zone name even if value has offset explicitly. To make time-formatting behaviour consistent, convert them into string in hugo. Close #8895
This commit is contained in:
1 parent
70e454812e
commit
b959ecbc81
1 file changed
+5
@@ -136,6 +136,11 @@ func ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.
|
||||
return vv.AsTime(location), nil
|
||||
case toml.LocalDateTime:
|
||||
return vv.AsTime(location), nil
|
||||
// issue #8895
|
||||
// datetimes parsed by `go-toml` have empty zone name
|
||||
// convert back them into string and use `cast`
|
||||
case time.Time:
|
||||
i = vv.Format(time.RFC3339)
|
||||
}
|
||||
return cast.ToTimeInDefaultLocationE(i, location)
|
||||
}
|
||||
Reference in new issue
Block a user