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

[bug] chrono does not print FixedOffset seconds #1154

Closed
grantslatton opened this issue Jun 24, 2023 · 2 comments
Closed

[bug] chrono does not print FixedOffset seconds #1154

grantslatton opened this issue Jun 24, 2023 · 2 comments

Comments

@grantslatton
Copy link

This code

let offset = FixedOffset::east_opt(1).unwrap();
let dt = NaiveDate::from_ymd(2021, 1, 1).and_hms(0, 0, 0);
let dt = DateTime::<FixedOffset>::from_local(dt, offset);
dbg!(dt.offset());
dbg!(dt.to_rfc3339());

Prints:

dt.offset() = +00:00:01
dt.to_rfc3339() = "2021-01-01T00:00:00+00:00"

Note that the RFC3339 only has +HH:MM, +00:00 but should be +00:00:01.

This is because the code delegates to write_local_minus_utc which explicitly ignores seconds.

This bug makes chrono out of compliance with RFC3339.

@pitdicker
Copy link
Collaborator

It is unclear to me what you consider the issue.

But an offset with seconds is indeed difficult, as encoding it is not supported by RFC 3339, ISO 8601 or RFC 2822.
You can format it with %::z.

@grantslatton
Copy link
Author

Ah, I discovered this by comparing the result of chrono::DateTime::to_rfc3339 to Python's datetime.datetime.isoformat which claims to be 8601, but I guess it is Python that is out of compliance here by showing the second-level offsets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants