Skip to content

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

@hallazzang

Description

@hallazzang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions