Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Fix tzlocal dependency causing an exception #250

Merged
merged 2 commits into from
Sep 19, 2022
Merged

Fix tzlocal dependency causing an exception #250

merged 2 commits into from
Sep 19, 2022

Conversation

marcelvriend
Copy link
Contributor

Description

Some users have an issue with the localize_datetime method, as reported in custom-components/grocy#241.
This seems to be related to an issues with tzlocal get_localzone returning different types, see regebro/tzlocal#131.

Some existing dependencies, including tzlocal, can be replaced with Python built-in functions.

  • Remove pytz and tzlocal dependencies and use Python built-in function.

  • The localize_datetime method is inconsistent. For timezone aware datetime, it returns the datetime as is. For timezone unaware datetime, it assumes it is in the system's local timezone and returns it converted to UTC.
    Change method so it also returns a localized datetime when the specified datetime is timezone unaware.

  • Replace iso8601 dependency with Python built-in function. Change test to match the datetime string format returned by the Grocy API.

Checklist

  • The code change is tested and works locally.
  • tests pass. Your PR won't be merged unless tests pass
  • There is no commented out code in this PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants