Skip to content

Fix jCal TIME parsing dropping TZID and zoned time - #2178

Open
RajGahoi wants to merge 1 commit into
PyCalendar:mainfrom
RajGahoi:fix/jcal-time-tzid-2154
Open

RajGahoi wants to merge 1 commit into
PyCalendar:mainfrom
RajGahoi:fix/jcal-time-tzid-2154

Conversation

@RajGahoi

Copy link
Copy Markdown

Linked issue

Description

When parsing a jCal time property that specifies a tzid parameter (e.g. ["x-time", {"tzid": "Asia/Dhaka"}, "time", "08:30:00"]), vTime.from_jcal constructed cls(value, params=...) where value was an unlocalized naive datetime.time.

During vTime.__init__, self.params.update_tzid_from(self.dt) was called. Because self.dt.tzinfo was None, tzid_from_dt(self.dt) evaluated to None, thereby deleting the tzid from the property parameters. As a result, zoned times were converted into floating times on serialization, breaking round-trip fidelity.

This PR fixes the issue by:

  1. Extracting parameters with params = Parameters.from_jcal_property(jcal_property) before parsing value.
  2. Localizing value using tzp.localize(value, params.tzid) when params.tzid is present, matching the behavior of vDatetime.from_jcal.
  3. Adding a regression test in test_section_3_6_values.py verifying that parsed vTime instances retain dt.tzinfo, preserve params["TZID"], and round-trip cleanly via to_jcal().
  4. Adding the required towncrier news fragment in news/2154.bugfix.

Checklist

  • I added a change log entry, following the instructions in all subsections under Change log requirements.
  • I followed icalendar's Artificial intelligence policy and disclosed my Responsible AI use in my commit messages, if applicable.
  • I added or updated tests, if applicable.
  • I ran and ensured all tests pass locally by following Run tests.
  • I added or edited documentation as necessary, both as docstrings to be rendered in the API documentation and narrative documentation, following the Style guide.

Additional information

Verified locally against test_time.py, test_timezoned.py, and the full rfc_7265_jcal test suite (140 unit tests passing).

…lendar#2154)

When parsing a jCal TIME property with a `tzid` parameter via `vTime.from_jcal`,
the parameter dictionary was passed into `cls(value, params=...)` with an unlocalized
naive `datetime.time`. `vTime.__init__` invoked `update_tzid_from(self.dt)`, which
cleared the `tzid` from the parameters because `self.dt` lacked a timezone, causing
the parsed property to lose its timezone and serialize to floating time.

Localize `value` with `tzp.localize(value, params.tzid)` in `vTime.from_jcal`
prior to instantiation, matching `vDatetime.from_jcal` and ensuring both `dt.tzinfo`
and `params['TZID']` are preserved across jCal round trips.

Resolves PyCalendar#2154

Signed-off-by: Raj Gahoi <gahoiraj01@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @RajGahoi! A maintainer will review it shortly.

@github-actions

Copy link
Copy Markdown
Contributor

Mixed activity

Activity patterns show a mix of organic and automated signals.

View full analysis →

Evidence
  • Rapid PRs to repository: 8 PRs opened to Expensify/App within 6s intervals

Last 5 PRs:

This is an automated analysis by AgentScan

@github-actions github-actions Bot added agentscan:needs-review AgentScan flagged this item for review because it has mixed signals ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding. labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

One or more PR-quality checks did not pass. Review the PR Quality Checks summary in the workflow run for the failed checks and their details, then make any necessary updates.

Checklist items may remain unchecked while work is in progress. Please tick each item as you complete it.

If you used AI assistance, follow the project's Responsible AI use policy and provide the required disclosures.

@SemTiOne

SemTiOne commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. However, there's already an open PR (#2155) for this issue. Would you please review that PR and provide some feedback to the author?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:needs-review AgentScan flagged this item for review because it has mixed signals ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jCal TIME parsing drops TZID and turns zoned times into floating times

2 participants