# Class Calendar OptimaJet.Workflow.Core.Runtime.Calendars.Calendar Represents a work calendar. Namespace: [OptimaJet.Workflow.Core.Runtime.Calendars](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/) ```csharp public class Calendar : ICalendar ``` ## Type Hierarchy - Calendar Current type - Implemented interfaces - [ICalendar](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/ICalendar/) ## Properties `public string Name { get; set; }` Gets or sets the calendar name. `public TimeSpan WorkingHours { get; set; }` Gets or sets the default working duration for a workday. ### Remarks The default value is eight hours. `public TimeSpan StartOfWork { get; set; }` Gets or sets the default start time of the workday. `public List Weekends { get; set; }` Gets or sets the days of week that are weekends. `public Dictionary Years { get; set; }` Gets or sets year-specific calendar settings. ## Methods `public bool IsWorkday(DateTime day)` Determines whether the specified date is a workday. ### Parameters | Name | Type | Description | | --- | --- | --- | | `day` | `DateTime` | The date to evaluate. | ### Returns | Type | Description | | --- | --- | | `Boolean` | `true` if the date is a workday; otherwise, `false`. | `public bool IsWorkTime(DateTime datetime)` Determines whether the specified date is a workday and its time has not passed the end of that workday. ### Parameters | Name | Type | Description | | --- | --- | --- | | `datetime` | `DateTime` | The date and time to evaluate. | ### Returns | Type | Description | | --- | --- | | `Boolean` | `true` if `datetime` is on a workday and is no later than the end of that workday; otherwise, `false`. | ### Remarks Times before the configured start of the workday are considered valid. `public TimeSpan GetRestOfWorkday(DateTime day)` Gets the duration from the specified date and time to the configured end of its workday. ### Parameters | Name | Type | Description | | --- | --- | --- | | `day` | `DateTime` | The date and time to evaluate. | ### Returns | Type | Description | | --- | --- | | `TimeSpan` | The duration until the configured workday end. The value is negative when `day` is later than that time. | ### Remarks The calculation is performed even when `day` is not a workday. `public TimeSpan GetStartOfWorkday(DateTime day)` Gets the configured start time of the workday for the specified date. ### Parameters | Name | Type | Description | | --- | --- | --- | | `day` | `DateTime` | The date used to resolve individual workday settings. | ### Returns | Type | Description | | --- | --- | | `TimeSpan` | The individual start time configured for the date, or the default start time. | `public DateTime FindWorkDayStart(DateTime searchFrom)` Finds the first workday start strictly later than the specified date and time. ### Parameters | Name | Type | Description | | --- | --- | --- | | `searchFrom` | `DateTime` | The exclusive lower bound for the search. | ### Returns | Type | Description | | --- | --- | | `DateTime` | The date and time when the matching workday starts. | ### Exceptions | Type | Description | | --- | --- | | `ArithmeticException` | No workday is found during the one-year search period. | `public DateTime FindWorkDayEnd(DateTime searchFrom)` Finds the first workday end strictly later than the specified date and time. ### Parameters | Name | Type | Description | | --- | --- | --- | | `searchFrom` | `DateTime` | The exclusive lower bound for the search. | ### Returns | Type | Description | | --- | --- | | `DateTime` | The date and time when the matching workday ends. | ### Exceptions | Type | Description | | --- | --- | | `ArithmeticException` | No workday is found during the one-year search period. | `public DateTime FindWorkDayTime(DateTime searchFrom)` Returns the specified date and time when it is accepted by [ICalendar.IsWorkTime(DateTime)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/ICalendar/); otherwise, finds the first subsequent workday start. ### Parameters | Name | Type | Description | | --- | --- | --- | | `searchFrom` | `DateTime` | The date and time to evaluate. | ### Returns | Type | Description | | --- | --- | | `DateTime` | `searchFrom` if it is accepted by [ICalendar.IsWorkTime(DateTime)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/ICalendar/); otherwise, the next workday start time. | ### Exceptions | Type | Description | | --- | --- | | `ArithmeticException` | No workday is found during the one-year search period. | `public List GetWorkDaysInRange(DateTime from, DateTime to)` Gets the workday start times strictly between the specified bounds. ### Parameters | Name | Type | Description | | --- | --- | --- | | `from` | `DateTime` | The exclusive lower bound of the range. | | `to` | `DateTime` | The exclusive upper bound of the range. | ### Returns | Type | Description | | --- | --- | | `List` | The workday start times that are later than `from` and earlier than `to`, ordered chronologically. | `public static Calendar Create(string name)` Creates a new calendar instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The calendar name. | ### Returns | Type | Description | | --- | --- | | `Calendar` | A new [Calendar](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/Calendar/) with [Calendar.Name](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/Calendar/) set to `name`. | `public override bool Equals(object obj)` Determines whether the specified object is equal to this calendar. ### Parameters | Name | Type | Description | | --- | --- | --- | | `obj` | `Object` | The object to compare with the current calendar. | ### Returns | Type | Description | | --- | --- | | `Boolean` | `true` if the specified object is a calendar with matching settings; otherwise, `false`. | `public override int GetHashCode()` Returns a hash code for this calendar based on its configuration values. ### Returns | Type | Description | | --- | --- | | `Int32` | A hash code for this instance. | [Previous IBulkApi](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Bulk/IBulkApi/) [Next CalendarExtensions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/CalendarExtensions/)