Table of Contents

Class AnnualCalendar

Namespace
Quartz.Impl.Calendar
Assembly
Quartz.dll

This implementation of the Calendar excludes a set of days of the year. You may use it to exclude bank holidays which are on the same date every year.

[Serializable]
public sealed class AnnualCalendar : BaseCalendar, ICalendar, ISerializable, IEquatable<BaseCalendar>, IEquatable<AnnualCalendar>
Inheritance
AnnualCalendar
Implements
Inherited Members

Constructors

AnnualCalendar()

Creates a calendar that excludes no day, and defers to nothing.

public AnnualCalendar()

AnnualCalendar(ICalendar)

Creates a calendar that excludes no day of its own and defers to baseCalendar for the days it excludes.

public AnnualCalendar(ICalendar baseCalendar)

Parameters

baseCalendar ICalendar

The calendar this one is layered over.

Properties

DaysExcluded

The days excluded by this calendar, every year.

public IReadOnlySet<MonthDay> DaysExcluded { get; }

Property Value

IReadOnlySet<MonthDay>

Methods

AddExcludedDay(MonthDay)

Excludes the given day of every year.

public bool AddExcludedDay(MonthDay day)

Parameters

day MonthDay

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(AnnualCalendar?)

Whether this calendar and other exclude the same times.

public bool Equals(AnnualCalendar? other)

Parameters

other AnnualCalendar

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 UTC time (in milliseconds) that is 'included' by the Calendar after the given time. Return the original value if timeStampUtc is included. Return 0 if all days are excluded.

Note that this Calendar is only has full-day precision.

public override DateTimeOffset GetNextIncludedTimeUtc(DateTimeOffset timeStampUtc)

Parameters

timeStampUtc 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(MonthDay)

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

public bool IsDayExcluded(MonthDay day)

Parameters

day MonthDay

Returns

bool

IsTimeIncluded(DateTimeOffset)

Determine whether the given UTC time (in milliseconds) is 'included' by the Calendar.

Note that this Calendar is only has full-day precision.

public override bool IsTimeIncluded(DateTimeOffset dateUtc)

Parameters

dateUtc DateTimeOffset

Returns

bool

RemoveExcludedDay(MonthDay)

Stops excluding the given day.

public bool RemoveExcludedDay(MonthDay day)

Parameters

day MonthDay

Returns

bool

true if the day was excluded.

See Also