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: Parse of RFC3339 is incorrect for fractional second seperator #54571

Open
dsnet opened this issue Aug 21, 2022 · 4 comments
Open

time: Parse of RFC3339 is incorrect for fractional second seperator #54571

dsnet opened this issue Aug 21, 2022 · 4 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Aug 21, 2022

RFC 3339, section 5.6 specifies that the time-secfrac field must use a period.

However, Parse permits the use of commas:

Parse(time.RFC3339, "0000-01-01T00:00:00,0Z")

reports nil rather than an error.

@dsnet dsnet changed the title time: Parse of RFC3339 is incorrect for fractional second seperator #54569 time: Parse of RFC3339 is incorrect for fractional second seperator Aug 21, 2022
@dsnet
Copy link
Member Author

dsnet commented Aug 21, 2022

Unfortunately, this behavior is specified in the docs:

A comma or decimal point followed by one or more zeros represents a fractional second,
printed to the given number of decimal places.
A comma or decimal point followed by one or more nines represents a fractional second,
printed to the given number of decimal places, with trailing zeros removed.
For example "15:04:05,000" or "15:04:05.000" formats or parses with millisecond precision.

@seankhliao
Copy link
Member

seankhliao commented Aug 21, 2022

That is a relatively recent addition #6189, at some point in the past, we didn't support it #24860
Maybe it would be ok to roll it back for RFC3339

@dsnet
Copy link
Member Author

dsnet commented Aug 21, 2022

Yuck. In my opinion #6189 was a mistake. We probably should instead have allowed the format string to have a , where it means either , or ., while keeping the presence of . to only mean ..

@gopherbot
Copy link

gopherbot commented Aug 21, 2022

Change https://go.dev/cl/425045 mentions this issue: time: fix Parse regression of sub-second separator in RFC3339

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 24, 2022
@seankhliao seankhliao added this to the Go1.20 milestone Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants