-
Notifications
You must be signed in to change notification settings - Fork 247
Determine Occurrence.Period by Duration only
#808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determine Occurrence.Period by Duration only
#808
Conversation
d2e271f to
35c3693
Compare
* 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
35c3693 to
e587ce8
Compare
There was a problem hiding this 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
RecurrenceUtilto filter onEffectiveEndTimeinstead of a nullableEndTimefallback - Rewrite
EventEvaluatorto create periods fromDurationonly (WithFinalDuration), and enforce representable end times - Add a check in
Periodconstructor to forbid adding a time-based duration to a date-only start - Adjust test assertions to use
EffectiveEndTime, remove ambiguous.icsfixtures, 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
WithFinalDurationuses the period'sDurationandEffectiveEndTimerather than settingEndTimedirectly.
/// <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
endTimetoeffectiveEndTimeto clearly indicate it refers toEffectiveEndTimeand avoid confusion with the originalEndTimeproperty.
let endTime = p.EffectiveEndTime
minichma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Co-authored-by: Copilot <[email protected]>
741371d to
054a8e6
Compare
…RangeException` This exception is more accurate than System.ArgumentOutOfRangeException
054a8e6 to
8672357
Compare
|



EventEvaluatorto use the start time withDurationinstead of end time to create aPeriodforOccurrencePeriod: Trying to create aPeriodby using a date-onlyCalDateTimeandDuration.HasTimewill throw.icsfiles of unit tests to either containDTENDorDURATION(never both) to get unambiguous test resultsPeriod.EffectiveEndTimeinstead ofPeriod.EndTimeResolves #737