diff --git a/README.md b/README.md index ff906169e..2e25a4039 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,9 @@ Currently, the `@compat` macro supports the following syntaxes: Compat.DelimitedFiles` are provided on versions older than 0.7, where these are not yet part of the standard library. ([#23931]) +* `using Compat.Dates` is provided on versions older than 0.7, where this library is not + yet a part of the standard library. ([#24459]) + ## Module Aliases * In 0.6, some 0.5 iterator functions have been moved to the `Base.Iterators` @@ -357,4 +360,5 @@ includes this fix. Find the minimum version from there. [#24047]: https://github.com/JuliaLang/julia/issues/24047 [#24282]: https://github.com/JuliaLang/julia/issues/24282 [#24372]: https://github.com/JuliaLang/julia/issues/24372 +[#24459]: https://github.com/JuliaLang/julia/issues/24459 [#24657]: https://github.com/JuliaLang/julia/issues/24657 diff --git a/src/Compat.jl b/src/Compat.jl index f3ce0992f..5b705565c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -695,6 +695,12 @@ else import Test, SharedArrays, Mmap, DelimitedFiles end +if VERSION < v"0.7.0-DEV.2575" + const Dates = Base.Dates +else + import Dates +end + # 0.7.0-DEV.1993 @static if !isdefined(Base, :EqualTo) if VERSION >= v"0.6.0" diff --git a/test/runtests.jl b/test/runtests.jl index 608ae182c..2483558e5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -645,6 +645,8 @@ cm359() = @__MODULE__ # PR 21378 let + import Compat: Dates + # https://en.wikipedia.org/wiki/Swatch_Internet_Time eval(Expr( :type, false, @@ -657,7 +659,7 @@ let Dates.toms(b::Beat) = Dates.value(b) * 86400 Dates._units(b::Beat) = " beat" * (abs(Dates.value(b)) == 1 ? "" : "s") Base.promote_rule(::Type{Dates.Day}, ::Type{Beat}) = Dates.Millisecond - Base.convert{T<:Dates.Millisecond}(::Type{T}, b::Beat) = T(Dates.toms(b)) + Base.convert(::Type{Dates.Millisecond}, b::Beat) = Dates.Millisecond(Dates.toms(b)) @test Beat(1000) == Dates.Day(1) @test Beat(1) < Dates.Day(1) @@ -847,6 +849,14 @@ module Test23876 @test isdefined(Mmap, :mmap) end +# 0.7 +module Test24459 + using Compat + using Compat.Test + using Compat.Dates + @test isdefined(@__MODULE__, :Dates) +end + let a = [0,1,2,3,0,1,2,3] @test findfirst(equalto(3), [1,2,4,1,2,3,4]) == 6 @test findfirst(!equalto(1), [1,2,4,1,2,3,4]) == 2