Making custom timezones possible using the standard library

In some standards, like in iCalendar standard (sorry no link due to max of 2 links), the provider of the data provides the timezone information for the timezone to use. In the iCalendar timezone, this is done using the VTIMEZONE object. This allows a person to create their own custom timezones, making it possible to ensure the different calendar applications are always exactly aligned, even when timezone changes are made and not propagated across programming languages yet.

Previously, I implemented this functionality using Pendulum timezones here. However, with the release of Pendulum 3.0, this code was removed and is now completely dependent on the code already in the standard library of Python3.9. This has been done by PR #569 in Pendulum, which I believe has been done by the same person as who implemented it originally in the standard library of CPython.

I proceeded to check the test code of the standard library and it seems to contain exactly the code that is needed for custom timezones, but it is only available in the test code of the standard library.

Therefore, I would like to propose to make this code globally available in the timezone package.
This would allow for it to be used during tests (and also verified by tests), while also allowing people to use it for creating their own custom timezones.

What do you think?

1 Like

Can’t you use this: datetime β€” Basic date and time types β€” Python 3.12.1 documentation