Skip to content
Permalink
Browse files

Date: ensure formatter carries on through succ&pred

and + and - and potentially other things

scimon++ for finding this
  • Loading branch information...
timo committed Jun 17, 2019
1 parent 6f8442a commit 34c0e892ca9649b9b6f9b3c1d1c8fc3cd477c195
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/core/Date.pm6
@@ -90,7 +90,7 @@ my class Date does Dateish {
multi method new(Date: Instant $i, :&formatter, *%_ --> Date:D) {
self.new(DateTime.new($i),:&formatter,|%_)
}
method new-from-daycount($daycount,:&formatter --> Date:D) {
method new-from-daycount($daycount,:&formatter = &!formatter --> Date:D) {
self!ymd-from-daycount($daycount, my $year, my $month, my $day);
nqp::eqaddr(self.WHAT,Date)
?? nqp::create(self)!SET-SELF($year,$month,$day,&formatter,$daycount)
@@ -222,17 +222,17 @@ my class Date does Dateish {
multi sub infix:<+>(Date:D $d, Int:D $x --> Date:D) {
nqp::eqaddr($d.WHAT,Date) && 0 < $d.day + $x <= 28
?? $d.new-from-diff($x)
!! Date.new-from-daycount($d.daycount + $x)
!! Date.new-from-daycount($d.daycount + $x, formatter => $d.formatter)
}
multi sub infix:<+>(Int:D $x, Date:D $d --> Date:D) {
nqp::eqaddr($d.WHAT,Date) && 0 < $d.day + $x <= 28
?? $d.new-from-diff($x)
!! Date.new-from-daycount($d.daycount + $x)
!! Date.new-from-daycount($d.daycount + $x, formatter => $d.formatter)
}
multi sub infix:<->(Date:D $d, Int:D $x --> Date:D) {
nqp::eqaddr($d.WHAT,Date) && 0 < $d.day - $x <= 28
?? $d.new-from-diff(-$x)
!! Date.new-from-daycount($d.daycount - $x)
!! Date.new-from-daycount($d.daycount - $x, formatter => $d.formatter)
}
multi sub infix:<->(Date:D $a, Date:D $b --> Int:D) {
$a.daycount - $b.daycount;

0 comments on commit 34c0e89

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