Skip to content

Commit

Permalink
Revert "Revert "Introduce Dateish.days-in-year method" (#5085)"
Browse files Browse the repository at this point in the history
This reverts commit 4d43bbf.
  • Loading branch information
lizmat committed Oct 18, 2022
1 parent 4d43bbf commit 7e188a2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core.c/Dateish.pm6
Expand Up @@ -23,10 +23,23 @@ my role Dateish {
nqp::atpos_i($days-in-month,$month) ||
($month == 2 ?? 28 + IS-LEAP-YEAR($year) !! Nil );
}
method days-in-month(Dateish:D: --> Int:D) {

proto method days-in-month(|) {*}
multi method days-in-month(Dateish: Int:D $year, Int:D $month --> Int:D) {
self!DAYS-IN-MONTH($year,$month)
}
multi method days-in-month(Dateish:D: --> Int:D) {
self!DAYS-IN-MONTH($!year,$!month)
}

proto method days-in-year(|) {*}
multi method days-in-year(Dateish: Int:D $year --> Int:D) {
365 + IS-LEAP-YEAR($year)
}
multi method days-in-year(Dateish:D: --> Int:D) {
365 + IS-LEAP-YEAR($!year)
}

method !year-Str(--> Str:D) {
sprintf 0 <= $!year <= 9999 ?? '%04d' !! '%+05d', $!year;
}
Expand Down

0 comments on commit 7e188a2

Please sign in to comment.