Skip to content

Commit 2e4358c

Browse files
dmitshurrsc
authored andcommitted
[release-branch.go1.9] time: fix documentation of Round, Truncate behavior for d <= 0
Saying that they return t unchanged is misleading, because they return a modified t, stripped of any monotonic clock reading, as of Go 1.9. Fixes #21485. Change-Id: Icddf8813aed3d687fcefcd2fe542829438be6a0a Reviewed-on: https://go-review.googlesource.com/56690 Reviewed-by: Avelino <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-on: https://go-review.googlesource.com/70846 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Russ Cox <[email protected]>
1 parent c6388d3 commit 2e4358c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/time/time.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) T
13831383
}
13841384

13851385
// Truncate returns the result of rounding t down to a multiple of d (since the zero time).
1386-
// If d <= 0, Truncate returns t unchanged.
1386+
// If d <= 0, Truncate returns t stripped of any monotonic clock reading but otherwise unchanged.
13871387
//
13881388
// Truncate operates on the time as an absolute duration since the
13891389
// zero time; it does not operate on the presentation form of the
@@ -1400,7 +1400,7 @@ func (t Time) Truncate(d Duration) Time {
14001400

14011401
// Round returns the result of rounding t to the nearest multiple of d (since the zero time).
14021402
// The rounding behavior for halfway values is to round up.
1403-
// If d <= 0, Round returns t unchanged.
1403+
// If d <= 0, Round returns t stripped of any monotonic clock reading but otherwise unchanged.
14041404
//
14051405
// Round operates on the time as an absolute duration since the
14061406
// zero time; it does not operate on the presentation form of the

0 commit comments

Comments
 (0)