Skip to content

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

@msoulier

Description

@msoulier

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions