Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -3,17 +3,12 @@ title: time.AsTime
description: Returns the given string representation of a date/time value as a time.Time value.
categories: []
keywords: []
action:
aliases: [time]
related:
- functions/time/Duration
- functions/time/Format
- functions/time/Now
- functions/time/ParseDuration
returnType: time.Time
signatures: ['time.AsTime INPUT [TIMEZONE]']
params:
functions_and_methods:
aliases: [time]
returnType: time.Time
signatures: ['time.AsTime INPUT [TIMEZONE]']
aliases: [/functions/time]
toc: true
---
## Overview
@@ -29,7 +24,7 @@ Hugo provides [functions] and [methods] to format, localize, parse, compare, and
As shown above, the first argument must be a parsable string representation of a date/time value. For example:
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
{{% include "/_common/parsable-date-time-strings.md" %}}
To override the default time zone, set the [`timeZone`] in your site configuration or provide a second argument to the `time.AsTime` function. For example:
@@ -48,6 +43,6 @@ The order of precedence for determining the time zone is:
[IANA Time Zone database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[`time.Time`]: https://pkg.go.dev/time#Time
[`timeZone`]: /getting-started/configuration/#timezone
[`timeZone`]: /configuration/all/#timezone
[functions]: /functions/time/
[methods]: /methods/time/

View File

@@ -1,17 +1,13 @@
---
title: time.Duration
description: Returns a time.Duration value using the given time unit and number.
description: Returns a time.Duration value using the given time unit and number.
categories: []
keywords: []
action:
aliases: [duration]
related:
- functions/time/AsTime
- functions/time/Format
- functions/time/Now
- functions/time/ParseDuration
returnType: time.Duration
signatures: [time.Duration TIME_UNIT NUMBER]
params:
functions_and_methods:
aliases: [duration]
returnType: time.Duration
signatures: [time.Duration TIME_UNIT NUMBER]
aliases: [/functions/duration]
---

View File

@@ -3,17 +3,12 @@ title: time.Format
description: Returns the given date/time as a formatted and localized string.
categories: []
keywords: []
action:
aliases: [dateFormat]
related:
- functions/time/AsTime
- functions/time/Duration
- functions/time/Now
- functions/time/ParseDuration
returnType: string
signatures: [time.Format LAYOUT INPUT]
params:
functions_and_methods:
aliases: [dateFormat]
returnType: string
signatures: [time.Format LAYOUT INPUT]
aliases: [/functions/dateformat]
toc: true
---
Use the `time.Format` function with `time.Time` values:
@@ -32,7 +27,7 @@ Or use `time.Format` with a parsable string representation of a date/time value:
Examples of parsable string representations:
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
{{% include "/_common/parsable-date-time-strings.md" %}}
To override the default time zone, set the [`timeZone`] in your site configuration. The order of precedence for determining the time zone is:
@@ -40,17 +35,17 @@ To override the default time zone, set the [`timeZone`] in your site configurati
1. The time zone specified in your site configuration
1. The `Etc/UTC` time zone
[`timeZone`]: /getting-started/configuration/#timezone
[`timeZone`]: /configuration/all/#timezone
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}
## Localization
Use the `time.Format` function to localize `time.Time` values for the current language and region.
{{% include "functions/_common/locales.md" %}}
{{% include "/_common/functions/locales.md" %}}
Use the layout string as described above, or one of the tokens below. For example:

View File

@@ -3,15 +3,11 @@ title: time.Now
description: Returns the current local time.
categories: []
keywords: []
action:
aliases: [now]
related:
- functions/time/AsTime
- functions/time/Duration
- functions/time/Format
- functions/time/ParseDuration
returnType: time.Time
signatures: [time.Now]
params:
functions_and_methods:
aliases: [now]
returnType: time.Time
signatures: [time.Now]
aliases: [/functions/now]
---

View File

@@ -3,15 +3,11 @@ title: time.ParseDuration
description: Returns a time.Duration value by parsing the given duration string.
categories: []
keywords: []
action:
aliases: []
related:
- functions/time/AsTime
- functions/time/Duration
- functions/time/Format
- functions/time/Now
returnType: time.Duration
signatures: [time.ParseDuration DURATION]
params:
functions_and_methods:
aliases: []
returnType: time.Duration
signatures: [time.ParseDuration DURATION]
aliases: [/functions/time.parseduration]
---

View File

@@ -1,13 +0,0 @@
---
cascade:
_build:
list: never
publishResources: false
render: never
---
<!--
Files within this headless branch bundle are Markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
Include the rendered content using the "include" shortcode.
-->

View File

@@ -1,14 +0,0 @@
---
_comment: Do not remove front matter.
---
Format|Time zone
:--|:--
`2023-10-15T13:18:50-07:00`|`America/Los_Angeles`
`2023-10-15T13:18:50-0700`|`America/Los_Angeles`
`2023-10-15T13:18:50Z`|`Etc/UTC`
`2023-10-15T13:18:50`|Default is `Etc/UTC`
`2023-10-15`|Default is `Etc/UTC`
`15 Oct 2023`|Default is `Etc/UTC`
The last three examples are not fully qualified, and default to the `Etc/UTC` time zone.

View File

@@ -1,12 +1,7 @@
---
title: Time functions
linkTitle: time
description: Template functions to work with time values.
description: Use these functions to work with time values.
categories: []
keywords: []
menu:
docs:
parent: functions
---
Use these functions to work with time values.