Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stdlib/Dates/src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# TimeType arithmetic
(+)(x::TimeType) = x
(-)(x::T, y::T) where {T<:TimeType} = x.instant - y.instant
(-)(x::TimeType, y::TimeType) = -(promote(x, y)...)
(-)(x::T, y::T) where {T<:AbstractDateTime} = x.instant - y.instant
(-)(x::AbstractDateTime, y::AbstractDateTime) = -(promote(x, y)...)

# Date-Time arithmetic
"""
Expand Down
6 changes: 0 additions & 6 deletions stdlib/Dates/test/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ using Dates
@test Dates.CompoundPeriod(a - b) == Dates.Hour(12)
end

@testset "TimeType arithmetic" begin
a = Date(2023, 5, 1)
b = DateTime(2023, 5, 2)
@test b - a == Day(1)
end

@testset "Wrapping arithmetic for Months" begin
# This ends up being trickier than expected because
# the user might do 2014-01-01 + Month(-14)
Expand Down