Commit 524cd485 authored by Martin Möhrmann's avatar Martin Möhrmann Committed by Brad Fitzpatrick

time: simplify stringification of Month

Simplifies https://golang.org/cl/33145
which fixed #17720.

Change-Id: Ib922d493cdc5920832dc95b55094796baca7243e
Reviewed-on: https://go-review.googlesource.com/33194Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4bee9012
......@@ -118,13 +118,9 @@ func (m Month) String() string {
if January <= m && m <= December {
return months[m-1]
}
const prefix = "%!Month("
buf := make([]byte, 20+len(prefix)+1)
buf[len(buf)-1] = ')'
n := fmtInt(buf[:len(buf)-1], uint64(m))
n -= len(prefix)
copy(buf[n:], prefix)
return string(buf[n:])
buf := make([]byte, 20)
n := fmtInt(buf, uint64(m))
return "%!Month(" + string(buf[n:]) + ")"
}
// A Weekday specifies a day of the week (Sunday = 0, ...).
......
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