Class ZonedDateTime.Comparer
Base class for ZonedDateTime comparers.
Since 1.1.x
Availability net45, netstandard1.3
Inheritance
Object
ZonedDateTime.Comparer
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public abstract class Comparer : IComparer<ZonedDateTime>, IEqualityComparer<ZonedDateTime>
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
Gets a comparer which compares ZonedDateTime values by the instants obtained by applying the offset to
the local date/time, ignoring the calendar system.
Since 1.1.x
Availability net45, netstandard1.3
Declaration
public static ZonedDateTime.Comparer Instant { get; }
Property Value
Type | Description |
---|---|
ZonedDateTime.Comparer | A comparer which compares values by the instants 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 (Europe/London) to be earlier than 2013-03-04T19:21:00 (America/Los_Angeles) even though the second value has a local time which is earlier; the time zones mean that the first value occurred earlier in the universal time line.
This property will return a reference to the same instance every time it is called.
Local
Gets a comparer which compares ZonedDateTime values by their local date/time, without reference to
the time zone or offset. Comparisons between two values of different calendar systems will fail with System.ArgumentException.
Since 1.1.x
Availability net45, netstandard1.3
Declaration
public static ZonedDateTime.Comparer Local { get; }
Property Value
Type | Description |
---|---|
ZonedDateTime.Comparer | A comparer which compares values by their local date/time. |
Remarks
For example, this comparer considers 2013-03-04T20:21:00 (Europe/London) to be later than 2013-03-04T19:21:00 (America/Los_Angeles) 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(ZonedDateTime, ZonedDateTime)
Compares two ZonedDateTime values and returns a value indicating whether one is less than, equal to, or greater than the other.
Since 1.1.x
Availability net45, netstandard1.3
Declaration
public abstract int Compare(ZonedDateTime x, ZonedDateTime y)
Parameters
Type | Name | Description |
---|---|---|
ZonedDateTime | x | The first value to compare. |
ZonedDateTime | y | The second value to compare. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
Int32 | A signed integer that indicates the relative values of x and y , as shown in the following table.
|
Equals(ZonedDateTime, ZonedDateTime)
Determines whether the specified
ZonedDateTime
values are equal.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public abstract bool Equals(ZonedDateTime x, ZonedDateTime y)
Parameters
Type | Name | Description |
---|---|---|
ZonedDateTime | x | The first ZonedDateTime to compare. |
ZonedDateTime | y | The second ZonedDateTime to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the specified objects are equal; otherwise, false . |
GetHashCode(ZonedDateTime)
Returns a hash code for the specified
ZonedDateTime
.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public abstract int GetHashCode(ZonedDateTime obj)
Parameters
Type | Name | Description |
---|---|---|
ZonedDateTime | obj | The ZonedDateTime for which a hash code is to be returned. |
Returns
Type | Description |
---|---|
Int32 | A hash code for the specified value. |
Implements
System.Collections.Generic.IComparer<T>
System.Collections.Generic.IEqualityComparer<T>