Skip to content
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: RFC3339Nano Z is invalid for offset according to RFC3339 #44064

Closed
Aulilino opened this issue Feb 2, 2021 · 5 comments
Closed

time: RFC3339Nano Z is invalid for offset according to RFC3339 #44064

Aulilino opened this issue Feb 2, 2021 · 5 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@Aulilino
Copy link

Aulilino commented Feb 2, 2021

the code: RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"

RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"

In the definition of RFC3339(https://www.ietf.org/rfc/rfc3339.txt), there is a clear explanation of character “Z”. It means no UTC offset when "Z" appeared.

      Z           A suffix which, when applied to a time, denotes a UTC
                  offset of 00:00; often spoken "Zulu" from the ICAO
                  phonetic alphabet representation of the letter "Z".
@seankhliao
Copy link
Member

This is used to trigger different printing behaviour, from the docs:

Replacing the sign in the format with a Z triggers the ISO 8601 behavior of printing Z instead of an offset for the UTC zone.

I think this is working as intended?

@seankhliao seankhliao changed the title time/format.go the format of RFC3339Nano may be incorrect time: RFC3339Nano Z is invalid for offset according to RFC3339 Feb 2, 2021
@ianlancetaylor
Copy link
Contributor

Please show us a small working code example that demonstrates the problem. Right now I don't see it. Thanks.

@ianlancetaylor ianlancetaylor added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 2, 2021
@Aulilino
Copy link
Author

Aulilino commented Feb 3, 2021

According to RFC3339, it means NO offset, when Z exists in the format.

The correct format should be "2006-01-02T15:04:05.999999999", "2006-01-02T15:04:05.999999999+07:00" or ""2006-01-02T15:04:05.999999999-07:00""

@seankhliao
Copy link
Member

time.RFC3339Nano is a layout string, not a time

Some valid layouts are invalid time values for time.Parse, due to formats such as _ for space padding and Z for zone information.

@Aulilino
Copy link
Author

Aulilino commented Feb 3, 2021

Got it. Seems I got it wrong. Thanks.

@Aulilino Aulilino closed this as completed Feb 3, 2021
@golang golang locked and limited conversation to collaborators Feb 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants