Skip to content

Commit

Permalink
Fix hashing of Dates.Time. Fixes #29480 (#29742)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Oct 21, 2018
1 parent 53563cd commit 1db6047
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/Dates/src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ function ==(a::Time, b::Time)
microsecond(a) == microsecond(b) && nanosecond(a) == nanosecond(b)
end
(==)(x::TimeType, y::TimeType) = (===)(promote(x, y)...)
Base.hash(x::Time, h::UInt) =
hash(hour(x), hash(minute(x), hash(second(x),
hash(millisecond(x), hash(microsecond(x), hash(nanosecond(x), h))))))

import Base: sleep, Timer, timedwait
sleep(time::Period) = sleep(toms(time) / 1000)
Expand Down
4 changes: 4 additions & 0 deletions stdlib/Dates/test/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ c = Dates.Time(0)
@test isfinite(Dates.Date)
@test isfinite(Dates.DateTime)
@test isfinite(Dates.Time)
@test c == c
@test c == (c + Dates.Hour(24))
@test hash(c) == hash(c + Dates.Hour(24))
@test hash(c + Dates.Nanosecond(10)) == hash(c + Dates.Hour(24) + Dates.Nanosecond(10))
end
@testset "Date-DateTime conversion/promotion" begin
global a, b, c, d
Expand Down

4 comments on commit 1db6047

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.