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

Add try_to_rfc3339 and to_iso8601, deprecate to_rfc3339 #1331

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pitdicker
Copy link
Collaborator

Split out from #1144.

RFC 3339 is not defined for dates with a year outside of 0..=9999 (like RFC 2822). ISO 8601 does support it.

DateTime::to_rfc3339 was a hybrid method, claiming to format a datetime as both valid RFC 3339 and ISO 8601. It would write invalid RFC 3339 strings if the year is out of range, which could not be parsed by DateTime::parse_from_rfc3339.

I propose to deprecate to_rfc3339, and replace it with two methods: try_to_rfc3339 and to_iso8601.

I did not make to_rfc3339 panic on out-of-range dates like to_rfc2822, to not break existing uses.
It is deprecated with the message: "Produces invalid data on years outside of the range 0..=9999. Use try_to_rfc3339() or to_iso8601 instead."

For DateTime::to_rfc3339_opts and the RFC3339 formatting item (used for "%+") I only made some documentation adjustments that they format the value an ISO 8601 representation when the year is out of range.

@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Attention: Patch coverage is 96.07843% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 91.80%. Comparing base (3114597) to head (5b394dd).

❗ Current head 5b394dd differs from pull request most recent head 37f8e74. Consider uploading reports for the commit 37f8e74 to get more accurate results

Files Patch % Lines
src/datetime/mod.rs 92.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1331      +/-   ##
==========================================
- Coverage   91.80%   91.80%   -0.01%     
==========================================
  Files          40       40              
  Lines       18329    18360      +31     
==========================================
+ Hits        16827    16855      +28     
- Misses       1502     1505       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

1 participant