Chris, That is not what I am seeing in Pharo 7: date1 := Date today. date2 := Date today translateToUTC. date1 = date2. "false" date1 hash = date2 hash. "false" dictionary := Dictionary new. dictionary at: date1 put: date1. dictionary at: date2 put: date2. (dictionary at: date1) = date1. "true" (dictionary at: date2) = date2. "true" dictionary. "a Dictionary(17 October 2018->17 October 2018 17 October 2018->17 October 2018 )" date1 offset. "0:02:00:00" date2 offset. "0:00:00:00" Both dates are different, but they are equal (an operation that ignores the offsets) date1 equals: date2. "true" Sven
On 17 Oct 2018, at 16:33, Chris Cunningham <cunningham.cb@gmail.com> wrote:
Hi,
On Tue, Oct 16, 2018 at 1:28 PM Alistair Grant <akgrant0710@gmail.com> wrote: Hi Petr,
On Tue, 16 Oct 2018 at 21:25, Petr Fischer via Pharo-users <pharo-users@lists.pharo.org> wrote:
My problem - use Dates as Dictionary keys - shortly:
d1 := Date today translateToUTC. d2 := Date today.
d1 = d2. (true!)
Of course, this doesn't help with using Date as a key in a dictionary. Probably your best option is to look at Sven's excellent ZTimezone package (although I haven't tested it in this scenario).
The base problem here is that the hash of the dates is not the same for dates that are equal - that should never happen. If you try d1 hash = d2 hash you should see that the hash's are different (Petr for sure; you for the cases where the offsets are different).
When objects (especially fo the same class) are =, then their hash must be the same as well, or things break.
-cbc