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

True

Comments

  1. day-of-week numbers the days from 1 (Monday) to 7 (Sunday), so the two weekend days are exactly the numbers 6 and 7.

  2. The test >= 6 is True for both Saturday and Sunday and False for any weekday. The 14th of February 2027 is a Sunday (7), so the program prints True.

Course navigation

Day of the week   |   Sets, bags, and mixes