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

Why specify a UTC offset instead of using zoneinfo.ZoneInfo? #35

Open
msoulier opened this issue Mar 10, 2025 · 0 comments
Open

Why specify a UTC offset instead of using zoneinfo.ZoneInfo? #35

msoulier opened this issue Mar 10, 2025 · 0 comments

Comments

@msoulier
Copy link

At the moment the PrayerConf object takes a timezone argument, which is a simple integer representing utc offset in hours.

This cannot work everywhere unless it is a float, as some regions have offsets that are not in hours.

Python provides a zoneinfo library to make selecting a timezone easier. The PrayerConf object could take one of these instead and still work internally in the same way.

`>>> zone = zoneinfo.ZoneInfo("America/Montreal")

import datetime
zone.utcoffset(datetime.datetime.now()).total_seconds
<built-in method total_seconds of datetime.timedelta object at 0x7f88fcbbd410>
zone.utcoffset(datetime.datetime.now()).total_seconds()
-14400.0
zone.utcoffset(datetime.datetime.now()).total_seconds() / 3600.0
-4.0`

And on my Linux box, it is simple enough to read the symlink /etc/localtime and determine this for the user.

$ ls -l /etc/localtime lrwxrwxrwx 1 root root 35 May 2 2023 /etc/localtime -> /usr/share/zoneinfo/America/Toronto

So why not make this simpler for the front-end and use the zoneinfo library?

Regards...

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

No branches or pull requests

1 participant