Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Nov 29, 2025

Change builders from VEVENT:

  • DTEND <= DTSTART will now be ignored. For such events, the default duration will be applied (as if DTEND would be missing without DURATION present).
  • Explicit negative DURATION values of events will be treated as positive, because negative durations are not allowed and don't make any sense (events can't go back in time). This only applies to the DTEND/DURATION of events (not reminders etc., where negative durations are a valid case.)

- Add validation to ensure DTEND is after DTSTART
- Update tests to cover cases where DTEND is before DTSTART
- Add tests for events with DTEND before DTSTART and negative DURATION
- Update DurationBuilder to ignore negative durations
- Update EndTimeBuilder to ignore DTEND before DTSTART
@rfc2822 rfc2822 linked an issue Nov 29, 2025 that may be closed by this pull request
@rfc2822 rfc2822 force-pushed the 147-handle-invalid-events-with-negative-duration branch from c1e1c05 to 8061f2d Compare November 29, 2025 16:24
@rfc2822 rfc2822 self-assigned this Nov 29, 2025
@rfc2822 rfc2822 requested a review from Copilot November 29, 2025 16:24
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 handles invalid calendar events where DTEND is before DTSTART or DURATION is negative, ensuring RFC 5545 compliance. When such invalid values are encountered, the code now converts negative durations to positive values and ignores DTEND values that precede DTSTART, falling back to default durations.

  • Added validation logic to reject DTEND < DTSTART and apply default durations
  • Introduced abs() extension function for TemporalAmount to convert negative durations to positive
  • Refactored duration calculation methods to work directly with TemporalAmount instead of wrapping in Duration property

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
EndTimeBuilder.kt Added DTEND validation to ensure it's after DTSTART, applies abs() to negative DURATION values
DurationBuilder.kt Simplified duration calculation to use TemporalAmount directly, applies abs() to negative durations
TimeApiExtensions.kt Added abs() extension function for TemporalAmount (Duration and Period)
EndTimeBuilderTest.kt Added tests for DTEND < DTSTART and negative DURATION scenarios
DurationBuilderTest.kt Added tests for negative DURATION calculation, updated return type assertions
TimeApiExtensionsTest.kt Added comprehensive tests for abs() function with positive and negative values
AndroidCalendarProviderBehaviorTest.kt Reordered test for DTEND = DTSTART and RRULE UNTIL before DTSTART

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…nvalid TemporalAmount

- Fix typo in EndTimeBuilder.kt comment
@rfc2822 rfc2822 marked this pull request as ready for review November 29, 2025 16:29
@rfc2822 rfc2822 requested a review from a team as a code owner November 29, 2025 16:29
@rfc2822 rfc2822 requested a review from Copilot November 29, 2025 16:29
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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devvv4ever devvv4ever marked this pull request as draft November 29, 2025 16:35
@devvv4ever
Copy link
Member

Always ignore explicit DTEND<DTSTART

@rfc2822 rfc2822 force-pushed the 147-handle-invalid-events-with-negative-duration branch from f15306f to fc9e10f Compare November 30, 2025 10:52
@rfc2822 rfc2822 requested a review from Copilot November 30, 2025 10:52
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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rfc2822 rfc2822 marked this pull request as ready for review November 30, 2025 10:58
Copy link
Member

@ArnyminerZ ArnyminerZ left a comment

Choose a reason for hiding this comment

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

Some small gimmicks. Otherwise looks good.

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rfc2822 rfc2822 merged commit ad0c68d into main Dec 1, 2025
13 checks passed
@rfc2822 rfc2822 deleted the 147-handle-invalid-events-with-negative-duration branch December 1, 2025 10:32
@rfc2822 rfc2822 linked an issue Dec 5, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content provider returned null on insert when DTEND before DTSTART Handle invalid events with negative duration

3 participants