Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
Fixes #131
Add support for ordinal dates. These are the "day number" of the year. January 1st is day 1 of every year. The numbers change for leap years, meaning that you can have day 366 on leap years.
What approach did you choose and why?
ordinal_to_ymd
method inisocalendar.c
_days_before_month
and didn't seem worthord_to_ymd
, since that is cPython's implementation that assumes an ordinal date starting at January 1 year 1, and doesn't reset each yearWhen I first took over maintainership and added these benchmarking scripts, there was a comment from another parser maintainer that pointed out that it wasn't a fair comparison since the other parsers could parse more of the ISO 8601 spec. At the time, I addded these warnings/disclaimers throughout the code base.
But with this PR, we now support the same subset (or more) of ISO 8601 than the other parsers do. So I've removed the disclaimers, but kept the supported subset section. It's still there (no parser supports the full spec), but doesn't need to be called out specially anymore.
ciso8601
,backports.datetime_fromisoformat
, or the builtindatetime.fromisoformat
. 🎉What should reviewers focus on?
You can see the rendered version of the document here.
Performance for non-ordinal timestamps is imperceptibly impacted.
The impact of these changes
We no longer have to have disclaimers everywhere. The decision tree is simple.
Once a new release is done, we can update the StackOverflow answer