]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] time: panic if UnixNano is out of range
authorGustavo Niemeyer <gustavo@niemeyer.net>
Fri, 13 Apr 2012 01:16:31 +0000 (22:16 -0300)
committerGustavo Niemeyer <gustavo@niemeyer.net>
Fri, 13 Apr 2012 01:16:31 +0000 (22:16 -0300)
««« 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
»»»

src/pkg/time/time.go

index 473bc2a451625c11261ff0c42b41adb90270cbc5..f556166fe6c76e07505c633ac08b1e5f074806e5 100644 (file)
@@ -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)
 }