Making icalendar.from_ical independent of pytz and usable with all timezone implementations #532
Replies: 4 comments
-
I like the first option better - if people would like to use pytz in one section (e.g. legacy code) and ZoneInfo in other (e.g. new code) they easily can. |
Beta Was this translation helpful? Give feedback.
-
running |
Beta Was this translation helpful? Give feedback.
-
While refactoring from zoneinfo import ZoneInfo
ZoneInfo('Europe/Warsaw')._trans_utc throws an |
Beta Was this translation helpful? Give feedback.
-
At the present moment v5.0.0a2, I understand that icalendar components can be constructed as objects with any timezone implementation (
pytz
,zoneinfo
,tz
).As pytz is more and more outdated,
I would like to be able to choose the timezone implementation that we use when we parse an ICS file.
At the moment, I believe that this is the step forward to make the icalendar step in up to the advances Python developers have made with the latest timezone implementations.
Proposal 1
Proposal for the interface:
Any object returned from these calls should not use pytz but the timezone specified.
Proposal 2
As icalendar has a global state to parse timezones set to pytz, we could set an other global default:
The global default will be something like a lazy pytz (as proposed by #294) that imports pytz only if no other implementation is set.
Calling
icalendar.set_timezone_implementation
will set the default parameter from Proposal 1.Implementation
As we use pytest to run the tests and @jacadzaca is already heavily refactoring the tests, see #400, we can use a parameter for parsing to pass the desired timezone implementation.
Parametrizing timezone implementations shows that pytz will stand out and always look a bit different.
The recurring-ical-events library shows that test parametrization can be used to run all tests for pytz and zoneinfo.
Datetime/Timezone implementations
These timezone implementations should be supported:
pytz
zoneinfo
/backports.zoneinfo
arrow
library #181Related
Comments and ideas are very much appreciated on this as this is a deep change - feels like it to me. Also, I wrote this now without reading through all the related issues. Please comment.
Beta Was this translation helpful? Give feedback.
All reactions