Odd issues with timezone strings (PST vs. -0800)

Hi there,

I’m working on creating a theme for my blog and one thing I’d really like is to display a string representation of the timezone a post was created in, for example “PST.”

I’ve tried accomplishing this with the following code:

{{ if not .Date.IsZero }}
  <time class="dt-published" datetime='{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}'>
    {{ if .PublishDate.Hour }}
      {{ .PublishDate.Format .Site.Params.DateFormat }}
    {{ else }}
      {{ .PublishDate.Format .Site.Params.DateFormatWithoutTime }}
    {{ end }}
{{ end }}

For reference, my .Site.Params are set in config.yaml as the following:

  DateFormat: "January 2, 2006 @ 15:04 MST"
  DateFormatWithoutTime: "January 2, 2006"

Unfortunately, this hasn’t turned out to be as straightforward as it seems. In some instances it works and in some instances it doesn’t:

For reference, the dates in my front-matter are set to the following:

  • Working: date = "2018-03-06T11:58:59-08:00"
  • Not working: date = "2018-03-22T12:15:03-08:00"

It’s worth pointing out that these two examples co-exist. When I added the latest post yesterday, it was output as “-0800” while every other post correctly rendered “PST.”

I’ve created a Gist containing all of the relevant files as well as my hugo env output.

I was wondering if anybody else had experienced something similar or might be able to help me out. Please let me know if there’s any more relevant information I could provide. Thanks! :slight_smile: