Skip to content

Commit 32ed459

Browse files
committed
Limit TimeType subtraction to AbstractDateTime
1 parent 406ba12 commit 32ed459

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

stdlib/Dates/src/arithmetic.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# TimeType arithmetic
88
(+)(x::TimeType) = x
99
(-)(x::T, y::T) where {T<:TimeType} = x.instant - y.instant
10-
(-)(x::TimeType, y::TimeType) = -(promote(x, y)...)
10+
(-)(x::AbstractDateTime, y::AbstractDateTime) = -(promote(x, y)...)
1111

1212
# Date-Time arithmetic
1313
"""

stdlib/Dates/test/arithmetic.jl

-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ using Dates
1111
@test Dates.CompoundPeriod(a - b) == Dates.Hour(12)
1212
end
1313

14-
@testset "TimeType arithmetic" begin
15-
a = Date(2023, 5, 1)
16-
b = DateTime(2023, 5, 2)
17-
@test b - a == Day(1)
18-
end
19-
2014
@testset "Wrapping arithmetic for Months" begin
2115
# This ends up being trickier than expected because
2216
# the user might do 2014-01-01 + Month(-14)

0 commit comments

Comments
 (0)