Skip to content

Conversation

@axunonb
Copy link
Collaborator

@axunonb axunonb commented Dec 6, 2024

  • Simplified handling of UNTIL value in ProcessRecurrencePattern.
  • Refactored MatchTimeZone to ensure UNTIL matches DTSTART's time zone and type following RFC 5545 definitions
  • Added unit tests to verify behavior under various scenarios, improving accuracy and consistency of recurrence evaluations.

Closes #663

* Simplified handling of UNTIL value in ProcessRecurrencePattern.
* Refactored MatchTimeZone to ensure UNTIL matches DTSTART's time zone and type.
* Added unit tests to verify behavior under various scenarios, improving accuracy and consistency of recurrence evaluations.

Closes ical-org#663
@axunonb axunonb requested a review from minichma December 6, 2024 19:32
minichma
minichma previously approved these changes Dec 7, 2024
BEGIN:VEVENT
UID:example1
SUMMARY:Event with local time and time zone
DTSTART;TZID=Asia/Tokyo:20231101T090000
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the test above with NY tz you chose dates involving a DST change (in 2023 in NY winter DST change was Nov 5), but in this test no DST change is involved (there is no DST in Tokyo). Not a problem, just noting this to make sure, its intentional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I updated the test to use Sydney/Australia with DST change.

October 4, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
October 5, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
October 6, 2024: 01:00 AM - 02:00 AM (UTC+1100) (Australia/Sydney)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, actually I think, this should be included, because UNTIL must be considered inclusive.

If the value
specified by UNTIL is synchronized with the specified recurrence,
this DATE or DATE-TIME becomes the last instance of the
recurrence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the conclusion came from the description I assume. It was not updated.
Now there are 2 test cases, one when DST occurs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I was looking at the comments. But now reconsidering the test, I still think its not correct.

October 6, 2024: 01:00 AM Sydney time = 20241005T140000Z, so it should be included in the first test and the number of occurrences should therefore be 6 in both cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Isn't UTC Time: 2024-10-05 14:00:00 => Sydney Time (AEST, UTC+10:00): 2024-10-06 00:00:00?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yes, of course, sorry for the confusion!

@axunonb axunonb force-pushed the pr/fix-match-timezone branch from 4b529bf to 72bb513 Compare December 7, 2024 13:34
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2024

System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.AssumeUniversal |
System.Globalization.DateTimeStyles.AdjustToUniversal);
var occurrences = evt.GetOccurrences(new CalDateTime(2024, 10, 01), new CalDateTime(2024, 10, 07));
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case DTSTART has a tzid but the startTime is floating. This is quite a special case and we should considere to disallow the case. Anyhow, I think it would be preferable to specify a tzid for the start/endTime too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, CalDateTime(2024, 10, 01) resolves to a DATE value, which cannot have a timezone (RFC 5545)?

Copy link
Collaborator Author

@axunonb axunonb Dec 7, 2024

Choose a reason for hiding this comment

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

So you mean, it should always be a zoned DATE-TIME?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a comment, not too relevant. Generally it would be advisable for users of the app, not to mix DATE vs DATE-TIME and floating vs non-floating, because there's always some ambiguity that causes additional complexity. In this case it really doesn't matter, so no need to change it. But as its advisable for users, not to mix it, we generally might want to avoid mixing them in the tests either (except for those cases where we explicitly want to test mixing them).

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.

Refactor RecurrencePattern.Until

2 participants