Debian Codegraph @

docs/content/en/methods/time/Round.md

raw
1 ---
2 title: Round
3 description: Returns the result of rounding TIME to the nearest multiple of DURATION since January 1, 0001, 00:00:00 UTC.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: time.Time
9 signatures: [TIME.Round DURATION]
10 ---
11
12 The rounding behavior for halfway values is to round up.
13
14 The `Round` 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, `Round` may return a time with a non-zero minute, depending on the time zone.
15
16 ```go-html-template
17 {{ $t := time.AsTime "2023-01-27T23:44:58-08:00" }}
18 {{ $d := time.ParseDuration "1h" }}
19
20 {{ ($t.Round $d).Format "2006-01-02T15:04:05-00:00" }} → 2023-01-28T00:00:00-00:00
21 ```