Skip to content

Commit

Permalink
Document functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
niccokunzmann committed Nov 11, 2024
1 parent 3cd9980 commit 57f8a57
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/icalendar/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,11 +1125,15 @@ def from_tzinfo(
The offsets are calculated from the tzinfo object.
Parameters:
:param tzinfo: the timezone object
:param tzid: the tzid for this timezone in case we cannot determine it
None for pytz and zoneinfo is fine.
:param first_date: a datetime that is earlier than anything that happens in the calendar
:param last_date: a datetime that is later than anything that happens in the calendar
.. note::
This can take some time. Please cache the results.
"""
if tzid is None:
tzid = tzid_from_tzinfo(timezone)
Expand Down Expand Up @@ -1204,7 +1208,22 @@ def from_tzid(
first_date:date=_DEFAULT_FIRST_DATE,
last_date:date=_DEFAULT_LAST_DATE
) -> Timezone:
"""Create a VTIMEZONE from a tzid like 'Europe/Berlin'."""
"""Create a VTIMEZONE from a tzid like ``"Europe/Berlin"``.
:param tzid: the id of the timezone
:param tzp: the timezone provider
:param first_date: a datetime that is earlier than anything that happens in the calendar
:param last_date: a datetime that is later than anything that happens in the calendar
>>> from icalendar import Timezone
>>> tz = Timezone.from_tzid("Europe/Berlin")
>>> print(tz.to_ical()[:36])
BEGIN:VTIMEZONE
TZID:Europe/Berlin
.. note::
This can take some time. Please cache the results.
"""
return cls.from_tzinfo(tzp.timezone(tzid), tzid, first_date, last_date)

@property
Expand Down

0 comments on commit 57f8a57

Please sign in to comment.