Skip to content

Commit

Permalink
[core/Temporal] Fixed RT #77910 (DateTime attributes like .hour shoul…
Browse files Browse the repository at this point in the history
…d always be Ints).
  • Loading branch information
Kodi Arfer authored and Kodi Arfer committed Sep 18, 2010
1 parent a204ba8 commit 12088a8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/Temporal.pm
Expand Up @@ -91,15 +91,15 @@ class Dateish {
[+] $.day, map { self.days-in-month($.year, $^m) }, 1 ..^ $.month
}

method check-value($val is rw, $name, $range) {
$val = +$val;
method check-value($val is rw, $name, $range, :$allow-nonint) {
$val = $allow-nonint ?? +$val !! $val.Int;
$val ~~ $range or
or die "$name must be in {$range.perl}\n";
}

method check-date {
# Asserts the validity of and numifies $!year, $!month, and $!day.
$!year = +$!year;
$!year .= Int;
self.check-value($!month, 'month', 1 .. 12);
self.check-value($!day, "day of $!year/$!month",
1 .. self.days-in-month);
Expand Down Expand Up @@ -158,7 +158,7 @@ class DateTime is Dateish {
# Asserts the validity of and numifies $!hour, $!minute, and $!second.
self.check-value($!hour, 'hour', 0 ..^ 24);
self.check-value($!minute, 'minute', 0 ..^ 60);
self.check-value($!second, 'second', 0 ..^ 62);
self.check-value($!second, 'second', 0 ..^ 62, :allow-nonint);
if $!second >= 60 {
# Ensure this is an actual leap second.
self.second < 61
Expand Down

0 comments on commit 12088a8

Please sign in to comment.