Skip to content
Permalink
Browse files

Make sure $!daycount is nulled on subclasses of DateTime

Essentially the same fix as 9295616 was for Date.  Spotted
by AlexDaniel++ / Blin++.  Fixes R#2615 (again)
  • Loading branch information...
lizmat committed Jan 24, 2019
1 parent 21ae9f3 commit 3488a65ed7929fbabc375d2103f25050086b1c5f
Showing with 11 additions and 7 deletions.
  1. +0 −4 src/core/Date.pm6
  2. +5 −3 src/core/DateTime.pm6
  3. +6 −0 src/core/Dateish.pm6
@@ -35,10 +35,6 @@ my class Date does Dateish {
nqp::isconcrete($daycount) ?? $daycount !! nqp::null);
self
}
method !SET-DAYCOUNT() {
nqp::bind($!daycount,nqp::null) unless nqp::isconcrete($!daycount);
self
}

proto method new(|) {*}
multi method new(Date:
@@ -104,7 +104,8 @@ my class DateTime does Dateish {
$year,$month,$day,$hour,$minute,$second,$timezone,&formatter)
!! self.bless(
:$year,:$month,:$day,
:$hour,:$minute,:$second,:$timezone,:&formatter,|%extra);
:$hour,:$minute,:$second,:$timezone,:&formatter,|%extra
)!SET-DAYCOUNT;

$second >= 60 ?? $dt!check-leap-second !! $dt
}
@@ -191,8 +192,9 @@ my class DateTime does Dateish {
!! nqp::create(self)!SET-SELF(
$year,$month,$day,$hour,$minute,$second,0,&formatter)
) !! self.bless(
:$year,:$month,:$day,
:$hour,:$minute,:$second,:timezone(0),:&formatter,|%_);
:$year,:$month,:$day,
:$hour,:$minute,:$second,:timezone(0),:&formatter,|%_
)!SET-DAYCOUNT;
$timezone ?? $dt.in-timezone($timezone) !! $dt
}
multi method new(DateTime:
@@ -31,6 +31,12 @@ my role Dateish {
sprintf 0 <= $!year <= 9999 ?? '%04d' !! '%+05d', $!year;
}

# make sure $!daycount is nulled for subclasses
method !SET-DAYCOUNT() {
nqp::bind($!daycount,nqp::null) unless nqp::isconcrete($!daycount);
self
}

multi method new(Dateish:) {
Failure.new(
"Cannot call {self.^name}.new with "

0 comments on commit 3488a65

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