aboutsummaryrefslogtreecommitdiff
path: root/src/time
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-07-19 15:09:21 -0700
committerBenny Siegert <bsiegert@gmail.com>2022-09-28 09:05:54 +0000
commit2c4c2a5106e16a2ef51e3fc1d846e5d75d7ee6cc (patch)
treeadde2cef122a14b9374f3535ea22a59dc6eaddce /src/time
parentd268504fd90063328f484152585189db8374930d (diff)
downloadgo-2c4c2a5106e16a2ef51e3fc1d846e5d75d7ee6cc.tar.xz
time: add comment explaining >>33 in Now
Change-Id: I022b617cd345b412bee0b50a862676a1dca94e01 Reviewed-on: https://go-review.googlesource.com/c/go/+/418376 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/time')
-rw-r--r--src/time/time.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/time/time.go b/src/time/time.go
index 0cd7a7e8a2..5da61510c1 100644
--- a/src/time/time.go
+++ b/src/time/time.go
@@ -1112,6 +1112,9 @@ func Now() Time {
mono -= startNano
sec += unixToInternal - minWall
if uint64(sec)>>33 != 0 {
+ // Seconds field overflowed the 33 bits available when
+ // storing a monotonic time. This will be true after
+ // March 16, 2157.
return Time{uint64(nsec), sec + minWall, Local}
}
return Time{hasMonotonic | uint64(sec)<<nsecShift | uint64(nsec), mono, Local}