Class OffsetDateTime.Comparer
Base class for OffsetDateTime comparers.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public abstract class OffsetDateTime.Comparer : IComparer<OffsetDateTime>, IEqualityComparer<OffsetDateTime>
Remarks
Use the static properties of this class to obtain instances. This type is exposed so that the
same value can be used for both equality and ordering comparisons.
Properties
Instant
Returns a comparer which compares OffsetDateTime values by the instant values obtained by applying the offset to
the local date/time, ignoring the calendar system.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static OffsetDateTime.Comparer Instant { get; }
Property Value
Type | Description |
---|---|
OffsetDateTime.Comparer | A comparer which compares values by the instant values obtained by applying the offset to the local date/time, ignoring the calendar system. |
Remarks
For example, this comparer considers 2013-03-04T20:21:00+0100 to be earlier than 2013-03-04T19:21:00-0700 even though the second value has a local time which is earlier.
This property will return a reference to the same instance every time it is called.
Local
Gets a comparer which compares OffsetDateTime values by their local date/time, without reference to
the offset. Comparisons between two values of different calendar systems will fail with ArgumentException.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static OffsetDateTime.Comparer Local { get; }
Property Value
Type | Description |
---|---|
OffsetDateTime.Comparer | A comparer which compares values by their local date/time, without reference to the offset. |
Remarks
For example, this comparer considers 2013-03-04T20:21:00+0100 to be later than 2013-03-04T19:21:00-0700 even though the second value represents a later instant in time.
This property will return a reference to the same instance every time it is called.
Methods
Compare(OffsetDateTime, OffsetDateTime)
Compares two OffsetDateTime values and returns a value indicating whether one is less than, equal to, or greater than the other.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public abstract int Compare(OffsetDateTime x, OffsetDateTime y)
Parameters
Type | Name | Description |
---|---|---|
OffsetDateTime | x | The first value to compare. |
OffsetDateTime | y | The second value to compare. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
int | A signed integer that indicates the relative values of x and y , as shown in the following table.
|
Equals(OffsetDateTime, OffsetDateTime)
Determines whether the specified
OffsetDateTime
values are equal.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public abstract bool Equals(OffsetDateTime x, OffsetDateTime y)
Parameters
Type | Name | Description |
---|---|---|
OffsetDateTime | x | The first OffsetDateTime to compare. |
OffsetDateTime | y | The second OffsetDateTime to compare. |
Returns
Type | Description |
---|---|
bool | true if the specified objects are equal; otherwise, false . |
GetHashCode(OffsetDateTime)
Returns a hash code for the specified
OffsetDateTime
.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public abstract int GetHashCode(OffsetDateTime obj)
Parameters
Type | Name | Description |
---|---|---|
OffsetDateTime | obj | The OffsetDateTime for which a hash code is to be returned. |
Returns
Type | Description |
---|---|
int | A hash code for the specified value. |