diff --git a/test/dates/adjusters.jl b/test/dates/adjusters.jl index 340e4d1e17f5b..15ea8b62faf1d 100644 --- a/test/dates/adjusters.jl +++ b/test/dates/adjusters.jl @@ -306,6 +306,8 @@ januarymondays2014 = [Dates.Date(2014,1,6),Dates.Date(2014,1,13),Dates.Date(2014 @test Dates.recur(x->!Dates.ismonday(x),startdate,stopdate;negate=true) == januarymondays2014 @test_throws ArgumentError Dates.recur((x,y)->x+y,Dates.Date(2013):Dates.Date(2014)) +@test_throws ArgumentError Dates.DateFunction((x,y)->x+y, false, Date(0)) +@test_throws ArgumentError Dates.DateFunction((dt)->2, false, Date(0)) @test length(Dates.recur(x->true,Dates.Date(2013):Dates.Date(2013,2))) == 32 @test length(Dates.recur(x->true,Dates.Date(2013):Dates.Date(2013,1,1))) == 1 @test length(Dates.recur(x->true,Dates.Date(2013):Dates.Date(2013,1,2))) == 2 diff --git a/test/dates/periods.jl b/test/dates/periods.jl index 989d50eec9898..f2b236d07a0dd 100644 --- a/test/dates/periods.jl +++ b/test/dates/periods.jl @@ -137,6 +137,9 @@ y2 = Dates.Year(2) @test typeof(y+ms) <: Dates.CompoundPeriod @test y > m @test d < w +@test mi < h +@test ms < h +@test ms < mi @test typemax(Dates.Year) == Dates.Year(typemax(Int64)) @test typemax(Dates.Year) + y == Dates.Year(-9223372036854775808) @test typemin(Dates.Year) == Dates.Year(-9223372036854775808) @@ -283,8 +286,10 @@ dt = Dates.DateTime(2014) @test 1ms - (2s + 7ms) == -((2s + 7ms) - 1ms) == (-6ms) - 2s emptyperiod = ((y + d) - d) - y @test emptyperiod == ((d + y) - y) - d == ((d + y) - d) - y +@test emptyperiod == 2y + (m - d) + ms - ((m - d) + 2y + ms) @test emptyperiod == 0ms @test string(emptyperiod) == "empty period" +@test string(ms + mi + d + m + y + w + h + s + 2y + m) == "3 years, 2 months, 1 week, 1 day, 1 hour, 1 minute, 1 second, 1 millisecond" @test 8d - s == 1w + 23h + 59mi + 59s @test h + 3mi == 63mi @test y - m == 11m @@ -337,6 +342,7 @@ cpa = [1y+1s 1m+1s 1w+1s 1d+1s; 1h+1s 1mi+1s 2m+1s 1s+1ms] @test [1y 1m; 1w 1d] + [1h 1mi; 1s 1ms] == [1y+1h 1m+1mi; 1w+1s 1d+1ms] @test [1y 1m; 1w 1d] - [1h 1mi; 1s 1ms] == [1y-1h 1m-1mi; 1w-1s 1d-1ms] +@test [1y 1m; 1w 1d] - [1h 1mi; 1s 1ms] - [1y-1h 1m-1mi; 1w-1s 1d-1ms] == [emptyperiod emptyperiod; emptyperiod emptyperiod] @test [1y+1s 1m+1s; 1w+1s 1d+1s] + [1h 1mi; 1s 1ms] == [1y+1h+1s 1m+1mi+1s; 1w+2s 1d+1s+1ms] @test [1y+1s 1m+1s; 1w+1s 1d+1s] - [1h 1mi; 1s 1ms] == [1y-1h+1s 1m-1mi+1s; 1w 1d+1s-1ms]