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

feat: Allow for to_datetime / strftime to automatically parse dates with single-digit hour/minute/second #20144

Merged
merged 6 commits into from
Dec 6, 2024

Conversation

wsyxbcl
Copy link
Contributor

@wsyxbcl wsyxbcl commented Dec 4, 2024

To accommodate the default datetime format used by Excel in certain regional settings (e.g., China), as discussed in #16092

closes #16092

The format mentioned in the original issue is actually H:m, with seconds omitted. However, since the seconds component is already optional in the current pattern, adding support for single-digit seconds shouldn't cause any issues.

@wsyxbcl wsyxbcl changed the title add infer pattern to match H:m:s time format fix[rust]: add infer pattern to match H:m:s time format Dec 4, 2024
@wsyxbcl
Copy link
Contributor Author

wsyxbcl commented Dec 4, 2024

@MarcoGorelli

@wsyxbcl wsyxbcl changed the title fix[rust]: add infer pattern to match H:m:s time format feat[rust]: add infer pattern to match H:m:s time format Dec 4, 2024
@wsyxbcl wsyxbcl changed the title feat[rust]: add infer pattern to match H:m:s time format feat(rust): add infer pattern to match H:m:s time format Dec 4, 2024
@wsyxbcl wsyxbcl changed the title feat(rust): add infer pattern to match H:m:s time format feat(rust): Add infer pattern to match H:m:s time format Dec 4, 2024
@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature rust Related to Rust Polars and removed title needs formatting labels Dec 4, 2024
@MarcoGorelli
Copy link
Collaborator

thanks - can you add a test please?

@wsyxbcl
Copy link
Contributor Author

wsyxbcl commented Dec 4, 2024

thanks - can you add a test please?

Thanks for reminding

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.63%. Comparing base (bcfa7ec) to head (52ced94).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20144      +/-   ##
==========================================
+ Coverage   79.57%   79.63%   +0.06%     
==========================================
  Files        1563     1564       +1     
  Lines      217395   217448      +53     
  Branches     2472     2473       +1     
==========================================
+ Hits       172986   173169     +183     
+ Misses      43841    43710     -131     
- Partials      568      569       +1     

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

@wsyxbcl
Copy link
Contributor Author

wsyxbcl commented Dec 5, 2024

@MarcoGorelli Is there anything else I can do? Take a look if you have a moment :)

Copy link
Collaborator

@alexander-beedie alexander-beedie left a comment

Choose a reason for hiding this comment

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

Could you make a (tiny) update to the regex?
(Added a comment inline about it).

crates/polars-time/src/chunkedarray/string/infer.rs Outdated Show resolved Hide resolved
@MarcoGorelli MarcoGorelli changed the title feat(rust): Add infer pattern to match H:m:s time format feat: Allow for try_parse_dates to parse dates with single-digit hour/minute Dec 5, 2024
@github-actions github-actions bot added the python Related to Python Polars label Dec 5, 2024
@MarcoGorelli MarcoGorelli changed the title feat: Allow for try_parse_dates to parse dates with single-digit hour/minute feat: Allow for to_datetime / strftime to automatically parse dates with single-digit hour/minute/second Dec 5, 2024
Copy link
Collaborator

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @wsyxbcl

I think this should be good - leaving open a bit in case anyone else has objections, then will ship it (edit @alexander-beedie gonna need you to approve too since you requested changes)

@ritchie46 ritchie46 merged commit 370a02e into pola-rs:main Dec 6, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CsvReader cannot parse datetime 2016/1/1 0:00 in csv file.
4 participants