Skip to content

Conversation

@sunkup
Copy link
Member

@sunkup sunkup commented Dec 2, 2025

iCloud rejects VEVENT uploads when DTSTART is set and DTEND is missing - even though it's valid - so as workaround we always add it with the value of DTSTART.

This PR uses the value of DTSTART to set DTEND if:

  • DTSTART is set and
  • DURATION is not set (in which case we don't need the DTEND)
    and either:
  • DTEND is missing or
  • DTEND is not after DTSTART

Otherwise (DTSTART missing or DURATION present) DTEND will not be set.

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 addresses an iCloud compatibility issue by ensuring DTEND is always added to VEVENT when DTSTART is present. iCloud rejects calendar events with DTSTART but no DTEND, even though this is valid according to the iCalendar specification. The workaround sets DTEND equal to DTSTART when DTEND is missing or invalid, except when DURATION is set (since DURATION and DTEND are mutually exclusive).

Key changes:

  • Modified EndTimeHandler to always set DTEND when DTSTART is present and DURATION is not set
  • DTEND defaults to DTSTART value when missing or not after DTSTART
  • Updated tests to verify the new behavior instead of expecting null DTEND

Reviewed changes

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

File Description
EndTimeHandler.kt Core logic change to always set DTEND equal to DTSTART when DURATION is not present, addressing iCloud rejection issue
EndTimeHandlerTest.kt Updated test expectations to verify DTEND is now set equal to DTSTART in edge cases, plus added test for DURATION skip condition
DurationHandler.kt Updated comments to reference the iCloud workaround context

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

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@sunkup sunkup marked this pull request as ready for review December 2, 2025 13:15
@sunkup sunkup requested a review from a team as a code owner December 2, 2025 13:15
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.

Looks good

Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

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

I think a local event with an invalid (for instance negative) DURATION won't generate a DTEND even with this PR.

See the comment about the responsibility. This should be clarified first.

@sunkup

This comment was marked as resolved.

@sunkup
Copy link
Member Author

sunkup commented Dec 4, 2025

@rfc2822 It's ready for review. I think the code could be prettier with early returns, but I have used the ?: operator as requested, so it's clear where dtEnd comes from.

@sunkup sunkup requested a review from rfc2822 December 4, 2025 15:27
@rfc2822
Copy link
Member

rfc2822 commented Dec 4, 2025

@rfc2822 It's ready for review. I think the code could be prettier with early returns, but I have used the ?: operator as requested, so it's clear where dtEnd comes from.

Well if its better with other methods of flow control, these should be used.

I just meant that it should be clear and easy to understand where the value for dtend comes from.

I'll have a look

@rfc2822
Copy link
Member

rfc2822 commented Dec 5, 2025

I was not happy about a few details and thought that they may really come because we have merged the handlers.

I tried out with different handlers in #157 and it I think it was easier to understand / test so I have merged it. @sunkup Please have a look at #157 nevertheless and if you see something suspicious, comment and/or create a new issue.

@rfc2822 rfc2822 closed this Dec 5, 2025
@rfc2822 rfc2822 deleted the 153-dtend-should-always-be-generated-for-icloud-even-if-its-the-same-as-dtstart branch December 5, 2025 13:17
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.

DTEND should always be generated for iCloud, even if it's the same as DTSTART

3 participants