From 524cd4855e11a26d07a7ca7ee45d3bee38c54425 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20M=C3=B6hrmann?= Date: Sat, 12 Nov 2016 20:08:02 +0100 Subject: [PATCH] time: simplify stringification of Month Simplifies https://golang.org/cl/33145 which fixed #17720. Change-Id: Ib922d493cdc5920832dc95b55094796baca7243e Reviewed-on: https://go-review.googlesource.com/33194 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/time/time.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/time/time.go b/src/time/time.go index 00fafb64dd..10b32461e1 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -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, ...). -- 2.50.0