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 net45, netstandard1.3
Inheritance
Object
ZoneEqualityComparer
Implements
IEqualityComparer<DateTimeZone>
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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(ZoneEqualityComparer.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 net45, netstandard1.3
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 |
---|---|
Boolean | 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 net45, netstandard1.3
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(ZoneEqualityComparer.Options) method on the result
of this method.
GetHashCode(DateTimeZone)
Returns a hash code for the specified time zone.
Since 1.1.x
Availability net45, netstandard1.3
Declaration
public int GetHashCode(DateTimeZone obj)
Parameters
Type | Name | Description |
---|---|---|
DateTimeZone | obj | The time zone to compute a hash code for. |
Returns
Type | Description |
---|---|
Int32 | 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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | obj is null. |
WithOptions(ZoneEqualityComparer.Options)
Returns a comparer operating over the same interval as this one, but with the given
set of options.
Since 1.1.x
Availability net45, netstandard1.3
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
System.Collections.Generic.IEqualityComparer<T>