Skip to content

Commit

Permalink
Disallow :U values in DateTime.new
Browse files Browse the repository at this point in the history
Merge pull request #1363 from titsuki/fix-date-new
Fixes RT#127016: https://rt.perl.org/Ticket/Display.html?id=127016
  • Loading branch information
zoffixznet committed Jan 5, 2018
2 parents 36d71a3 + 867d5ed commit 038b1ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/Date.pm
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() $year, Int() $month, Int() $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() :$year!, Int() :$month = 1, Int() :$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 038b1ea

Please sign in to comment.