From 9af5ee7431a32e8f44ddc4a532aad8aef1548077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20St-Jean?= Date: Sat, 1 Apr 2023 06:48:16 -0400 Subject: [PATCH] Add sleep method (#628) --- src/Unitful.jl | 1 + src/dates.jl | 2 ++ test/dates.jl | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/Unitful.jl b/src/Unitful.jl index 50a59aed..ed34b1d5 100644 --- a/src/Unitful.jl +++ b/src/Unitful.jl @@ -16,6 +16,7 @@ import Base: length, float, last, one, oneunit, zero, range import Base: getindex, eltype, step, last, first, frexp import Base: Integer, Rational, typemin, typemax import Base: steprange_last, unsigned +import Base: sleep @static if VERSION ≥ v"1.7.0-DEV.119" import Base: isunordered end diff --git a/src/dates.jl b/src/dates.jl index c1738098..eee39e48 100644 --- a/src/dates.jl +++ b/src/dates.jl @@ -186,3 +186,5 @@ end isapprox(x::AbstractArray{Dates.CompoundPeriod}, y::AbstractArray{<:AbstractQuantity}; kwargs...) = isapprox(y, x; kwargs...) + +sleep(x::AbstractQuantity) = sleep(ustrip(s, x)) diff --git a/test/dates.jl b/test/dates.jl index fd4be784..0fff991f 100644 --- a/test/dates.jl +++ b/test/dates.jl @@ -783,4 +783,6 @@ @test_throws ErrorException promote(1u"m", Second(1)) @test_throws ErrorException promote(Day(1), 3u"T") end + + sleep(10u"ms") # not tested explicitly, because sleep doesn't come with guarantees end