Skip to content

Conversation

@axunonb
Copy link
Collaborator

@axunonb axunonb commented May 25, 2025

  • Update EventEvaluator to use the start time with Duration instead of end time to create a Period for Occurrence
  • Period: Trying to create a Period by using a date-only CalDateTime and Duration.HasTime will throw
  • Modify .ics files of unit tests to either contain DTEND or DURATION (never both) to get unambiguous test results
  • Modify unit tests to use Period.EffectiveEndTime instead of Period.EndTime
  • Add unit test for issue Incorrect timezone calculation if short recurrence falls into an ambiguous local time #737

Resolves #737

@axunonb axunonb marked this pull request as ready for review May 25, 2025 22:03
@axunonb axunonb requested a review from minichma May 25, 2025 22:03
@axunonb axunonb force-pushed the pr/use-duration-for-occurrence-periods branch 2 times, most recently from d2e271f to 35c3693 Compare June 5, 2025 19:41
* Update `EventEvaluator`
* `Period`: Trying to create a `Period` a using a date-only `CalDateTime` and `Duration.HasTime` will throw
* Modify `.ics` files of unit tests to either contain `DTEND` or `DURATION` (never both) to get unambiguous test results
* Modifty unit tests to use `Period.EffectiveEndTime` instead of `Period.EndTime`
* Add unit test for issue ical-org#737

Resolves ical-org#737
@axunonb axunonb force-pushed the pr/use-duration-for-occurrence-periods branch from 35c3693 to e587ce8 Compare June 5, 2025 19:48
@axunonb axunonb requested a review from Copilot June 5, 2025 19:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how event Periods are determined by relying solely on durations, adds validation to prevent mixing date-only starts with time-based durations, and updates tests/fixtures for unambiguous results.

  • Update RecurrenceUtil to filter on EffectiveEndTime instead of a nullable EndTime fallback
  • Rewrite EventEvaluator to create periods from Duration only (WithFinalDuration), and enforce representable end times
  • Add a check in Period constructor to forbid adding a time-based duration to a date-only start
  • Adjust test assertions to use EffectiveEndTime, remove ambiguous .ics fixtures, and add a new test for issue #737

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

File Description
Ical.Net/Evaluation/RecurrenceUtil.cs Use EffectiveEndTime for occurrence filtering
Ical.Net/Evaluation/EventEvaluator.cs Replace WithEndTime with WithFinalDuration and duration‐based logic
Ical.Net/DataTypes/Period.cs Prevent adding time-based durations to date-only starts
Ical.Net.Tests/* Updated assertions to EffectiveEndTime, adjusted .ics fixtures, added new DST test
Comments suppressed due to low confidence (2)

Ical.Net/Evaluation/EventEvaluator.cs:52

  • Update the XML documentation to reflect that WithFinalDuration uses the period's Duration and EffectiveEndTime rather than setting EndTime directly.
/// <param name="period">The period where <see cref="Period.EndTime"/> will be set.</param>

Ical.Net/Evaluation/RecurrenceUtil.cs:39

  • [nitpick] Rename the local variable endTime to effectiveEndTime to clearly indicate it refers to EffectiveEndTime and avoid confusion with the original EndTime property.
let endTime = p.EffectiveEndTime

minichma
minichma previously approved these changes Jun 5, 2025
Copy link
Collaborator

@minichma minichma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@axunonb axunonb force-pushed the pr/use-duration-for-occurrence-periods branch from 741371d to 054a8e6 Compare June 6, 2025 06:55
@axunonb axunonb requested a review from minichma June 6, 2025 06:56
…RangeException`

This exception is more accurate than System.ArgumentOutOfRangeException
@axunonb axunonb force-pushed the pr/use-duration-for-occurrence-periods branch from 054a8e6 to 8672357 Compare June 6, 2025 07:07
@sonarqubecloud
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect timezone calculation if short recurrence falls into an ambiguous local time

2 participants