Table of Contents

Class HolidayCalendar

Namespace
Quartz.Impl.Calendar
Assembly
Quartz.dll

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

baseCalendar ICalendar

The base calendar.

Properties

DaysExcluded

The days excluded by this calendar.

public IReadOnlySet<DateOnly> DaysExcluded { get; }

Property Value

IReadOnlySet<DateOnly>

Methods

AddExcludedDay(DateOnly)

Excludes the given day.

public bool AddExcludedDay(DateOnly day)

Parameters

day DateOnly

Returns

bool

true if the day was not already excluded.

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

other HolidayCalendar

The calendar to compare with.

Returns

bool

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

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

timeUtc DateTimeOffset

Returns

DateTimeOffset

GetObjectData(SerializationInfo, StreamingContext)

Writes this calendar's fields into a serialization payload.

[SecurityCritical]
public override void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

The payload being written.

context StreamingContext

The serialization context.

IsDayExcluded(DateOnly)

Returns true if the given day is excluded by this calendar.

public bool IsDayExcluded(DateOnly day)

Parameters

day DateOnly

Returns

bool

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

timeStampUtc DateTimeOffset

Returns

bool

RemoveExcludedDay(DateOnly)

Stops excluding the given day.

public bool RemoveExcludedDay(DateOnly day)

Parameters

day DateOnly

Returns

bool

true if the day was excluded.