diff options
author | satotake <doublequotation@gmail.com> | 2021-10-26 02:49:44 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 19:49:44 +0200 |
commit | b959ecbc8175e2bf260f10b08965531bce9bcb7e (patch) | |
tree | 6865de720f3912b34abe18fb1f964af5ffac48e2 /common/htime/time.go | |
parent | 70e454812ef684d02ffa881becf0f8ce6a1b5f8c (diff) |
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
Diffstat (limited to 'common/htime/time.go')
-rw-r--r-- | common/htime/time.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/common/htime/time.go b/common/htime/time.go index 33a77ead5..5071b0858 100644 --- a/common/htime/time.go +++ b/common/htime/time.go @@ -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) } |