Add timezone support for front matter dates without one

Fixes #8810
This commit is contained in:
Bjørn Erik Pedersen 2021-07-27 13:45:05 +02:00
parent a57dda854b
commit efa5760db5
10 changed files with 196 additions and 73 deletions

View file

@ -11,7 +11,7 @@ menu:
docs:
parent: "functions"
keywords: [dates,time,location]
signature: ["time INPUT [LOCATION]"]
signature: ["time INPUT [TIMEZONE]"]
workson: []
hugoversion: "v0.77.0"
relatedfuncs: []
@ -29,10 +29,12 @@ aliases: []
## Using Locations
The optional `LOCATION` parameter is a string that sets a default location that is associated with the specified time value. If the time value has an explicit timezone or offset specified, it will take precedence over the `LOCATION` parameter.
The optional `TIMEZONE` parameter is a string that sets a default time zone (or more specific, the location, which represents the collection of time offsets in a geographical area) that is associated with the specified time value. If the time value has an explicit timezone or offset specified, it will take precedence over the `TIMEZONE` parameter.
The list of valid locations may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
If no `TIMEZONE` is set, the `timeZone` from site configuration will be used.
```
{{ time "2020-10-20" }} → 2020-10-20 00:00:00 +0000 UTC
{{ time "2020-10-20" "America/Los_Angeles" }} → 2020-10-20 00:00:00 -0700 PDT