Skip to content

Commit

Permalink
DateTime!new-from-positional doesn't need named parameters
Browse files Browse the repository at this point in the history
It's fully internal, so we're in complete control, so we don't need
the overhead of named parameters.
  • Loading branch information
lizmat committed Feb 7, 2020
1 parent 495ddcc commit 076ef98
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/core.c/DateTime.pm6
Expand Up @@ -80,9 +80,9 @@ my class DateTime does Dateish {
Int() $hour,
Int() $minute,
$second, # can have fractional seconds
Int() $timezone,
&formatter,
%extra,
:$timezone = 0,
:&formatter,
--> DateTime:D) {
1 <= $month <= 12
|| X::OutOfRange.new(:what<Month>,:got($month),:range<1..12>).throw;
Expand Down Expand Up @@ -133,7 +133,7 @@ my class DateTime does Dateish {
multi method new(DateTime:
\y,\mo,\d,\h,\mi,\s,:$timezone = 0,:&formatter,*%_
--> DateTime:D) {
self!new-from-positional(y,mo,d,h,mi,s,%_,:$timezone,:&formatter)
self!new-from-positional(y,mo,d,h,mi,s,$timezone,&formatter,%_)
}
multi method new(DateTime:
:$year!,
Expand All @@ -147,7 +147,7 @@ my class DateTime does Dateish {
*%_
--> DateTime:D) {
self!new-from-positional(
$year,$month,$day,$hour,$minute,$second,%_,:$timezone,:&formatter)
$year,$month,$day,$hour,$minute,$second,$timezone,&formatter,%_)
}
multi method new(DateTime:
Date:D :$date!, *%_
Expand Down Expand Up @@ -245,7 +245,7 @@ my class DateTime does Dateish {
$timezone //= 0;

self!new-from-positional(
$0,$1,$2,$3,$4,+(~$5.subst(",",".")),%_,:$timezone,:&formatter)
$0,$1,$2,$3,$4,+(~$5.subst(",",".")),$timezone,&formatter,%_)
}

method now(:$timezone=$*TZ, :&formatter --> DateTime:D) {
Expand All @@ -255,15 +255,15 @@ my class DateTime does Dateish {
method clone(DateTime:D: *%_ --> DateTime:D) {
my \h := nqp::getattr(%_,Map,'$!storage');
self!new-from-positional(
nqp::ifnull(nqp::atkey(h,'year'), $!year),
nqp::ifnull(nqp::atkey(h,'month'), $!month),
nqp::ifnull(nqp::atkey(h,'day'), $!day),
nqp::ifnull(nqp::atkey(h,'hour'), $!hour),
nqp::ifnull(nqp::atkey(h,'minute'),$!minute),
nqp::ifnull(nqp::atkey(h,'second'),$!second),
nqp::ifnull(nqp::atkey(h,'year'), $!year),
nqp::ifnull(nqp::atkey(h,'month'), $!month),
nqp::ifnull(nqp::atkey(h,'day'), $!day),
nqp::ifnull(nqp::atkey(h,'hour'), $!hour),
nqp::ifnull(nqp::atkey(h,'minute'), $!minute),
nqp::ifnull(nqp::atkey(h,'second'), $!second),
nqp::ifnull(nqp::atkey(h,'timezone'), $!timezone),
nqp::ifnull(nqp::atkey(h,'formatter'),&!formatter),
%_,
timezone => nqp::ifnull(nqp::atkey(h,'timezone'),$!timezone),
formatter => nqp::ifnull(nqp::atkey(h,'formatter'),&!formatter),
)
}

Expand Down

0 comments on commit 076ef98

Please sign in to comment.