Noda Time
Show / Hide Table of Contents

Class ZoneEqualityComparer

Equality comparer for time zones, comparing specific aspects of the zone intervals within a time zone for a specific interval of the time line.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Inheritance
object
ZoneEqualityComparer
Implements
IEqualityComparer<DateTimeZone>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NodaTime.TimeZones
Assembly: NodaTime.dll
Syntax
public sealed class ZoneEqualityComparer : IEqualityComparer<DateTimeZone?>
Remarks
The default behaviour of this comparator is to consider two time zones to be equal if they share the same wall offsets at all points within a given time interval, regardless of other aspects of each ZoneInterval within the two time zones. This behaviour can be changed using the WithOptions(Options) method.

Methods

Equals(DateTimeZone?, DateTimeZone?)

Compares two time zones for equality according to the options and interval provided to this comparer.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public bool Equals(DateTimeZone? x, DateTimeZone? y)
Parameters
Type Name Description
DateTimeZone x The first DateTimeZone to compare.
DateTimeZone y The second DateTimeZone to compare.
Returns
Type Description
bool true if the specified time zones are equal under the options and interval of this comparer; otherwise, false.

ForInterval(Interval)

Returns a ZoneEqualityComparer for the given interval with the default options.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static ZoneEqualityComparer ForInterval(Interval interval)
Parameters
Type Name Description
Interval interval The interval over which to compare time zones. This must have both a start and an end.
Returns
Type Description
ZoneEqualityComparer A ZoneEqualityComparer for the given interval with the default options.
Remarks
The default behaviour of this comparator is to consider two time zones to be equal if they share the same wall offsets at all points within a given interval. To specify non-default options, call the WithOptions(Options) method on the result of this method.

GetHashCode(DateTimeZone?)

Returns a hash code for the specified time zone.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public int GetHashCode(DateTimeZone? obj)
Parameters
Type Name Description
DateTimeZone obj The time zone to compute a hash code for.
Returns
Type Description
int A hash code for the specified object.
Remarks
The hash code generated by any instance of ZoneEqualityComparer will be equal to the hash code generated by any other instance constructed with the same options and interval, for the same time zone (or equal ones). Two instances of ZoneEqualityComparer with different options or intervals may (but may not) produce different hash codes for the same zone.

WithOptions(Options)

Returns a comparer operating over the same interval as this one, but with the given set of options.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public ZoneEqualityComparer WithOptions(ZoneEqualityComparer.Options options)
Parameters
Type Name Description
ZoneEqualityComparer.Options options New set of options, which must consist of flags defined within the ZoneEqualityComparer.Options enum.
Returns
Type Description
ZoneEqualityComparer A comparer operating over the same interval as this one, but with the given set of options.
Remarks
This method does not modify the comparer on which it's called.
Exceptions
Type Condition
ArgumentOutOfRangeException The specified options are invalid.

Implements

IEqualityComparer<T>
In this article
Back to top Generated by DocFX