Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

timezone issues with show name in past CRIDs #244

Open
hairmare opened this issue Mar 10, 2024 · 3 comments · May be fixed by #328
Open

timezone issues with show name in past CRIDs #244

hairmare opened this issue Mar 10, 2024 · 3 comments · May be fixed by #328
Assignees

Comments

@hairmare
Copy link
Member

Depending on CEST/CET, the show name doesn't match. There is a bunch of timezone related code involved, and due to several historic implementations there is a lot of converting going on that should be looked into.

@hairmare
Copy link
Member Author

this is the minimal reproducer for radiorabe/suisa_sendemeldung#528

import cridlib
from datetime import datetime
import pytz

timestamp_utc = pytz.utc.localize(
    datetime.strptime("2024-01-16 23:01:16", "%Y-%m-%d %H:%M:%S"),
)

crid = cridlib.get(timestamp=timestamp_utc)

print(crid)
assert "klangbecken" in str(crid)

@hairmare
Copy link
Member Author

The consumer needs to tell CRIDlib where we are:

import cridlib
from datetime import datetime
import pytz

timestamp_utc = pytz.utc.localize(
    datetime.strptime("2024-01-16 23:01:16", "%Y-%m-%d %H:%M:%S"),
)

crid = cridlib.get(timestamp=timestamp_utc.astimezone(pytz.timezone("Europe/Zurich")))

print(crid)
assert "klangbecken" in str(crid)

Maybe CRIDlib should astimezone on it's own in the get.past case? 🤔

@hairmare hairmare linked a pull request Jul 12, 2024 that will close this issue
@hairmare
Copy link
Member Author

hairmare commented Jul 12, 2024

DoD (both with and w/o TZ=UTC)

import cridlib
from datetime import datetime
import pytz

timestamp_utc = pytz.utc.localize(
    datetime.strptime("2024-01-16 23:01:16", "%Y-%m-%d %H:%M:%S"),
)
crid = cridlib.get(timestamp=timestamp_utc)
assert "crid://rabe.ch/v1/klangbecken#t=clock=20240116T230116.00Z" == str(crid)

timestamp = pytz.utc.localize(
    datetime.strptime("2024-01-16 23:01:16", "%Y-%m-%d %H:%M:%S"),
).astimezone(pytz.timezone("Europe/Zurich"))

crid2 = cridlib.get(timestamp=timestamp)
assert "crid://rabe.ch/v1/klangbecken#t=clock=20240116T230116.00Z" == str(crid2)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant