-
Notifications
You must be signed in to change notification settings - Fork 18k
time: output does not respect comma as millisecond separator #48037
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
Comments
Its behavior is changed by this commit f02a26b |
Change https://golang.org/cl/345438 mentions this issue: |
Please consider backporting it into 1.17. |
@gopherbot please consider backporting it into 1.17. Thanks. |
Backport issue(s) opened: #48177 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/350149 mentions this issue: |
…seconds into Format In CL 300996 that fixed issue #6189, we made Parse recognize "," as a separator for fractional seconds. However, we didn't modify Format to propagate the separator verbatim from Parse. Without this change, we break prior functionality that relied on a comma being used in Format. For #48037 Fixes #48177 Change-Id: I6565a25e8657ca3747a58b25acba58f27cdcddc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/345438 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]> Trust: Cherry Mui <[email protected]> (cherry picked from commit e1c3f21) Reviewed-on: https://go-review.googlesource.com/c/go/+/350149 Trust: Ian Lance Taylor <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I used
time.Format
to format a time including milliseconds with layout string"15:04:05,000"
. Before go 1.17, the comma was not recognized as separator for milliseconds and the string,000
was added to the format output verbatim. The result was for example23:00:12,000
. Since go 1.17, the comma is recognized as separator for milliseconds, but changed to a period in the output. The result now is for example23:00:12.345
. I expect the result respect the comma in the layout string and getting23:00:12,345
.Having the zeros replaced with the actual milliseconds changed the behavior to previous versions but is an improvement from my perspective. But, the changed behavior regarding the comma as separator breaks existing code that relies on a comma being used, e.g., because it is parsed by some other system later on.
Example code: https://play.golang.org/p/Bq6p4dxqhgG
What did you expect to see?
23:00:12,345
(or
23:00:12,000
as in go <1.17)What did you see instead?
23:00:12.345
The text was updated successfully, but these errors were encountered: