golang/go

time: Time.Format does not provide space padding for numbers other than days

Open

#22,802 opened on Nov 18, 2017

View on GitHub
 (11 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
FeatureRequestNeedsInvestigationhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

I'm not sure I'm running the latest release of Go, but I just ran brew upgrade go on my macOS laptop and it says go 1.9.2 already installed.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

I was trying to make a library that gives programmers who wanted to use Python-like strftime method on time.Time a nice Strftime function. While writing test code to test if paddings are working, I found that there is no space(literal ) padding for 'month' and 'hour' but only 'day' haves it.

To explain what happens, here's Go playground's link: https://play.golang.org/p/cAgWgVD5Tu

As you can see underscore(_) layout string doesn't work for month, hour, minute and second.

What did you expect to see?

In the above playground, I expected 9 4 for month and day.

What did you see instead?

But I've got _9 4 instead. Same for month, hour, minute and second.

I would like to patch the time package and I'd like to know whether this issue has already issued or not. Thanks.

Contributor guide