Skip to content

Commit

Permalink
Add missing support for addition and subtraction
Browse files Browse the repository at this point in the history
Inspired by the discussion in JuliaLang#28570
  • Loading branch information
nilshg committed Aug 26, 2020
1 parent 8a01917 commit 5416a09
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stdlib/Dates/src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ end
(-)(x::Time, y::TimePeriod) = return Time(Nanosecond(value(x) - tons(y)))
(+)(y::Period, x::TimeType) = x + y

# Missing support
(+)(x::T, y::Missing) where {T<:AbstractTime} = missing
(+)(x::Missing, y::T) where {T<:AbstractTime} = missing
(-)(x::T, y::Missing) where {T<:AbstractTime} = missing
(-)(x::Missing, y::T) where {T<:AbstractTime} = missing

# AbstractArray{TimeType}, AbstractArray{TimeType}
(-)(x::OrdinalRange{T}, y::OrdinalRange{T}) where {T<:TimeType} = Vector(x) - Vector(y)
(-)(x::AbstractRange{T}, y::AbstractRange{T}) where {T<:TimeType} = Vector(x) - Vector(y)
Expand Down

0 comments on commit 5416a09

Please sign in to comment.