-
Notifications
You must be signed in to change notification settings - Fork 18k
time: doesn't parse RFC3339 properly #9346
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
@aniketawati How did you resolve this? |
For posterity: the time package docs describe this layout conversion with the Z (near the bottom of the linked section), which is that it shows "Z" instead of a time offset if the timezone is UTC, and +hh:mm or -hh:mm otherwise. Since this is one of the few examples of the reference time format not being an actually valid time, I can see the confusion. |
Maybe the docs should be updated to reflect the insight shared by @firba1 ?? |
@mdwhatcott firba1 is citing the docs, so I'm not sure what to change. I would encourage you to send in a change if you see how to make the docs better (https://golang.org/doc/contribute.html). |
Thanks for the encouragement @ianlancetaylor. I received a good answer on stackoverflow just today that was more helpful for me than the docs, probably because it used complete real examples and was specific to the particular layout string I was using:
|
For #9346 #22135 explicitly state under layout constants that they are not valid time values for Parse. Also add examples of parsing valid RFC3339 values and the layout to the example for time.Parse. Fix capitalisation of time.Parse and Time.Format. For #20869 include RFC3339 in the list of layouts that do not accept all the time formats allowed by RFCs (lowercase z). This does not fully address #20869. Fixes #9346 Fixes #22135 Change-Id: Ia4c13e5745de583db5ef7d5b1688d7768bc42c1b Reviewed-on: https://go-review.googlesource.com/74231 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Time can't parse the layout constant for RFC3339 in the code itself.
For eg. Go playground link - http://play.golang.org/p/EJH53M__AH
Currently if there is any offset in time (non UTC time), time formats it in RFC3339 as - +07:00 instead of Z07:00
If Z07:00 is given, it gives an error
The text was updated successfully, but these errors were encountered: