We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 61f6082 commit e7425d5Copy full SHA for e7425d5
stdlib/Dates/src/arithmetic.jl
@@ -7,6 +7,7 @@
7
# TimeType arithmetic
8
(+)(x::TimeType) = x
9
(-)(x::T, y::T) where {T<:TimeType} = x.instant - y.instant
10
+(-)(x::TimeType, y::TimeType) = -(promote(x, y)...)
11
12
# Date-Time arithmetic
13
"""
stdlib/Dates/test/arithmetic.jl
@@ -10,6 +10,13 @@ using Dates
b = Dates.Time(11, 59, 59)
@test Dates.CompoundPeriod(a - b) == Dates.Hour(12)
end
+
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
20
@testset "Wrapping arithmetic for Months" begin
21
# This ends up being trickier than expected because
22
# the user might do 2014-01-01 + Month(-14)
0 commit comments