Noda Time
Show / Hide Table of Contents

Class ZonedDateTime.Comparer

Base class for ZonedDateTime comparers.
Inheritance
Object
ZonedDateTime.Comparer
Implements
IComparer<ZonedDateTime>
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>
Remarks

Use the static properties of this class to obtain instances.

For the curious: this class only exists so that in the future, it can expose more functionality - probably implementing IEqualityComparer<T>. If we simply provided properties on ZonedDateTime of type IComparer<T> we'd have no backward-compatible way of adding to the set of implemented interfaces.

Properties

Instant

Returns a comparer which compares ZonedDateTime values by the instants obtained by applying the offset to the local date/time, ignoring the calendar system.
Declaration
public static ZonedDateTime.Comparer Instant { get; }
Property Value
Type Description
ZonedDateTime.Comparer
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 comparer behaves the same way as the CompareTo(ZonedDateTime) method; it is provided for symmetry with Local.

This property will return a reference to the same instance every time it is called.

Local

Returns a comparer which compares ZonedDateTime values by their local date/time, without reference to the time zone, offset or the calendar system.
Declaration
public static ZonedDateTime.Comparer Local { get; }
Property Value
Type Description
ZonedDateTime.Comparer
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.
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.
ValueMeaning
Less than zerox is less than y.
Zerox is equals to y.
Greater than zerox is greater than y.
Remarks

Use the static properties of this class to obtain instances.

For the curious: this class only exists so that in the future, it can expose more functionality - probably implementing IEqualityComparer<T>. If we simply provided properties on ZonedDateTime of type IComparer<T> we'd have no backward-compatible way of adding to the set of implemented interfaces.

Implements

System.Collections.Generic.IComparer<T>
In This Article
Back to top Generated by DocFX