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

Make days-until handling timezone-aware #290

Closed

Conversation

mhemeryck
Copy link

Following discussion in #281

Issue for me is that the "days until" for the limburg.net integration is rendered one day too late in the future.

Regarding my home assistant install timing setup:

  • host system was on GMT -- now CET (Brussels time)
  • container has a timezone of Europe/Brussels, but this was not used.

After reading home assistant UTC & time zone awareness, it seems home assistant was already using UTC internally for quite some time (2015).

I think the proper fix thus is that all you'd use UTC time internally for all time computations, but render to local time where facing the outside world.

I have no idea though how this change will affect the other integrations, I suppose these all also have been assuming no timezone awareness.

On a practical note though, I suppose all of these integrations are either Dutch or Belgian? Perhaps it would just make sense to convert everything to that timezone instead?

@mhemeryck
Copy link
Author

Did try this both on my local system (local time CET) and within the container (UTC)

import datetime                                                                                                                                                                              
                                                                                                                                                                                             
item = {"date": "2022-01-17T12:47:23+01:00"}                                                                                                                                                 
d = datetime.datetime.strptime(item["date"], "%Y-%m-%dT%H:%M:%S%z").replace(tzinfo=None)                                                                                                     
(d - datetime.datetime.now()).days + 1 

On my own system, it gave back the correct result, but inside the UTC-only container, it did not (off by 1 day)

@mhemeryck mhemeryck marked this pull request as ready for review January 17, 2022 12:16
@pippyn
Copy link
Owner

pippyn commented Jan 17, 2022

Thanks for your contribution!

This will require all integrations to be changed though. As timezone-aware objects can not be compared to timezone-naive objects.

I'll have a look into the impact of this change.

@mhemeryck
Copy link
Author

This will require all integrations to be changed though. As timezone-aware objects can not be compared to timezone-naive objects.

I'll have a look into the impact of this change.

Yup, I was wondering the same thing and whether it'd be easier to just do the conversion directly from the limburg.net wastecollector instead.

I'm also wondering why it seems like it's specific to my setup 🤔

Anyways, thx for having a look into it!

@tnagels
Copy link

tnagels commented May 17, 2024

I seem to be having the same issue. Has any work been done on this?

@mhemeryck
Copy link
Author

I did create this PR already a couple of years ago, but nothing has happened since. As far as I know this issue is still open, Closing this PR for now, since it looks hopelessly outdated.

@mhemeryck mhemeryck closed this May 21, 2024
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.

None yet

3 participants