Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize time.Format + time zone support #8804

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

bep
Copy link
Member

@bep bep commented Jul 27, 2021

Fixes #8797

@bep bep force-pushed the feat/date-locale-8797 branch from 1603215 to 31c98f8 Compare July 27, 2021 10:23
@bep
Copy link
Member Author

bep commented Jul 27, 2021

@regisphilibert @jmooring if we limit the discussion to time.Format (or dateFormat which is the alias).

This function now is:

  • Localized
  • Supports both Go's special layout syntax and some predefined constants (which I think makes it easier to get multilingual right)

E.g. (more examples in the docs in this PR):

Date: {{ .Date | time.Format ":date_medium" }}

@bep bep force-pushed the feat/date-locale-8797 branch from 31c98f8 to 0e8e49d Compare July 27, 2021 10:39
@bep bep force-pushed the feat/date-locale-8797 branch from 0e8e49d to 632f8df Compare July 27, 2021 16:26
@bep bep changed the title Localize time.Format Localize time.Format + time zone support Jul 27, 2021
@bep
Copy link
Member Author

bep commented Jul 27, 2021

@jmooring one question: I have added some improved time zone support to this PR; I have called the new config timeZone because 1) That is what Jekyll uses and I suspect there are many Hugo sites out there already using it and 2) I think it's the term most people understands. Go calls this "time location", which I guess is more precise ... but.

@bep bep force-pushed the feat/date-locale-8797 branch from 632f8df to 55fe27e Compare July 27, 2021 16:31
@jmooring
Copy link
Member

@bep

I have called the new config timeZone

Good!

Unfortunately most people confuse time zones (e.g., America/Los_Angeles) with time zone abbreviations (e.g., PST) which are essentially useless given the N:N relationship between offsets and time zone abbreviations.

@bep bep merged commit efa5760 into gohugoio:master Jul 27, 2021
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make time.Format localized
2 participants