Table of Contents

Class WeeklyCalendar

Namespace
Quartz.Impl.Calendar
Assembly
Quartz.dll

This implementation of the Calendar excludes a set of days of the week. You may use it to exclude weekends for example. But you may define any day of the week. By default it excludes Saturday and Sunday.

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

Constructors

WeeklyCalendar()

Initializes a new instance of the WeeklyCalendar class, excluding Saturday and Sunday.

public WeeklyCalendar()

WeeklyCalendar(ICalendar)

Initializes a new instance of the WeeklyCalendar class, excluding Saturday and Sunday.

public WeeklyCalendar(ICalendar baseCalendar)

Parameters

baseCalendar ICalendar

The base calendar.

Properties

DaysExcluded

The days of the week excluded by this calendar.

public IReadOnlySet<DayOfWeek> DaysExcluded { get; }

Property Value

IReadOnlySet<DayOfWeek>

Methods

AddExcludedDay(DayOfWeek)

Excludes the given day of every week.

public bool AddExcludedDay(DayOfWeek day)

Parameters

day DayOfWeek

Returns

bool

true if the day was not already excluded.

AreAllDaysExcluded()

Check if all week days are excluded. That is no day is included.

public bool AreAllDaysExcluded()

Returns

bool

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

Whether this calendar and other exclude the same times.

public bool Equals(WeeklyCalendar? other)

Parameters

other WeeklyCalendar

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. Return the original value if timeStamp is included. Return DateTime.MinValue if all days are excluded.

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(DayOfWeek)

Return true, if the given day of the week is defined to be excluded.

public bool IsDayExcluded(DayOfWeek day)

Parameters

day DayOfWeek

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 timeUtc)

Parameters

timeUtc DateTimeOffset

Returns

bool

RemoveExcludedDay(DayOfWeek)

Stops excluding the given day of the week.

public bool RemoveExcludedDay(DayOfWeek day)

Parameters

day DayOfWeek

Returns

bool

true if the day was excluded.

See Also