Created
October 5, 2022 11:00
-
-
Save gfldex/b1a3eb9f870cb7c6af384763f2fa2a80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multi sub MAIN(Bool :$S, Bool :$three) { | |
constant @months = <January February March April May June July August September October November December>; | |
my @week-days = $S ?? <Su Mo Tu We Th Fr Sa> !! <Mo Tu We Th Fr Sa Su>; | |
my &start-week-day = $S ?? { .[0].day-of-week % 7 } !! { .[0].day-of-week - 1 } | |
my $month-offset = $three ?? -1 !! 0; | |
loop { | |
$_ = now.Date.truncated-to('month'); | |
$_ = .earlier(:month(1)) if $three; | |
$_ = .later(:month($++)) if $three; | |
my $heading = @months[.month - 1] ~ ' ' ~ .year; | |
put ' ' x 10 - $heading.chars / 2, $heading; | |
$_ = $_ ..^ .later(:1months); | |
.put for (|@week-days, |(' ' xx .&start-week-day), |$_».day».fmt('%.2d')).rotor(7, :partial); | |
put '' if $three; | |
last if ++$ ≥ 3 || !$three; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment