Skip to content
Permalink
Browse files

Make IS-LEAP-YEAR calculation ab out 2x as fast

By using a native int for year: I doubt we can reliably state whether a year
is a leap year by the time we run out of int precision.
  • Loading branch information...
lizmat committed Dec 31, 2018
1 parent 588037f commit 467394b8e3e392f973bda14b63de9756427f239b
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/core/Dateish.pm6
@@ -10,7 +10,7 @@ my role Dateish {
}

# this sub is also used by DAYS-IN-MONTH, which is used by other types
sub IS-LEAP-YEAR($y) {
sub IS-LEAP-YEAR(int $y --> Bool:D) {
$y %% 4 and not $y %% 100 or $y %% 400
}
method is-leap-year(Dateish:D: --> Bool:D) { IS-LEAP-YEAR($!year) }

0 comments on commit 467394b

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