1
0
mirror of https://github.com/golang/go synced 2024-11-15 11:20:30 -07:00

[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
»»»
This commit is contained in:
Gustavo Niemeyer 2012-04-12 22:16:31 -03:00
parent 18a71beb07
commit cd73d696d0

View File

@ -763,7 +763,9 @@ func (t Time) Unix() int64 {
} }
// UnixNano returns t as a Unix time, the number of nanoseconds elapsed // 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 { func (t Time) UnixNano() int64 {
return (t.sec+internalToUnix)*1e9 + int64(t.nsec) return (t.sec+internalToUnix)*1e9 + int64(t.nsec)
} }