Class HolidayCalendar
This implementation of the Calendar stores a list of holidays (full days that are excluded from scheduling).
[Serializable]
public sealed class HolidayCalendar : BaseCalendar, ICalendar, ISerializable, IEquatable<BaseCalendar>, IEquatable<HolidayCalendar>
- Inheritance
-
HolidayCalendar
- Implements
- Inherited Members
Remarks
The implementation DOES take the year into consideration, so if you want to exclude July 4th for the next 10 years, you need to add 10 entries to the exclude list.
Constructors
HolidayCalendar()
Initializes a new instance of the HolidayCalendar class.
public HolidayCalendar()
HolidayCalendar(ICalendar)
Initializes a new instance of the HolidayCalendar class.
public HolidayCalendar(ICalendar baseCalendar)
Parameters
baseCalendarICalendarThe base calendar.
Properties
DaysExcluded
The days excluded by this calendar.
public IReadOnlySet<DateOnly> DaysExcluded { get; }
Property Value
Methods
AddExcludedDay(DateOnly)
Excludes the given day.
public bool AddExcludedDay(DateOnly day)
Parameters
dayDateOnly
Returns
Clone()
Creates a new object that is a copy of the current instance.
public override ICalendar Clone()
Returns
- ICalendar
A new object that is a copy of this instance.
Equals(HolidayCalendar?)
Whether this calendar and other exclude the same times.
public bool Equals(HolidayCalendar? other)
Parameters
otherHolidayCalendarThe calendar to compare with.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
[SuppressMessage("Sonar", "S2328:GetHashCode should not reference mutable fields", Justification = "Content equality over mutable state is what a calendar is; see BaseCalendar.GetHashCode.")]
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Remarks
The hash is over the same mutable state Equals(BaseCalendar?) compares, which is what the two members have to agree on, and every calendar in this namespace is the same shape. A calendar is an editable description of excluded time — Description, the time zone, the excluded days — and the alternative to hashing it is a constant, which puts every calendar in one bucket and answers nothing. Nothing in Quartz keys a hash-based collection by a calendar instance: the stores hold calendars by name, and the name is a string.
GetNextIncludedTimeUtc(DateTimeOffset)
Determine the next time (in milliseconds) that is 'included' by the Calendar after the given time.
Note that this Calendar is only has full-day precision.
public override DateTimeOffset GetNextIncludedTimeUtc(DateTimeOffset timeUtc)
Parameters
timeUtcDateTimeOffset
Returns
GetObjectData(SerializationInfo, StreamingContext)
Writes this calendar's fields into a serialization payload.
[SecurityCritical]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoThe payload being written.
contextStreamingContextThe serialization context.
IsDayExcluded(DateOnly)
Returns true if the given day is excluded by this calendar.
public bool IsDayExcluded(DateOnly day)
Parameters
dayDateOnly
Returns
IsTimeIncluded(DateTimeOffset)
Determine whether the given time (in milliseconds) is 'included' by the Calendar.
Note that this Calendar is only has full-day precision.
public override bool IsTimeIncluded(DateTimeOffset timeStampUtc)
Parameters
timeStampUtcDateTimeOffset
Returns
RemoveExcludedDay(DateOnly)
Stops excluding the given day.
public bool RemoveExcludedDay(DateOnly day)
Parameters
dayDateOnly