hugo icon indicating copy to clipboard operation
hugo copied to clipboard

time: Fix toml zoneinfo inconsistency

Open satotake opened this issue 2 years ago • 0 comments

TOML's time representation has known issues about zoneinfo name such as PDT in hugo

  • https://github.com/gohugoio/hugo/pull/9082
  • https://github.com/gohugoio/hugo/pull/9982
  • https://github.com/gohugoio/hugo/issues/8895
  • https://github.com/gohugoio/hugo/issues/9996

These are caused because

  • TOML's time format has only offset
    • zoneinfo cannot be retrieved with offset value
  • TZ environment variable can change the behaviour
  • cast.ToTimeInDefaultLocationE may or may not use location arg

Given that hugo often is used on both local and remote machine, and as #9996 said hugo supports multilingual site generation,

  • TZ envvar should not have any effect on this
    • Remote environments can be hard to debug
  • If only timeZone is set explicitly in config file and offsets of time are matched with it, hugo should show zoneinfo
    • Otherwise, zoneinfo should not be displayed
  • hugo should handle TOML's time object and time string equally

To meet these,

  • assure to set location derived from conf to time of TOML if possible
  • add tests

Close https://github.com/gohugoio/hugo/issues/9996

satotake avatar Aug 07 '22 19:08 satotake