Skip to content

Commit

Permalink
Use Int:D() instead of Int:D
Browse files Browse the repository at this point in the history
Fixes RT#127016: https://rt.perl.org/Public/Bug/Display.html?id=127016

This fix enables Date.new to accept these sequences as same as the previous behavior:

- Str:D sequence (e.g., Date.new('2018', '1', '4'))
- Sequence which contains Rat:D (e.g., Date.new(2017, 12/2, 3))
  • Loading branch information
titsuki committed Jan 5, 2018
1 parent fc2a3fd commit dfaa228
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/Date.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ my class Date does Dateish {
method !SET-SELF($!year,$!month,$!day,&!formatter,$!daycount = Int) { self }

proto method new(|) {*}
multi method new(Date: Int:D $year, Int:D $month, Int:D $day, :&formatter, *%_) {
multi method new(Date: Int:D() $year, Int:D() $month, Int:D() $day, :&formatter, *%_) {
(1..12).in-range($month,'Month');
(1 .. self.DAYS-IN-MONTH($year,$month)).in-range($day,'Day');
self === Date
?? nqp::create(self)!SET-SELF($year,$month,$day,&formatter)
!! self.bless(:$year,:$month,:$day,:&formatter,|%_)
}
multi method new(Date: Int:D :$year!, Int:D :$month = 1, Int:D :$day = 1, :&formatter, *%_) {
multi method new(Date: Int:D() :$year!, Int:D() :$month = 1, Int:D() :$day = 1, :&formatter, *%_) {
(1..12).in-range($month,'Month');
(1 .. self.DAYS-IN-MONTH($year,$month)).in-range($day,'Day');
self === Date
Expand Down

0 comments on commit dfaa228

Please sign in to comment.