Skip to content

Commit

Permalink
htime: Set zone of datetime from from go-toml
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
satotake authored Oct 25, 2021
1 parent 70e4548 commit b959ecb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/htime/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit b959ecb

Please sign in to comment.