-
Notifications
You must be signed in to change notification settings - Fork 233
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
Get Occurrences fails on a RRULE FREQ=SECONDLY #622
Comments
Here is temporary workaround for [Test]
public void SecondlyRecurrence()
{
var dateTime = DateTime.UtcNow;
// Create a new calendar
var calendar = new Calendar
{
RecurrenceRestriction = RecurrenceRestrictionType.NoRestriction
};
var calendarEvent = new CalendarEvent
{
Summary = "Recurring Event Every 45 Seconds",
DtStart = new CalDateTime(dateTime),
DtEnd = new CalDateTime(dateTime.AddHours(1)),
RecurrenceRules = new List<RecurrencePattern>
{
new RecurrencePattern(FrequencyType.Secondly, 45)
}
};
// This does not seem to add any reference to the parent `Calendar`,
// Services inside `CalendarEvent` and its children should be updated
calendar.Events.Add(calendarEvent);
// Serialize the calendar to an iCalendar string
var serializer = new CalendarSerializer();
var serializedCalendar = serializer.SerializeToString(calendar);
/*************************************************************
* This is a temporary workaround to make GetOccurrences work
* with the RecurrenceRestriction set to NoRestriction.
*************************************************************/
calendar = Calendar.Load(serializedCalendar);
// This setting does not deserialize, so we have to set again
calendar.RecurrenceRestriction = RecurrenceRestrictionType.NoRestriction;
// Evaluate the recurrences
var occurrences = calendar.GetOccurrences(dateTime, dateTime.AddHours(1));
Assert.That(occurrences, Has.Count.EqualTo(80));
} |
Wow! I didn't expect a response so quickly. I'm currently only using the You guys are absolutely knocking it out of the park. Thank you so very much. |
Btw, there's one more limitation that could play a role with SECONDLY freq:
The number of increments between occurrences must be < (or <=) 1000, so something like this might not work as expected:
because after 3:59:59 the number of second increments until 1:00:00 is > 1000. Shouldn't play a role in case of 45s intervals though. |
@minichma The recurrence related properties on |
FWIW, for me, this can be a lower priority than whatever else you have in the pipeline. The specific product I'm on right now is only days+. However, when we migrate other products to this, we'll need seconds. |
Fully agree. I tend to think that its not the lib's task to define which kind of restrictions on performance are acceptable for the user. So I would probably remove the RecurrenceRestrictionType altogether. Its also not quite easy to understand what it is doing. The maxIncrement probably makes sense but in my opinion should default to indefinite. |
Modified Constants.cs: - Deprecated `RecurrenceRestrictionType` and `RecurrenceEvaluationModeType` enums. Updated RecurrencePattern.cs: - Deprecated `RestrictionType` and `EvaluationMode` properties. - Set default for `RestrictionType`. Enhanced RecurrenceUtil: - Added new using directives. - Introduced `DefaultTimeout`. - Updated `GetOccurrences` with timeout logic. Refined RecurrencePatternEvaluator: - Removed `_maxIncrementCount` with connected logic in favor of `RecurrenceUtil.DefaultTimeout` - Improved XML documentation comments. Updated Calendar.cs: - Simplified `Load` method. - Deprecated certain properties and methods associated with `RestrictionType` and `EvaluationMode` - Removed obsolete `Evaluate` method. Enhanced RecurrenceTests.cs with more robust test cases: - Replaced `Assert.That` with `Assert.Multiple`. - Changed assertion for occurrences count. - Renamed test methods for clarity. - Added timeout settings and updated expected exceptions. - Adjusted test data and added comments. Corrected typos and improved formatting for better readability. Fixes ical-org#622
- Deprecated `RecurrenceRestrictionType` and `RecurrenceEvaluationModeType` enums. Updated RecurrencePattern.cs: - Deprecated `RestrictionType` and `EvaluationMode` properties. - Set default for `RestrictionType`. Enhanced RecurrenceUtil: - Added new using directives. - Introduced `DefaultTimeout`. - Updated `GetOccurrences` with timeout logic. Refined RecurrencePatternEvaluator: - Removed `_maxIncrementCount` with connected logic in favor of `RecurrenceUtil.DefaultTimeout` - Improved XML documentation comments. Updated Calendar.cs: - Simplified `Load` method. - Deprecated certain properties and methods associated with `RestrictionType` and `EvaluationMode` - Removed obsolete `Evaluate` method. Enhanced RecurrenceTests.cs with more robust test cases: - Replaced `Assert.That` with `Assert.Multiple`. - Changed assertion for occurrences count. - Renamed test methods for clarity. - Added timeout settings and updated expected exceptions. - Adjusted test data and added comments. Corrected typos and improved formatting for better readability. Fixes ical-org#622
Discussed in #615
Originally posted by DaleyKD October 18, 2024
Does this library support getting occurrences if we use a secondly recurrence pattern?
Our project doesn't use this for calendar events, but more to help us determine when to run the next job (as part of our job scheduler). And SOME jobs need to run every 45 seconds or so.
I've been trying to get it to work, but have had no luck. It seems to work for FREQ=MINUTELY.
The text was updated successfully, but these errors were encountered: