From a656e1492fe41249dabac44873b9769f81a08349 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 17 Apr 2020 14:29:28 -0700 Subject: [PATCH] Add method inadvertently removed in #41 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. --- src/timespans.jl | 2 ++ test/timespans.jl | 1 + 2 files changed, 3 insertions(+) diff --git a/src/timespans.jl b/src/timespans.jl index 90aa8ebe..5e33a01a 100644 --- a/src/timespans.jl +++ b/src/timespans.jl @@ -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) diff --git a/test/timespans.jl b/test/timespans.jl index 0fcb12aa..1127bb84 100644 --- a/test/timespans.jl +++ b/test/timespans.jl @@ -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