Commit f699811c authored by Russ Cox's avatar Russ Cox

time: do not crash in String on nil Time

R=r
CC=golang-dev
https://golang.org/cl/2052041
parent 8d7ae528
...@@ -335,7 +335,12 @@ func (t *Time) Format(layout string) string { ...@@ -335,7 +335,12 @@ func (t *Time) Format(layout string) string {
} }
// String returns a Unix-style representation of the time value. // String returns a Unix-style representation of the time value.
func (t *Time) String() string { return t.Format(UnixDate) } func (t *Time) String() string {
if t == nil {
return "<nil>"
}
return t.Format(UnixDate)
}
var errBad = os.ErrorString("bad") // just a marker; not returned to user var errBad = os.ErrorString("bad") // just a marker; not returned to user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment