The EqualsImpl
method in the Nodatime BclDateTimeZone
class throws a NotImplementedException
. It is documented to behave in this way - is there a reason for this?
If testing equality of two ZonedDateTime
s that use a BclDateTimeZone
this causes the exception to be thrown.
Is this a bug, it doesn't seem right?
It is documented to behave in this way - is there a reason for this?
Yup - it's basically very hard to determine zone equality in a general way. Suppose we have two BclDateTimeZone
instances which wrap two distinct TimeZoneInfo
values... we could:
TimeZoneInfo.Local
has an ID of Local
IIRC)I agree that it's a pain, and I think I'm planning on removing value equality on ZonedDateTime
entirely in Noda Time 2.0, and make ZonedDateTime
use reference equality.
If you want to compare time zones, a better alternative is likely to be the use of ZonedEqualityComparer
to specify how you want them to be compared.
But the inability to compare ZonedDateTime
values for equality when using BCL values is definitely nasty. I've raised a bug for that; I'm preparing a 1.3.1 release, and I might see if I can fix it there, rather than you having to wait for 2.0.
See more on this question at Stackoverflow