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

Fix wrong time format #98

Merged
merged 4 commits into from
Dec 15, 2022
Merged

Fix wrong time format #98

merged 4 commits into from
Dec 15, 2022

Conversation

tklecka
Copy link
Contributor

@tklecka tklecka commented Dec 15, 2022

closes #97
home-assistant/core#83988

as @steinerl said
it looks like the ZAMG changed their timestamp format.
I'm also not sure if this is a permanent change...

@killer0071234 killer0071234 added the bug Something isn't working label Dec 15, 2022
@killer0071234
Copy link
Owner

Please change also the test data in data_station.json

@tklecka
Copy link
Contributor Author

tklecka commented Dec 15, 2022

Please change also the test data in data_station.json

Sorry didn't see that, WIP

@steinerl
Copy link

The metadata timestamp format has also changed, which means that data_metadata.json is basically also incorrect.

@tklecka
Copy link
Contributor Author

tklecka commented Dec 15, 2022

The metadata timestamp format has also changed, which means that data_metadata.json is basically also incorrect.

True, but I don't think the dates from the metadata are used anywhere. I have changed them in the data_metadata.json, just in case.

@steinerl
Copy link

steinerl commented Dec 15, 2022

@killer0071234 also curious why you don't parse the timezone offset like so %Y-%m-%dT%H:%M%z and instead use the hardcoded +00:00 and set the time zone to Europe/Vienna afterwards, which means that the timestamps are incorrect (off by the Viennese time zone offset).
Any particular reason?

>>> fixed_tz = datetime.strptime("2022-12-15T10:30+00:00", "%Y-%m-%dT%H:%M+00:00").replace(tzinfo=zoneinfo.ZoneInfo("Europe/Vienna"))
datetime.datetime(2022, 12, 15, 10, 30, tzinfo=zoneinfo.ZoneInfo(key='Europe/Vienna'))

>>> parsed_tz = datetime.strptime("2022-12-15T10:30+00:00", "%Y-%m-%dT%H:%M%z")
datetime.datetime(2022, 12, 15, 10, 30, tzinfo=datetime.timezone.utc)

>>> parsed_tz - fixed_tz
datetime.timedelta(seconds=3600)

@killer0071234
Copy link
Owner

@killer0071234 also curious why you don't parse the timezone offset like so %Y-%m-%dT%H:%M%z and instead use the hardcoded +00:00 and set the time zone to Europe/Vienna afterwards, which means that the timestamps are incorrect (off by the Viennese time zone offset). Any particular reason?

>>> fixed_tz = datetime.strptime("2022-12-15T10:30+00:00", "%Y-%m-%dT%H:%M+00:00").replace(tzinfo=zoneinfo.ZoneInfo("Europe/Vienna"))
datetime.datetime(2022, 12, 15, 10, 30, tzinfo=zoneinfo.ZoneInfo(key='Europe/Vienna'))

>>> parsed_tz = datetime.strptime("2022-12-15T10:30+00:00", "%Y-%m-%dT%H:%M%z")
datetime.datetime(2022, 12, 15, 10, 30, tzinfo=datetime.timezone.utc)

>>> parsed_tz - fixed_tz
datetime.timedelta(seconds=3600)

This part of the code I took over from the old Zamg integration, and did not dig into it that deep

@killer0071234
Copy link
Owner

The metadata timestamp format has also changed, which means that data_metadata.json is basically also incorrect.

True, but I don't think the dates from the metadata are used anywhere. I have changed them in the data_metadata.json, just in case.

That's true, this part is just copied in from a real reply and we are just using the possible stations out of it.

@codecov-commenter
Copy link

Codecov Report

Base: 95.54% // Head: 95.54% // No change to project coverage 👍

Coverage data is based on head (bdcf9e5) compared to base (1ee4fcf).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #98   +/-   ##
=======================================
  Coverage   95.54%   95.54%           
=======================================
  Files           3        3           
  Lines         157      157           
  Branches       22       22           
=======================================
  Hits          150      150           
  Misses          5        5           
  Partials        2        2           
Impacted Files Coverage Δ
src/zamg/zamg.py 95.17% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

src/zamg/zamg.py Outdated Show resolved Hide resolved
@killer0071234 killer0071234 merged commit acdedec into killer0071234:main Dec 15, 2022
@MattWestb
Copy link

The timezone is one problem then it was working OK
Looking in the history is the time off one hour (i think it was in the summer time) but for the moment its not possible testing then is not getting and data to looking in the historical grafe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changed/Wrong timestamp format
5 participants