Skip to content
Permalink
Browse files

Fix Date diff calculation

Fixes R#2707.
  • Loading branch information...
lizmat committed Feb 19, 2019
1 parent f56e075 commit 91ca82752321e5eec73dc36a4897647379de6ee8
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/core/Date.pm6
@@ -221,17 +221,17 @@ my class Date does Dateish {
}

multi sub infix:<+>(Date:D $d, Int:D $x --> Date:D) {
nqp::eqaddr($d.WHAT,Date) && $d.day + $x <= 28
nqp::eqaddr($d.WHAT,Date) && 0 < $d.day + $x <= 28
?? $d.new-from-diff($x)
!! Date.new-from-daycount($d.daycount + $x)
}
multi sub infix:<+>(Int:D $x, Date:D $d --> Date:D) {
nqp::eqaddr($d.WHAT,Date) && $d.day + $x <= 28
nqp::eqaddr($d.WHAT,Date) && 0 < $d.day + $x <= 28
?? $d.new-from-diff($x)
!! Date.new-from-daycount($d.daycount + $x)
}
multi sub infix:<->(Date:D $d, Int:D $x --> Date:D) {
nqp::eqaddr($d.WHAT,Date) && $d.day - $x > 0
nqp::eqaddr($d.WHAT,Date) && 0 < $d.day - $x <= 28
?? $d.new-from-diff(-$x)
!! Date.new-from-daycount($d.daycount - $x)
}

0 comments on commit 91ca827

Please sign in to comment.
You can’t perform that action at this time.