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

Allow specifying an explicit format in parse_date/parse_time #1131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Sep 22, 2024

Closes #1090

This uses parse_pattern internally when a custom format is used.

Copy link

codecov bot commented Sep 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.29%. Comparing base (313277a) to head (2b8e6b8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1131      +/-   ##
==========================================
+ Coverage   91.28%   91.29%   +0.01%     
==========================================
  Files          27       27              
  Lines        4623     4630       +7     
==========================================
+ Hits         4220     4227       +7     
  Misses        403      403              
Flag Coverage Δ
macos-12-3.10 90.06% <100.00%> (+0.01%) ⬆️
macos-12-3.11 90.00% <100.00%> (+0.01%) ⬆️
macos-12-3.12 90.21% <100.00%> (+0.01%) ⬆️
macos-12-3.13-dev 89.74% <100.00%> (+0.01%) ⬆️
macos-12-3.8 89.99% <100.00%> (+0.01%) ⬆️
macos-12-3.9 89.99% <100.00%> (+0.01%) ⬆️
macos-12-pypy3.10 90.06% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.10 90.08% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.11 90.02% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.12 90.23% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.13-dev 89.76% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.8 90.01% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.9 90.01% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-pypy3.10 90.08% <100.00%> (+0.01%) ⬆️
windows-2022-3.10 90.20% <100.00%> (+0.01%) ⬆️
windows-2022-3.11 90.14% <100.00%> (+0.01%) ⬆️
windows-2022-3.12 90.35% <100.00%> (+0.01%) ⬆️
windows-2022-3.13-dev 89.88% <100.00%> (+0.01%) ⬆️
windows-2022-3.8 90.13% <100.00%> (+0.01%) ⬆️
windows-2022-3.9 90.13% <100.00%> (+0.01%) ⬆️
windows-2022-pypy3.10 90.20% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor doc-related request, LGTM otherwise!

babel/dates.py Outdated
Comment on lines 1202 to 1207
This function first tries to interpret the string as ISO-8601
date format, then uses the date format for the locale as a hint to
determine the order in which the date fields appear in the string.

If an explicit format is provided, the function will use it to parse
the date instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should note that the ISO-8601 attempt isn't done when you use an explicit format. Might need to rephrase the whole thing to make that flow nicely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it up a bit so that it hopefully reads better now. Also added an example with an explicit format=....

@akx akx added this to the Babel 2.17 milestone Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parse functions should support a custom format
2 participants