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

DateTime::parse_from_str not equivalent to TimeZone::datetime_from_str #93

Closed
Mark-Simulacrum opened this issue Aug 26, 2016 · 3 comments

Comments

@Mark-Simulacrum
Copy link

DateTime::parse_from_str will parse Mon Mar 14 08:32:45 2016 -0700, but TimeZone::datetime_from_str will not.

Relevant IRC conversation starts here: https://botbot.me/mozilla/rust-tools/2016-08-26/?msg=71963735&page=1

@pitdicker
Copy link
Collaborator

The irc logs are no longer available. But I think the issue is in how TimeZone::datetime_from_str works. From the documentation:
"If the to-be-parsed string includes an offset, it must match the offset of the TimeZone, otherwise an error will be returned."

So with TimeZone::datetime_from_str before parsing a string that includes an offset, you are expected to know the time zone. I.e. you have to know the offset before parsing a string as FixedOffset.

Also in the case of time zones like provided by chrono_tz parsing may fail even when you know the time zone, because the offset may have changed with a new revision of the time zone database.

I don't really see any use case where you would want to use TimeZone::datetime_from_str over DateTime::parse_from_str.

@djc
Copy link
Contributor

djc commented Sep 2, 2023

I don't really see any use case where you would want to use TimeZone::datetime_from_str over DateTime::parse_from_str.

Should we deprecate the shit out of it?

@pitdicker
Copy link
Collaborator

🤣 With pleasure #1251.

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

No branches or pull requests

3 participants