aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-09-02 14:21:40 -0400
committerRuss Cox <rsc@golang.org>2010-09-02 14:21:40 -0400
commitf699811c14067387efec0f30a522274b9719b34a (patch)
tree6f4b3ab1fb025b52cb2958a3bcd9864b0e868bbe
parent8d7ae528bfe295cce6a7a72eee9eb187ad28c23d (diff)
downloadgo-f699811c14067387efec0f30a522274b9719b34a.tar.gz
go-f699811c14067387efec0f30a522274b9719b34a.zip
time: do not crash in String on nil Time
R=r CC=golang-dev https://golang.org/cl/2052041
-rw-r--r--src/pkg/time/format.go7
1 files changed, 6 insertions, 1 deletions
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 "<nil>"
+ }
+ return t.Format(UnixDate)
+}
var errBad = os.ErrorString("bad") // just a marker; not returned to user