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,13 +3,10 @@ title: Add
description: Returns the given time plus the given duration.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
- functions/time/Duration
- functions/time/ParseDuration
returnType: time.Time
signatures: [TIME.Add DURATION]
params:
functions_and_methods:
returnType: time.Time
signatures: [TIME.Add DURATION]
---
```go-html-template

View File

@@ -3,11 +3,10 @@ title: AddDate
description: Returns the time corresponding to adding the given number of years, months, and days to the given time.Time value.
categories: []
keywords: []
action:
aliases: []
related: []
returnType: time.Time
signatures: [TIME.AddDate YEARS MONTHS DAYS]
params:
functions_and_methods:
returnType: time.Time
signatures: [TIME.AddDate YEARS MONTHS DAYS]
aliases: [/functions/adddate]
---
@@ -21,11 +20,10 @@ aliases: [/functions/adddate]
{{ $d.AddDate -1 -1 -1 | time.Format "2006-01-02" }} → 2020-11-30
```
{{% note %}}
When adding months or years, Hugo normalizes the final `time.Time` value if the resulting day does not exist. For example, adding one month to 31 January produces 2 March or 3 March, depending on the year.
See [this explanation](https://github.com/golang/go/issues/31145#issuecomment-479067967) from the Go team.
{{% /note %}}
> [!note]
> When adding months or years, Hugo normalizes the final `time.Time` value if the resulting day does not exist. For example, adding one month to 31 January produces 2 March or 3 March, depending on the year.
>
> See [this explanation](https://github.com/golang/go/issues/31145#issuecomment-479067967) from the Go team.
```go-html-template
{{ $d := "2023-01-31" | time.AsTime }}

View File

@@ -3,13 +3,10 @@ title: After
description: Reports whether TIME1 is after TIME2.
categories: []
keywords: []
action:
related:
- methods/time/Before
- methods/time/Equal
- functions/time/AsTime
returnType: bool
signatures: [TIME1.After TIME2]
params:
functions_and_methods:
returnType: bool
signatures: [TIME1.After TIME2]
---
```go-html-template

View File

@@ -3,13 +3,10 @@ title: Before
description: Reports whether TIME1 is before TIME2.
categories: []
keywords: []
action:
related:
- methods/time/After
- methods/time/Equal
- functions/time/AsTime
returnType: bool
signatures: [TIME1.Before TIME2]
params:
functions_and_methods:
returnType: bool
signatures: [TIME1.Before TIME2]
---
```go-html-template

View File

@@ -3,16 +3,10 @@ title: Day
description: Returns the day of the month of the given time.Time value.
categories: []
keywords: []
action:
related:
- methods/time/Year
- methods/time/Month
- methods/time/Hour
- methods/time/Minute
- methods/time/Second
- functions/time/AsTime
returnType: int
signatures: [TIME.Day]
params:
functions_and_methods:
returnType: int
signatures: [TIME.Day]
---
```go-html-template

View File

@@ -3,13 +3,10 @@ title: Equal
description: Reports whether TIME1 is equal to TIME2.
categories: []
keywords: []
action:
related:
- methods/time/After
- methods/time/Before
- functions/time/AsTime
returnType: bool
signatures: [TIME1.Equal TIME2]
params:
functions_and_methods:
returnType: bool
signatures: [TIME1.Equal TIME2]
---
```go-html-template

View File

@@ -3,15 +3,10 @@ title: Format
description: Returns a textual representation of the time.Time value formatted according to the layout string.
categories: []
keywords: []
action:
aliases: []
related:
- functions/time/AsTime
- methods/time/UTC
- methods/time/Local
returnType: string
signatures: [TIME.Format LAYOUT]
toc: true
params:
functions_and_methods:
returnType: string
signatures: [TIME.Format LAYOUT]
aliases: [/methods/time/format]
---
@@ -23,11 +18,8 @@ aliases: [/methods/time/format]
{{ $t.Format $format }} → 27 Jan 2023
```
{{% note %}}
To [localize](g) the return value, use the [`time.Format`] function instead.
[`time.Format`]: /functions/time/format/
{{% /note %}}
> [!note]
> To [localize](g) the return value, use the [`time.Format`] function instead.
Use the `Format` method with any `time.Time` value, including the four predefined front matter dates:
@@ -40,15 +32,12 @@ Use the `Format` method with any `time.Time` value, including the four predefine
{{ .Lastmod.Format $format }}
```
{{% note %}}
Use the [`time.Format`] function to format string representations of dates, and to format raw TOML dates that exclude time and time zone offset.
[`time.Format`]: /functions/time/format/
{{% /note %}}
> [!note]
> Use the [`time.Format`] function to format string representations of dates, and to format raw TOML dates that exclude time and time zone offset.
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}
## Examples
@@ -95,3 +84,5 @@ Use the [`humanize`](/functions/inflect/humanize) function to render the day of
{{ humanize $t.Day }} of {{ $t.Format "January 2006" }} → 27th of January 2023
```
[`time.Format`]: /functions/time/format/

View File

@@ -3,16 +3,10 @@ title: Hour
description: Returns the hour within the day of the given time.Time value, in the range [0, 23].
categories: []
keywords: []
action:
related:
- methods/time/Year
- methods/time/Month
- methods/time/Day
- methods/time/Minute
- methods/time/Second
- functions/time/AsTime
returnType: int
signatures: [TIME.Hour]
params:
functions_and_methods:
returnType: int
signatures: [TIME.Hour]
---
```go-html-template

View File

@@ -3,11 +3,10 @@ title: IsDST
description: Reports whether the given time.Time value is in Daylight Savings Time.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
returnType: bool
signatures: [TIME.IsDST]
params:
functions_and_methods:
returnType: bool
signatures: [TIME.IsDST]
---
```go-html-template

View File

@@ -3,11 +3,10 @@ title: IsZero
description: Reports whether the given time.Time value represents the zero time instant, January 1, year 1, 00:00:00 UTC.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
returnType: bool
signatures: [TIME.IsZero]
params:
functions_and_methods:
returnType: bool
signatures: [TIME.IsZero]
---
````go-html-template

View File

@@ -3,12 +3,10 @@ title: Local
description: Returns the given time.Time value with the location set to local time.
categories: []
keywords: []
action:
related:
- methods/time/UTC
- functions/time/AsTime
returnType: time.Time
signatures: [TIME.Local]
params:
functions_and_methods:
returnType: time.Time
signatures: [TIME.Local]
---
```go-html-template

View File

@@ -3,16 +3,10 @@ title: Minute
description: Returns the minute offset within the hour of the given time.Time value, in the range [0, 59].
categories: []
keywords: []
action:
related:
- methods/time/Year
- methods/time/Month
- methods/time/Day
- methods/time/Hour
- methods/time/Second
- functions/time/AsTime
returnType: int
signatures: [TIME.Minute]
params:
functions_and_methods:
returnType: int
signatures: [TIME.Minute]
---
```go-html-template

View File

@@ -3,16 +3,10 @@ title: Month
description: Returns the month of the year of the given time.Time value.
categories: []
keywords: []
action:
related:
- methods/time/Year
- methods/time/Day
- methods/time/Hour
- methods/time/Minute
- methods/time/Second
- functions/time/AsTime
returnType: time.Month
signatures: [TIME.Month]
params:
functions_and_methods:
returnType: time.Month
signatures: [TIME.Month]
---
To convert the `time.Month` value to a string:

View File

@@ -3,11 +3,10 @@ title: Nanosecond
description: Returns the nanosecond offset within the second of the given time.Time value, in the range [0, 999999999].
categories: []
keywords: []
action:
related:
- functions/time/AsTime
returnType: int
signatures: [TIME.Nanosecond]
params:
functions_and_methods:
returnType: int
signatures: [TIME.Nanosecond]
---
```go-html-template

View File

@@ -3,13 +3,10 @@ title: Round
description: Returns the result of rounding TIME to the nearest multiple of DURATION since January 1, 0001, 00:00:00 UTC.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
- functions/time/ParseDuration
- methods/time/Truncate
returnType: time.Time
signatures: [TIME.Round DURATION]
params:
functions_and_methods:
returnType: time.Time
signatures: [TIME.Round DURATION]
---
The rounding behavior for halfway values is to round up.

View File

@@ -3,16 +3,10 @@ title: Second
description: Returns the second offset within the minute of the given time.Time value, in the range [0, 59].
categories: []
keywords: []
action:
related:
- methods/time/Year
- methods/time/Month
- methods/time/Day
- methods/time/Hour
- methods/time/Minute
- functions/time/AsTime
returnType: int
signatures: [TIME.Second]
params:
functions_and_methods:
returnType: int
signatures: [TIME.Second]
---
```go-html-template

View File

@@ -3,11 +3,10 @@ title: Sub
description: Returns the duration computed by subtracting TIME2 from TIME1.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
returnType: time.Duration
signatures: [TIME1.Sub TIME2]
params:
functions_and_methods:
returnType: time.Duration
signatures: [TIME1.Sub TIME2]
---
```go-html-template

View File

@@ -3,13 +3,10 @@ title: Truncate
description: Returns the result of rounding TIME down to a multiple of DURATION since January 1, 0001, 00:00:00 UTC.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
- functions/time/ParseDuration
- methods/time/Round
returnType: time.Time
signatures: [TIME.Truncate DURATION]
params:
functions_and_methods:
returnType: time.Time
signatures: [TIME.Truncate DURATION]
---
The `Truncate` method operates on TIME as an absolute duration since the [zero time](g); it does not operate on the presentation form of the time. If DURATION is a multiple of one hour, `Truncate` may return a time with a non-zero minute, depending on the time zone.

View File

@@ -3,12 +3,10 @@ title: UTC
description: Returns the given time.Time value with the location set to UTC.
categories: []
keywords: []
action:
related:
- methods/time/Local
- functions/time/AsTime
returnType: time.Time
signatures: [TIME.UTC]
params:
functions_and_methods:
returnType: time.Time
signatures: [TIME.UTC]
---
```go-html-template

View File

@@ -1,15 +1,11 @@
---
title: Unix
description: Returns the given time.Time value expressed as the number of seconds elapsed since January 1, 1970 UTC.
description: Returns the given time.Time value expressed as the number of seconds elapsed since January 1, 1970 UTC.
categories: []
action:
related:
- methods/time/UnixMilli
- methods/time/UnixMicro
- methods/time/UnixNano
- functions/time/AsTime
returnType: int64
signatures: [TIME.Unix]
params:
functions_and_methods:
returnType: int64
signatures: [TIME.Unix]
aliases: [/functions/unix]
---

View File

@@ -1,16 +1,12 @@
---
title: UnixMicro
description: Returns the given time.Time value expressed as the number of microseconds elapsed since January 1, 1970 UTC.
description: Returns the given time.Time value expressed as the number of microseconds elapsed since January 1, 1970 UTC.
categories: []
keywords: []
action:
related:
- methods/time/Unix
- methods/time/UnixMilli
- methods/time/UnixNano
- functions/time/AsTime
returnType: int64
signatures: [TIME.UnixMicro]
params:
functions_and_methods:
returnType: int64
signatures: [TIME.UnixMicro]
---
See [Unix epoch](https://en.wikipedia.org/wiki/Unix_time).

View File

@@ -1,16 +1,12 @@
---
title: UnixMilli
description: Returns the given time.Time value expressed as the number of milliseconds elapsed since January 1, 1970 UTC.
description: Returns the given time.Time value expressed as the number of milliseconds elapsed since January 1, 1970 UTC.
categories: []
keywords: []
action:
related:
- methods/time/Unix
- methods/time/UnixMicro
- methods/time/UnixNano
- functions/time/AsTime
returnType: int64
signatures: [TIME.UnixMilli]
params:
functions_and_methods:
returnType: int64
signatures: [TIME.UnixMilli]
---
See [Unix epoch](https://en.wikipedia.org/wiki/Unix_time).

View File

@@ -1,16 +1,12 @@
---
title: UnixNano
description: Returns the given time.Time value expressed as the number of nanoseconds elapsed since January 1, 1970 UTC.
description: Returns the given time.Time value expressed as the number of nanoseconds elapsed since January 1, 1970 UTC.
categories: []
keywords: []
action:
related:
- methods/time/Unix
- methods/time/UnixMilli
- methods/time/UnixMicro
- functions/time/AsTime
returnType: int64
signatures: [TIME.UnixNano]
params:
functions_and_methods:
returnType: int64
signatures: [TIME.UnixNano]
---
See [Unix epoch](https://en.wikipedia.org/wiki/Unix_time).

View File

@@ -1,13 +1,12 @@
---
title: Weekday
description: Returns the day of the week of the given time.Time value.
description: Returns the day of the week of the given time.Time value.
categories: []
keywords: []
action:
related:
- functions/time/AsTime
returnType: time.Weekday
signatures: [TIME.Weekday]
params:
functions_and_methods:
returnType: time.Weekday
signatures: [TIME.Weekday]
---
To convert the `time.Weekday` value to a string:

View File

@@ -3,16 +3,10 @@ title: Year
description: Returns the year of the given time.Time value.
categories: []
keywords: []
action:
related:
- methods/time/Month
- methods/time/Day
- methods/time/Hour
- methods/time/Minute
- methods/time/Second
- functions/time/AsTime
returnType: int
signatures: [TIME.Year]
params:
functions_and_methods:
returnType: int
signatures: [TIME.Year]
---
```go-html-template

View File

@@ -3,10 +3,10 @@ title: YearDay
description: Returns the day of the year of the given time.Time value, in the range [1, 365] for non-leap years, and [1, 366] in leap years.
categories: []
keywords: []
action:
related: []
returnType: int
signatures: [TIME.YearDay]
params:
functions_and_methods:
returnType: int
signatures: [TIME.YearDay]
---
```go-html-template

View File

@@ -4,10 +4,4 @@ linkTitle: Time
description: Use these methods with time.Time values.
categories: []
keywords: []
menu:
docs:
identifier: time-methods
parent: methods
---
Use these methods with time.Time values.