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

Rewrite parse_date util to not rely on strptime #522

Merged
merged 2 commits into from
Oct 24, 2023
Merged

Conversation

ludeeus
Copy link
Contributor

@ludeeus ludeeus commented Oct 19, 2023

strptime relies on the locale pacakge, which can easily be changed to invalid values by integrations like this https://github.com/BenPru/luxtronik/blob/576736e5c92cbce5f47d3523766f821e706bde8f/custom_components/luxtronik/base.py#L91.
Which makes our handling of dates invalid.

This PR switches the logic to use ciso8601.parse_datetime instead as this does not rely on strptime and the set locale.

hass_nabucasa/utils.py Outdated Show resolved Hide resolved
@ludeeus ludeeus requested a review from pvizeli October 19, 2023 07:38
Copy link
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Core will also have issues for this case in util.dt.parse_date. Wonder if core should patch locale.setlocale if there's no valid use case?

@ludeeus ludeeus merged commit fb0d640 into master Oct 24, 2023
2 checks passed
@ludeeus ludeeus deleted the no_strptime branch October 24, 2023 07:24
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