-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time: Time.Format does not provide space padding for numbers other than days #22802
Comments
Well, this is documented at least:
Up to @robpike to decide whether to extend it to support other things. |
Yes, and I've found another thing that 24-hour based hour cannot represented without padding since |
It does seem inconsistent but is it a common enough case to worry about? No one has noticed the issue before and it's easy to fix by post-processing. What do others think? |
Well I was surprised that no one has noticed this issue but me, I think the reason is that the zero padding fits well for almost every usecases. But in my opinion a consistency for standard packages matters a lot, would it be good to patch it by myself and send a pull request to this repository? I've never contributed to this large repository before, though. |
This repository does not accept pull requests directly. Please see https://golang.org/doc/contribute.html |
Thank you. I'll read it and get on my work soon! |
By the way, how do you think about the 24-based hour's no-padding( |
Change https://golang.org/cl/78735 mentions this issue: |
Rob will review. |
@rsc Anything should I do for now? |
… day but others As mentioned in #22802, only day component of layout string has space padding(represented by one underscore before its placeholder). This commit expands the rule for month, hour, minute and second. Updates #22802 (maybe fixes it) Change-Id: I886998380489862ab9a324a6774f2e4cf7124122 Reviewed-on: https://go-review.googlesource.com/78735 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Change https://golang.org/cl/85998 mentions this issue: |
CL 78735 description: time: add space padding layout strings(using underscore) for not only day but others As mentioned in #22802, only day component of layout string has space padding(represented by one underscore before its placeholder). This commit expands the rule for month, hour, minute and second. Updates #22802 (maybe fixes it) Revert this CL because it breaks currently working formats that happen to use underscores. Fixes #23259 Change-Id: I64acaaca9b5b74785ee0f0be7910574e87daa649 Reviewed-on: https://go-review.googlesource.com/85998 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rob Pike <r@golang.org>
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 saysgo 1.9.2 already installed
.What operating system and processor architecture are you using (
go env
)?What did you do?
I was trying to make a library that gives programmers who wanted to use Python-like
) padding for 'month' and 'hour' but only 'day' haves it.
strftime
method ontime.Time
a niceStrftime
function. While writing test code to test if paddings are working, I found that there is no space(literalTo 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.The text was updated successfully, but these errors were encountered: