Skip to content

Commit

Permalink
Add method inadvertently removed in #41 (#43)
Browse files Browse the repository at this point in the history
Since we have type piracy on types from Dates to allow them to act like
`TimeSpan`s, they could be used in `contains` until the signature was
restricted to `AbstractTimeSpan`s in #41 to mitigate breakage from
`contains` being reintroduced to Base.
  • Loading branch information
ararslan authored Apr 17, 2020
1 parent e10eecc commit de8a022
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/timespans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function contains(a::AbstractTimeSpan, b::AbstractTimeSpan)
return first(a) <= first(b) && last(a) >= last(b)
end

contains(a::AbstractTimeSpan, b) = contains(a, TimeSpan(b))

"""
overlaps(a, b)
Expand Down
1 change: 1 addition & 0 deletions test/timespans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ end
@test !contains(TimeSpan(11, 20), TimeSpan(10, 19))
@test !contains(TimeSpan(10, 19), TimeSpan(10, 21))
@test !contains(TimeSpan(11, 19), TimeSpan(10, 20))
@test contains(TimeSpan(1, 10), Nanosecond(4))
end

@testset "overlaps(::TimeSpan...)" begin
Expand Down

0 comments on commit de8a022

Please sign in to comment.