Class MonthlyCalendar
This implementation of the Calendar excludes a set of days of the month. You may use it to exclude every 1. of each month for example. But you may define any day of a month.
[Serializable]
public sealed class MonthlyCalendar : BaseCalendar, ICalendar, ISerializable, IEquatable<BaseCalendar>, IEquatable<MonthlyCalendar>
- Inheritance
-
MonthlyCalendar
- Implements
- Inherited Members
Constructors
MonthlyCalendar()
Initializes a new instance of the MonthlyCalendar class.
public MonthlyCalendar()
MonthlyCalendar(ICalendar)
Creates a calendar that excludes no day of the month of its own and defers to
baseCalendar for the days it excludes.
public MonthlyCalendar(ICalendar baseCalendar)
Parameters
baseCalendarICalendarThe calendar this one is layered over.
Properties
DaysExcluded
The days of the month excluded by this calendar, 1 through 31.
public IReadOnlySet<int> DaysExcluded { get; }
Property Value
Methods
AddExcludedDay(int)
Excludes the given day of every month.
public bool AddExcludedDay(int day)
Parameters
dayintThe day of the month, 1 through 31.
Returns
AreAllDaysExcluded()
Check if all days are excluded. That is no day is included.
public bool AreAllDaysExcluded()
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(MonthlyCalendar?)
Whether this calendar and other exclude the same times.
public bool Equals(MonthlyCalendar? other)
Parameters
otherMonthlyCalendarThe 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. 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
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(int)
Return true, if day is defined to be excluded.
public bool IsDayExcluded(int day)
Parameters
dayintThe day of the month, 1 through 31.
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(int)
Stops excluding the given day of the month.
public bool RemoveExcludedDay(int day)
Parameters
dayintThe day of the month, 1 through 31.