Class CalendarExtensions
OptimaJet.Workflow.Core.Runtime.Calendars.CalendarExtensions
Provides extension methods for configuring Calendar instances and calculating intervals using workflow calendar rules.
Namespace: OptimaJet.Workflow.Core.Runtime.Calendars
public static class CalendarExtensionsMethods
public static TimeSpan GetInterval(this ICalendar calendar, string value, DateTime startDateTime) #Gets the interval represented by
value, optionally applying calendar-specific working-day rules.Parameters
Name
Type
Description
calendarICalendarCalendar settings used for working-time values.
valueStringA timer expression string.
startDateTimeDateTimeThe start point for the interval calculation.
Returns
Type
Description
TimeSpanA TimeSpan value that can be added to
startDateTime to get the target time.Exceptions
Type
Description
ArgumentNullExceptionThrown when
value is null.ArgumentExceptionThrown when
value mixes calendar and non-calendar interval units.Remarks
If
value contains calendar-prefixed units (wyear, wmonth, wdays, whours, wminutes), calendar working-day logic is used. Otherwise normal interval parsing is delegated to HelperDateTime.GetInterval(string).public static Calendar SetWorkingHours(this Calendar calendar, TimeSpan workingHours) #Sets the total working hours per workday and returns the same Calendar instance.
Parameters
Name
Type
Description
calendarCalendarCalendar instance to update.
workingHoursTimeSpanWorking hours to configure.
Returns
Type
Description
CalendarThe updated
calendar.Exceptions
Type
Description
ArgumentOutOfRangeExceptionThrown if
workingHours is greater than 24 hours, or if it causes the workday to exceed 24 hours when combined with Calendar.StartOfWork.Remarks
The value is normalized using HelperDateTime.Floor(TimeSpan), so seconds and milliseconds are dropped.
public static Calendar SetStartOfWork(this Calendar calendar, TimeSpan startTimeOfDay) #Sets the start time of the workday and returns the same Calendar instance.
Parameters
Name
Type
Description
calendarCalendarCalendar instance to update.
startTimeOfDayTimeSpanTime of day when the working period starts.
Returns
Type
Description
CalendarThe updated
calendar.Exceptions
Type
Description
ArgumentOutOfRangeExceptionThrown if
startTimeOfDay is greater than 24 hours, or if it causes the workday to exceed 24 hours with Calendar.WorkingHours.Remarks
The value is normalized using HelperDateTime.Floor(TimeSpan), so seconds and milliseconds are dropped.
public static Calendar SetWeekends(this Calendar calendar, params DayOfWeek[] weekends) #Adds the specified weekend days to Calendar.Weekends and returns the same Calendar instance.
Parameters
Name
Type
Description
calendarCalendarCalendar instance to update.
weekendsDayOfWeek[]Weekday values to add as weekends.
Returns
Type
Description
CalendarThe updated
calendar.Exceptions
Type
Description
ArgumentNullExceptionThrown when
weekends is null.public static Calendar SetYears(this Calendar calendar, params Year[] years) #Adds year-level settings to the calendar and returns the same Calendar instance.
Parameters
Name
Type
Description
calendarCalendarCalendar instance to update.
Returns
Type
Description
CalendarThe updated
calendar.Exceptions
Type
Description
ArgumentExceptionThrown if a value with the same Year.YearNumber already exists in Calendar.Years.