Skip to content

fix(period): reject zero-length periods in vPeriod (#2087) - #2113

Open
RajGahoi wants to merge 1 commit into
PyCalendar:mainfrom
RajGahoi:fix/period-reject-zero-length
Open

RajGahoi wants to merge 1 commit into
PyCalendar:mainfrom
RajGahoi:fix/period-reject-zero-length

Conversation

@RajGahoi

Copy link
Copy Markdown

Fixes #2087.

Summary

Per RFC 5545 section 3.3.9:

  • The start of the period MUST be before the end of the period.
  • The period duration MUST be a positive, non-zero duration.

Previously, vPeriod accepted periods whose start and end were identical or where duration was zero (timedelta(0) or PT0S), allowing zero-length periods to pass through construction and serialization.

Changes

  • In vPeriod.__init__, check start == end and raise ValueError("Start time is equal to end time").
  • In vPeriod.from_ical, validate that start and end are not equal, raising ValueError when start == end or duration is zero.
  • Added parameter tests in src/icalendar/tests/prop/test_vPeriod.py and dedicated test coverage in src/icalendar/tests/test_issue_2087_zero_length_period.py.
  • Added news entry news/2087.bugfix.

@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 fork→PR pattern: 19/26 fork branches followed by upstream PRs within 58s

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 PR quality: good labels Nov 14, 2026
Per RFC 5545 section 3.3.9, the start of a period MUST be strictly before the end of the period. Previously, identical start and end datetimes were accepted by vPeriod.

Validate that start and end are not equal when an explicit end datetime is provided in both vPeriod.__init__ and vPeriod.from_ical, raising ValueError('Start time is equal to end time').

Signed-off-by: Raj Gahoi <gahoiraj01@gmail.com>
@RajGahoi
RajGahoi force-pushed the fix/period-reject-zero-length branch from 88f20bc to d709e8c Compare November 14, 2026 12:21
@angatha angatha added the duplicate Another PR or issue for the same problem already exist. Please consider giving those your attention. label Nov 16, 2026
@angatha

angatha commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the contributeion. #2103 was created first. Can you please give it a review and maybe make some suggestions you did in another way?

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 duplicate Another PR or issue for the same problem already exist. Please consider giving those your attention. PR quality: good

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Zero-length periods are accepted

2 participants