Skip to content

Commit

Permalink
clean-up mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Mar 11, 2024
1 parent c178ca2 commit 3889b2d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/period.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ function ==(p1::Period{T,Tfactor,Texponent},p2::Period{T,Tfactor,Texponent}) whe
return p1.duration == p2.duration
end

for op in (:+,:-)
for op in (:+,:-,:mod)
@eval begin
function $op(p1::Period{T,Tfactor,Texponent},p2::Period{T,Tfactor,Texponent}) where {T, Tfactor, Texponent}
Period{T,Tfactor,Texponent}($op(p1.duration,p2.duration))
end
end
end

for op in (:+,:-,:(==))
for op in (:+,:-,:mod,:(==))
@eval begin
$op(p1::Period,p2::Period) = $op(promote(p1,p2)...)
$op(p1::Period,p2::Dates.Period) = $op(promote(p1,p2)...)
Expand Down Expand Up @@ -207,12 +207,6 @@ function isless(p1::Period,p2::Period)
return Dates.value(p1 - p2) < 0
end

function Base.mod(x::Period,y::Period)
x,y = promote(x,y)
T = typeof(x)
return T(mod(Dates.value(x),Dates.value(y)))
end

# Missing support
(==)(x::Period, y::Missing) = missing
(==)(x::Missing, y::Period) = missing

0 comments on commit 3889b2d

Please sign in to comment.