Course of Raku / Advanced / More about built-in types / Date and time / Exercises / Day of the week
Solution: Day of the week
Here is a possible solution to the task.
Code
my $date = Date.new(2027, 2, 14);
say $date.day-of-week >= 6;🦋 You can find the source code in the file day-of-week.raku.
Output
TrueComments
day-of-weeknumbers the days from1(Monday) to7(Sunday), so the two weekend days are exactly the numbers6and7.The test
>= 6isTruefor both Saturday and Sunday andFalsefor any weekday. The 14th of February 2027 is a Sunday (7), so the program printsTrue.