Repository navigation
Preserve TZID when parsing jCal TIME properties - #2155
Open
shrohan2003 wants to merge 1 commit into
Open
shrohan2003 wants to merge 1 commit into
shrohan2003 wants to merge 1 commit into
Conversation
Localize the parsed time before constructing vTime so its constructor retains the supplied TZID. Cover direct property and Event round trips with pytz and zoneinfo, along with UTC and floating times. Codex (GPT-6) assisted with investigation, implementation, and testing. The user requested additional verified open-source bug fixes and PRs. Validation: four regression cases failed before the fix; the full suite passes with 22425 passed, 43 skipped, and 577 xfailed. Ruff passes.
shrohan2003
requested review from
angatha,
niccokunzmann and
stevepiercy
as code owners
November 19, 2026 07:39
Contributor
|
Thanks for the pull request, @shrohan2003! A maintainer will review it shortly. |
4 of 5 tasks
SemTiOne
suggested changes
Nov 20, 2026
| @@ -0,0 +1 @@ | |||
| Preserve the timezone when parsing jCal TIME properties with a TZID, including through component parsing and serialization. Codex (GPT-6) assisted with reproduction, implementation, and regression tests. | |||
Contributor
There was a problem hiding this comment.
Suggested change
| Preserve the timezone when parsing jCal TIME properties with a TZID, including through component parsing and serialization. Codex (GPT-6) assisted with reproduction, implementation, and regression tests. | |
| Preserved the timezone when parsing jCal TIME properties, including when parsing components and serializing them. Codex (GPT-6) assisted with reproducing the issue, implementing the fix, and writing regression tests. :user:`shrohan2003` |
Comment on lines
267
to
+270
| with JCalParsingError.reraise_with_path_added(3): | ||
| value = cls.parse_jcal_value(jcal_property[3]) | ||
| if params.tzid: | ||
| value = tzp.localize(value, params.tzid) |
Contributor
There was a problem hiding this comment.
Please reject TZID when the jCal TIME value ends in Z, as vTime.from_xcal() does. zoneinfo silently replaces UTC with the local timezone. Also add a regression test for both providers.
Suggested change
| with JCalParsingError.reraise_with_path_added(3): | |
| value = cls.parse_jcal_value(jcal_property[3]) | |
| if params.tzid: | |
| value = tzp.localize(value, params.tzid) | |
| with JCalParsingError.reraise_with_path_added(3): | |
| value = cls.parse_jcal_value(jcal_property[3]) | |
| if params.tzid: | |
| if is_utc(value): | |
| raise JCalParsingError( | |
| f"Cannot mix {params.tzid} with UTC", cls | |
| ) | |
| value = tzp.localize(value, params.tzid) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Closes #2154
Description
Parsing a jCal TIME with
TZID=Asia/Dhakacurrently produces a naive time and removes the timezone parameter. Re-serializing an event consequently changes a zoned time into a floating time. Apply the TZID before constructingvTime, following the existingvDatetime.from_jcal()approach.Regression tests cover property and Event round trips with both pytz and zoneinfo, preserve the input, and check UTC and floating times. Four timezone cases fail before the fix. The full suite passes with 22,425 passed, 43 skipped, and 577 xfailed on Python 3.13.18. Ruff lint and format checks pass.
Checklist