Skip to content

Commit

Permalink
Fix hashing of Dates.Time. Fixes #29480
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Oct 4, 2018
1 parent 5bc3de4 commit 1229ee4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/Dates/src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ 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), h)))

import Base: sleep, Timer, timedwait
sleep(time::Period) = sleep(toms(time) / 1000)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/Dates/test/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ 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))
end
@testset "Date-DateTime conversion/promotion" begin
global a, b, c, d
Expand Down

0 comments on commit 1229ee4

Please sign in to comment.