Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2154.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed :meth:`~icalendar.prop.dt.time.vTime.from_jcal` to preserve the TZID parameter and timezone on parsed TIME properties (:rfc:`7265`). @RajGahoi
5 changes: 4 additions & 1 deletion src/icalendar/prop/dt/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,14 @@ def from_jcal(cls, jcal_property: list) -> Self:
~icalendar.error.JCalParsingError: If the provided jCal is invalid.
"""
JCalParsingError.validate_property(jcal_property, cls)
params = Parameters.from_jcal_property(jcal_property)
with JCalParsingError.reraise_with_path_added(3):
value = cls.parse_jcal_value(jcal_property[3])
if params.tzid:
value = tzp.localize(value, params.tzid)
return cls(
value,
params=Parameters.from_jcal_property(jcal_property),
params=params,
)

def to_xcal(self, element: Element) -> None:
Expand Down
14 changes: 14 additions & 0 deletions src/icalendar/tests/rfc_7265_jcal/test_section_3_6_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,17 @@ def test_jcal_round_trip_preserves_value_parameter(ics_line, prop_name, expected
if isinstance(prop, list):
prop = prop[0]
assert prop.params.get("VALUE") == expected_value


def test_jcal_time_with_tzid_preserves_timezone():
"""A jCal TIME property with a TZID retains its timezone and survives round-trip (GH #2154)."""
jcal = [
"vevent",
[["x-time", {"tzid": "Asia/Dhaka"}, "time", "08:30:00"]],
[],
]
event = Event.from_jcal(jcal)
prop = event["X-TIME"]
assert prop.dt.tzinfo is not None
assert prop.params.get("TZID") == "Asia/Dhaka"
assert event.to_jcal() == jcal