Table of Contents

Class BaseCalendar

Namespace
Quartz.Impl.Calendar
Assembly
Quartz.dll

This implementation of the Calendar may be used (you don't have to) as a base class for more sophisticated one's. It merely implements the base functionality required by each Calendar.

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

Remarks

Regarded as base functionality is the treatment of base calendars. Base calendar allow you to chain (stack) as much calendars as you may need. For example to exclude weekends you may use WeeklyCalendar. In order to exclude holidays as well you may define a WeeklyCalendar instance to be the base calendar for HolidayCalendar instance.

Constructors

BaseCalendar()

Initializes a new instance of the BaseCalendar class.

public BaseCalendar()

BaseCalendar(ICalendar?)

Initializes a new instance of the BaseCalendar class.

public BaseCalendar(ICalendar? baseCalendar)

Parameters

baseCalendar ICalendar

The base calendar.

BaseCalendar(ICalendar?, TimeZoneInfo?)

Initializes a new instance of the BaseCalendar class.

public BaseCalendar(ICalendar? baseCalendar, TimeZoneInfo? timeZone)

Parameters

baseCalendar ICalendar

The base calendar.

timeZone TimeZoneInfo

The time zone.

BaseCalendar(SerializationInfo, StreamingContext)

Serialization constructor.

protected BaseCalendar(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo
context StreamingContext

BaseCalendar(TimeZoneInfo)

Initializes a new instance of the BaseCalendar class.

public BaseCalendar(TimeZoneInfo timeZone)

Parameters

timeZone TimeZoneInfo

The time zone.

Properties

CalendarBase

Set a new base calendar or remove the existing one

public ICalendar? CalendarBase { get; set; }

Property Value

ICalendar

Description

Gets or sets the description given to the ICalendar instance by its creator (if any).

public string? Description { get; set; }

Property Value

string

TimeZone

Gets or sets the time zone.

public virtual TimeZoneInfo TimeZone { get; set; }

Property Value

TimeZoneInfo

The time zone.

Methods

Clone()

Creates a new object that is a copy of the current instance.

public virtual ICalendar Clone()

Returns

ICalendar

A new object that is a copy of this instance.

CloneFields(BaseCalendar)

Copies the fields every calendar has — description, time zone and base calendar — into a copy a derived type has constructed, which then copies its own.

protected BaseCalendar CloneFields(BaseCalendar clone)

Parameters

clone BaseCalendar

The copy being built.

Returns

BaseCalendar

The same copy, so that an override can return it directly.

Equals(BaseCalendar?)

Whether this calendar and other exclude the same times.

public bool Equals(BaseCalendar? other)

Parameters

other BaseCalendar

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 the remarks.")]
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 timeStamp is included. Return 0 if all days are excluded.

public virtual DateTimeOffset GetNextIncludedTimeUtc(DateTimeOffset timeUtc)

Parameters

timeUtc DateTimeOffset

Returns

DateTimeOffset
See Also

GetObjectData(SerializationInfo, StreamingContext)

Writes this calendar's fields into a serialization payload.

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

Parameters

info SerializationInfo

The payload being written.

context StreamingContext

The serialization context.

IsTimeIncluded(DateTimeOffset)

Check if date/time represented by timeStamp is included. If included return true. The implementation of BaseCalendar simply calls the base calendars IsTimeIncluded() method if base calendar is set.

public virtual bool IsTimeIncluded(DateTimeOffset timeStampUtc)

Parameters

timeStampUtc DateTimeOffset

Returns

bool
See Also

See Also