-
Notifications
You must be signed in to change notification settings - Fork 18k
time: decimal comma not supported in fractional seconds #6189
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
Here is what I wrote in mail responding to a CL to fix this: Thanks for filing the issue but I might prefer to leave it unaddressed for the moment. Proper locale treatment is coming (I hope soon) and this seems like the wrong place to start insinuating special locale handling into the standard library. Strconv can't do it yet, for instance. I'll mark the bug as to be fixed for Go 1.3. Labels changed: added go1.3, removed go1.2maybe. |
I'm not sure this is just a localization issue. According to http://en.wikipedia.org/wiki/ISO_8601 the latest version (ISO 8601:2004(E)) suggests that a comma is the preferred separator, which means some software will use a comma even when not localized. As a real life use case, I'm currently trying to parse a log file generated by log4j where the most commonly used date formatters use a comma (eg: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/helpers/ISO8601DateFormat.html) |
Would a PR be welcome to add this functionality? We have a workaround in our codebase but it'd be great to have support in the standard library. |
@alanctgardner, if you already have a fix, feel free to send it so we can see how invasive it might be. @mpvl, this bug was punted in 2013 because proper locale support was coming. Is it still coming? |
CL https://golang.org/cl/23063 mentions this issue. |
Date localization is definitely still in the planning, but fairly low on the priority list at the moment. Extraction, segmentation, numbers, among other things are higher on the list right now. That said, I think it is not unreasonable for the standard lib to support case 2 of the play example: The third case: |
That makes sense to me - the patch I uploaded doesn't support using a comma where a period is specified in the format string (and vice versa). That does seem like localization. The patch does support the case where there's no fractional seconds part in the format but there are fractional seconds with a comma in the string, like: {"2006-01-02 15:04:05", "2013-08-19 22:56:01,234"} but I would be willing to remove that if it's too localization-related. The real crux of the issue is that there's no way to parse a date that uses a comma as a delimiter using any format string. |
I am completely new to Go, thanks for this Issue which saved me a ton of time. I ended up strings-Replace'ing the log4j-comma. |
In https://golang.org/cl/23063 @robpike said:
But the next day @mpvl said there:
That sends a mixed message. Can you please decide about if you want to support My use-case: I parse supervisord log, and there is no way to configure timestamps format. |
golang does not support fraction of sec time layout using coma (,) - golang/go#6189. This is a work around.
I am using @grafana 's promtail to parse logs from java, python and go applications. Not all of them use the same format that go assumes as "neutral" and "unlocalized". @AlekSi and @actgardner have strong points I could expect apps not being flexible enough to configure log formatting, but not the programming language behind any of them. IMO, little bugs like this make golang much less attractive for developers looking for a versatile language. Regarding localization, claiming that using a english standard like decimal dot is "unlocalized" sounds pretty colonialist, and the fact that "proper localization" is still coming, tells to me that diversity for different languages and cultures is totally not a priority for @golang As constructive data, I analyzed a bit the linux
So adding latin and arabic comma would be a great step. |
I have the same problem with colon delimiter before fraction of a second. cannot parse "466" as ".000"" |
I find it hard to understand why this is a localization issue. Using comma as the millisecond delimiter is the default format used by https://logging.apache.org/log4j/2.x/manual/garbagefree.html#Layouts |
This is absolutely not a localization issue. It's a developer usability issue. let's say I have a timestamps like the following:
The first one, I can parse, the rest I cannot. It doesn't matter at all that some other maniac developer is feeding me a timestamp format that makes no sense at all, and is non standard as hell. The pattern matching technique in go is just bad, and inflexible. Microsoft Excel has a better mechanism, see: here. Get it together people. |
Now under consideration in proposal: #36145 |
Change https://golang.org/cl/300996 mentions this issue: |
Change https://golang.org/cl/345438 mentions this issue: |
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. Fixes #48037 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]>
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]>
Unfortunately, this change broke compliance with RFC 3339, where we now permit Given that RFC 3339 is more common than ISO 8601, I think it was a mistake to loosen this behavior. In my opinion it would have been better to introduce a |
Change https://go.dev/cl/425045 mentions this issue: |
by dmitri.m:
The text was updated successfully, but these errors were encountered: