aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2012-04-12 22:16:31 -0300
committerGustavo Niemeyer <gustavo@niemeyer.net>2012-04-12 22:16:31 -0300
commitcd73d696d041d492a6a31bc02a895740c022c9bc (patch)
tree9ca5858cb6cd837aaf6d9187fe54585e12e30656
parent18a71beb07d845176fcab6711b766eeee4d35d46 (diff)
downloadgo-cd73d696d041d492a6a31bc02a895740c022c9bc.tar.gz
go-cd73d696d041d492a6a31bc02a895740c022c9bc.zip
[release-branch.go1] time: panic if UnixNano is out of range
««« backport 4ed98a6b6fe5 time: panic if UnixNano is out of range R=golang-dev, remyoudompheng, dsymonds, gustavo, dchest, r, rsc CC=golang-dev https://golang.org/cl/5985059 »»»
-rw-r--r--src/pkg/time/time.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pkg/time/time.go b/src/pkg/time/time.go
index 473bc2a451..f556166fe6 100644
--- a/src/pkg/time/time.go
+++ b/src/pkg/time/time.go
@@ -763,7 +763,9 @@ func (t Time) Unix() int64 {
}
// UnixNano returns t as a Unix time, the number of nanoseconds elapsed
-// since January 1, 1970 UTC.
+// since January 1, 1970 UTC. The result is undefined if the Unix time
+// in nanoseconds cannot be represented by an int64. Note that this
+// means the result of calling UnixNano on the zero Time is undefined.
func (t Time) UnixNano() int64 {
return (t.sec+internalToUnix)*1e9 + int64(t.nsec)
}