This repository was archived by the owner on Apr 23, 2024. It is now read-only.
Fix tzlocal dependency causing an exception #250
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andtzlocal
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