Skip to content

Reduce use of EvaluationPeriod#946

Open
maknapp wants to merge 22 commits into
version/6.0from
maknapp/remove-evaluation-period
Open

Reduce use of EvaluationPeriod#946
maknapp wants to merge 22 commits into
version/6.0from
maknapp/remove-evaluation-period

Conversation

@maknapp
Copy link
Copy Markdown
Collaborator

@maknapp maknapp commented May 10, 2026

Note that this is based off of #934, so really only 2 commits.

RecurrenceRuleEvaluator was just wrapping ZonedDateTime in an EvaluationPeriod with no end time, which meant another EvaluationPeriod needed to be made to add an end time. RecurrenceRuleEvaluator now yields ZonedDateTime directly.

RecurrenceUtil.GetOccurrences(...) no longer filters by start/end range because it is a duplicate filter to RecurringEvaluator.Evaluate().

EXDATE date time exclusions were switched to HashSet instead of sorting and merging. There is no benefit to merging if the list needs to be sorted.

To help reduce allocations and unnecessary work, RDATE merging and EXDATE filtering is skipped if empty.

maknapp added 22 commits April 3, 2026 11:06
DATE values should not have a time zone.
Removes hasTime parameter from CalDateTime constructors
and requires DATE values to be created with a static
method. This prevents the time zone parameter from being
silently ignored when creating DATE values.

Fixes #933
Time zone can be ignored for DATE values since they
cannot have a time zone. This also verifies that end
is not before start for DATE values.
This was only being used in tests.
Explicit names for ToDateTimeUtc and ToDateTimeUnspecified
help clarify intention when using DateTime.
DateTime.Today is calculated from DateTime.Now but
NodaTime also does the same calculation, so just use
DateTime.Now to get the same result.
@maknapp maknapp requested review from axunonb and minichma May 10, 2026 15:31
@sonarqubecloud
Copy link
Copy Markdown

@maknapp maknapp changed the base branch from maknapp/caldatetime to version/6.0 May 10, 2026 15:37
Copy link
Copy Markdown
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.

I'm not the right person to review the whole PR, this is just a comment on using HashSet for EXDATEs. The original idea of using OrderedExclude was probably to be close to the implementation of EXRULEs, where it was more or less required. Once the set has been constructed, the computational cost per recurrence are also somewhat lower in case of OrderedExclude compared to a HashSet lookup, but that's neglectable. Now that it seems that support for EXRULEs has been dropped, there's no strong argument for OrderedExclude over a HashSet lookup. I assume the reason for removing it is to make the code easier to read and somewhat less complex to reason about, right? No concerns from my side.

@maknapp
Copy link
Copy Markdown
Collaborator Author

maknapp commented May 11, 2026

I'm not the right person to review the whole PR, this is just a comment on using HashSet for EXDATEs.

Yes, sorry. That specific part was the reason I included you to review - probably should have just asked that directly @ you instead of including to review.

The original idea of using OrderedExclude was probably to be close to the implementation of EXRULEs, where it was more or less required. Once the set has been constructed, the computational cost per recurrence are also somewhat lower in case of OrderedExclude compared to a HashSet lookup, but that's neglectable. Now that it seems that support for EXRULEs has been dropped, there's no strong argument for OrderedExclude over a HashSet lookup. I assume the reason for removing it is to make the code easier to read and somewhat less complex to reason about, right? No concerns from my side.

Yes, since it was the only remaining use of OrderedExclude left and HashSet was good enough for this case. I just wanted to double-check that it was not doing something I was missing.

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.

2 participants