Skip to content

Questions about timezone/ZoneInfo and fold attribute #12

@ariebovenberg

Description

@ariebovenberg

👋 Hi there, I recently came across this nice project. As far as I know, it's the only one looking to make the aware/naive distinction at both runtime and type-checking 👏

Looking at the code though I had some questions:

1. The local timezone is cast to ZoneInfo here, but .tzinfo here always returns datetime.timezone instances.

tz_local = cast(ZoneInfo, _datetime.datetime.now().astimezone().tzinfo)

I know because I've tried as well ;). timezone (e.g. CET) sadly doesn't account for variable UTC offsets (i.e. no DST), while ZoneInfo (e.g. Europe/Paris) does.
The solution could be to use the tzlocal library which helps determine the actual IANA timezone (i.e. ZoneInfo object) for the system. Pendulum uses this approach AFAIK.

2. The fold attribute is omitted from the constructor. Is this intentional? It's the only way to disambiguate times that occur twice is a timezone. It would be interesting if it could be omitted for the UTC datetime (which is never ambiguous), but required for IANA zoned datetimes.

😉 PS: I'm working on a datetime library of my own. Feel free to drop feedback if you like 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions