From: Russ Cox Date: Thu, 2 Sep 2010 18:21:40 +0000 (-0400) Subject: time: do not crash in String on nil Time X-Git-Tag: weekly.2010-09-06~17 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f699811c14067387efec0f30a522274b9719b34a;p=gostls13.git time: do not crash in String on nil Time R=r CC=golang-dev https://golang.org/cl/2052041 --- diff --git a/src/pkg/time/format.go b/src/pkg/time/format.go index 8166d2e77a..355721e183 100644 --- a/src/pkg/time/format.go +++ b/src/pkg/time/format.go @@ -335,7 +335,12 @@ func (t *Time) Format(layout string) string { } // 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 "" + } + return t.Format(UnixDate) +} var errBad = os.ErrorString("bad") // just a marker; not returned to user