Skip to content

Commit 3c1d4fc

Browse files
rofinnomus
authored andcommitted
Added Compat.AbstractDateTime (#443)
* Added Compat.AbstractDateTime. * Added tests and README entry for AbstractDateTime. * Added DateTime subtype check.
1 parent 8d6689e commit 3c1d4fc

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Currently, the `@compat` macro supports the following syntaxes:
301301

302302
## New types
303303

304-
Currently, no new exported types are introduced by Compat.
304+
* `Compat.AbstractDateTime` is an alias for `Compat.Dates.AbstractDateTime` as of ([#25227]) and `Compat.Dates.TimeType` prior to that.
305305

306306
## Developer tips
307307

src/Compat.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,12 @@ else
770770
import Dates
771771
end
772772

773+
if VERSION < v"0.7.0-DEV.3216"
774+
const AbstractDateTime = Compat.Dates.TimeType
775+
else
776+
const AbstractDateTime = Compat.Dates.AbstractDateTime
777+
end
778+
773779
if VERSION < v"0.7.0-DEV.3052"
774780
const Printf = Base.Printf
775781
else

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,10 @@ end
10831083
# 0.7.0-DEV.3172
10841084
@test replace("abcb", "b"=>"c") == "accc"
10851085
@test replace("abcb", "b"=>"c", count=1) == "accb"
1086+
# 0.7.0-DEV.3216
1087+
@test Compat.AbstractDateTime === (isdefined(Compat.Dates, :AbstractDateTime) ? Compat.Dates.AbstractDateTime : Compat.Dates.TimeType)
1088+
@test Compat.AbstractDateTime <: Compat.Dates.TimeType
1089+
@test Compat.Dates.DateTime <: Compat.AbstractDateTime
10861090

10871091
# 0.7.0-DEV.3025
10881092
let c = CartesianIndices(1:3, 1:2), l = LinearIndices(1:3, 1:2)

0 commit comments

Comments
 (0)