kopia lustrzana https://github.com/collective/icalendar
Add tzdata package to add-on timezones
See https://stackoverflow.com/a/78580486/1320237pull/623/head
rodzic
e45ce94b7e
commit
1c795eddbb
1
setup.py
1
setup.py
|
@ -24,6 +24,7 @@ install_requires = [
|
|||
# install requirements depending on python version
|
||||
# see https://www.python.org/dev/peps/pep-0508/#environment-markers
|
||||
'backports.zoneinfo; python_version == "3.7" or python_version == "3.8"',
|
||||
'tzdata'
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -12,5 +12,6 @@ import pytest
|
|||
@pytest.mark.parametrize("tzp_", [PYTZ(), ZONEINFO()])
|
||||
def test_timezone_names_are_known(tz_name, tzp_):
|
||||
"""Make sure that all timezones are understood."""
|
||||
pytest.skip()
|
||||
if tz_name in ("Factory", "localtime"):
|
||||
pytest.skip()
|
||||
assert tzp_.knows_timezone_id(tz_name), f"{tzp_.__class__.__name__} should know {tz_name}"
|
||||
|
|
|
@ -25,7 +25,7 @@ class ZONEINFO:
|
|||
"""Return a timezone with a name or None if we cannot find it."""
|
||||
try:
|
||||
return zoneinfo.ZoneInfo(name)
|
||||
except ValueError:
|
||||
except zoneinfo.ZoneInfoNotFoundError:
|
||||
pass
|
||||
|
||||
def knows_timezone_id(self, id: str) -> bool:
|
||||
|
@ -38,6 +38,14 @@ class ZONEINFO:
|
|||
# zoninfo does not know any transition dates after 2038
|
||||
rrule._until = datetime(2038, 12, 31, tzinfo=pytz.UTC)
|
||||
|
||||
def create_timezone(self, name: str, transition_times, transition_info):
|
||||
"""Create a pytz timezone file given information."""
|
||||
cls = type(name, (DstTzInfo,), {
|
||||
'zone': name,
|
||||
'_utc_transition_times': transition_times,
|
||||
'_transition_info': transition_info
|
||||
})
|
||||
return cls()
|
||||
|
||||
|
||||
__all__ = ["ZONEINFO"]
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -11,7 +11,6 @@ deps =
|
|||
pytest
|
||||
coverage
|
||||
hypothesis
|
||||
backports.zoneinfo ; python_version<'3.9'
|
||||
commands =
|
||||
coverage run --source=src/icalendar --omit=*/tests/hypothesis/* --omit=*/tests/fuzzed/* --module pytest []
|
||||
coverage report
|
||||
|
|
Ładowanie…
Reference in New Issue