Table of Contents

Struct DateRange

Namespace
Payetools.Common.Model
Assembly
Payetools.Common.dll

Represents a date range.

public readonly struct DateRange : IEnumerable<DateOnly>, IEnumerable, IEquatable<DateRange>
Implements
Inherited Members
Extension Methods

Constructors

DateRange(DateOnly, DateOnly)

Initialises a new DateRange from the supplied start and end dates.

public DateRange(DateOnly startDate, DateOnly endDate)

Parameters

startDate DateOnly

Start of date range.

endDate DateOnly

End of date range.

Exceptions

ArgumentException

Thrown if endDate is before startDate.

DateRange(DateOnly, int, DateOnly?)

Initialises a new DateRange from the supplied start date and duration, ensuring that the end date is never later than the supplied latestAllowableDate.

public DateRange(DateOnly startDate, int duration, DateOnly? latestAllowableDate = null)

Parameters

startDate DateOnly

Start of date range.

duration int

Duration of the DateRange, in days.

latestAllowableDate DateOnly?

Latest allowable end date for the DateRange.

Exceptions

ArgumentException

Thrown if duration is less than a day.

Properties

End

Gets the end of this date range.

public DateOnly End { get; }

Property Value

DateOnly

Start

Gets the start of this date range.

public DateOnly Start { get; }

Property Value

DateOnly

Methods

Equals(DateRange)

Determines whether two DateRange instances are equal.

public bool Equals(DateRange other)

Parameters

other DateRange

DateRange to compare for equality.

Returns

bool

True if the two DateRanges are equivalent; false otherwise.

Equals(object?)

Determines whether two DateRange instances are equal.

public override bool Equals(object? obj)

Parameters

obj object

Object to compare for equality.

Returns

bool

True if the two DateRanges are equivalent; false otherwise.

GetEnumerator()

Gets an enumerator across this DateRange. Enables use of foreach.

public IEnumerator<DateOnly> GetEnumerator()

Returns

IEnumerator<DateOnly>

Enumerator for enumerating across all the dates in between the Start and End dates.

GetHashCode()

Returns the hash code for this object.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents the current object. Intended mainly for debug purposes.

public override string ToString()

Returns

string

String representation of the DateRange in the format: start - end.

Operators

operator ==(DateRange, DateRange)

Evaluates whether two range ranges are equivalent.

public static bool operator ==(DateRange left, DateRange right)

Parameters

left DateRange

First DateRange to compare.

right DateRange

Second DateRange to compare.

Returns

bool

True if the two DateRanges are equivalent; false otherwise.

operator !=(DateRange, DateRange)

Evaluates whether two range ranges are not equivalent.

public static bool operator !=(DateRange left, DateRange right)

Parameters

left DateRange

First DateRange to compare.

right DateRange

Second DateRange to compare.

Returns

bool

True if the two DateRanges are not equivalent; false otherwise.