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

Fix parse_with() #33

Merged
merged 7 commits into from
Mar 25, 2023
Merged

Fix parse_with() #33

merged 7 commits into from
Mar 25, 2023

Conversation

kdwarn
Copy link
Contributor

@kdwarn kdwarn commented Mar 18, 2023

I have been using the dateparser library in developing a project of mine (https://codeberg.org/kdwarn/ts-cli) and found a bug with the parse_with function. As detailed in an issue there (https://codeberg.org/kdwarn/ts-cli/issues/18), it wasn't converting correctly to UTC. Essentially, the default_time parameter to Parse::new needs to be different if using parse and parse_with_timezone or if using parse_with. The solution I came up with was to change Parse struct's field default_time to an Option<NaiveTime> rather than a NaiveTime, and then in the various functions either use the provided default_time if given or create one at that time. Given this, I imagine you'll want to do a version bump.

In the existing code, there were only doctests that covered parse_with (no separate unit tests), and at least one was failing. I wrote out what I think to be a fairly comprehensive set of units tests, and both they and the doctests are now passing. I had to modify a lot of tests to account for changing default_time from NaiveTime to Option<NativeTime>.

Note that I also bumped to the new 2021 edition of Rust, and there seems to be no issues with that.

Also, I explicitly bumped to 0.4.24 of chrono, and then turned off deprecation warnings, as there are many. I figure they can be addressed separately after this.

kdwarn added 5 commits March 16, 2023 08:45
ymd_z() for parse_with still needs to be fixed - tests with it are
failing and those are currently commented out.

Ignore deprecation warnings for now - come back to that after
finishing resolving issue ymd_z (as separate pull request).
@waltzofpearls
Copy link
Owner

Hey @kdwarn, thanks for the PR! I will have a look when I get home.

@kdwarn
Copy link
Contributor Author

kdwarn commented Mar 18, 2023

To be clear, dateparser's tests are passing. I did not look at belt itself.

@kdwarn
Copy link
Contributor Author

kdwarn commented Mar 24, 2023

Ok, clippy shouldn’t complain anymore.

If you want, I can squash this all into one commit.

@waltzofpearls
Copy link
Owner

@kdwarn Thanks for fixing the linter warnings. I will squash the commits when merging the PR. I had a look at your PR. Looks good to me. I'm working on fixing belt tests in a separate branch.

Copy link
Owner

@waltzofpearls waltzofpearls left a comment

Choose a reason for hiding this comment

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

👍

@waltzofpearls waltzofpearls merged commit 7111b1a into waltzofpearls:main Mar 25, 2023
@kdwarn
Copy link
Contributor Author

kdwarn commented Mar 25, 2023

Excellent!

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.

2 participants