-
Notifications
You must be signed in to change notification settings - Fork 18k
time: ParseInLocation does not adjust timezone offset when seconds are not explicitly set #53919
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
Change https://go.dev/cl/417934 mentions this issue: |
The second zone offset: https://go.dev/play/p/ivhN_nsQ_qB See also #37277 |
cc @rsc |
Thank you, @seankhliao. Yes, I realize that. The expectation was that BTW I encountered the error when writing custom JSON marshalling and unmarshalling of an object that has a field for the time and a timezone string. For the API client to work, times have to be marshalled using standard |
It seems to me that this problem occurs because the tzdata database says that the timezone for Asia/Shanghai in 1900 is So I don't think that there is anything to do here. Code that needs to worry about these old dates for which the timezone database uses second offsets can check the timezone offset via |
Closing as there appears to be nothing to do |
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 ran into an issue where a
time.Time
object was seconds off after having been converted into a string usingFormat
withRFC3339
and back usingParseInLocation
.https://go.dev/play/p/5t8wa3b_ahv
What did you expect to see?
The test above succeeding, i.e. when I explicitly state my desired location that go is smart enough to adjust the seconds.
What did you see instead?
The test failing.
This is because the parsed time zone differs mere seconds from the desired time zone and
RFC3339
expresses a time zone only in hours and minutes.The text was updated successfully, but these errors were encountered: