magico13 / PyEmVue

Python Library for the Emporia Vue Energy Monitor
MIT License
185 stars 36 forks source link

Date formatting #13

Closed tsuckow closed 1 year ago

tsuckow commented 3 years ago

You blindly append 'Z' to the end of datetimes which causes problems if the datetime has timezone information. (Such as trying to feed start_time from the output of one request into another)

I'm not sure if only Z is accepted by the api but it would probably be better to use timezone aware datetimes. To convert datetime aware datetimes to be utc without tzinfo I'm using start_time.astimezone(datetime.timezone.utc).replace(tzinfo=None)

magico13 commented 3 years ago

If you pass any other format to the API it errors out so that's why it's the way it is right now. I agree that I should add better handling so you can pass in tz aware datetimes and have it reformat them as needed.

magico13 commented 1 year ago

Doing some old issue cleanup. One of the previous releases improved this so that you can pass either unaware utc time or an aware time and it will handle formatting. I've tried to swap to using only aware times personally.