Course of Raku / Advanced / More about built-in types / Date and time / Exercises / One week later
Solution: One week later
Here is a possible solution to the task.
Code
my $later = Date.new(2027, 2, 28).later(:days(7));
say $later;
say $later.day-of-week;🦋 You can find the source code in the file one-week-later.raku.
Output
2027-03-07
7Comments
later(:days(7))moves the date forward by seven days — one week. We could also have written+ 7, but the named argument states the unit explicitly.February 2027 has 28 days, so a week after the 28th rolls over into March automatically: the result is
2027-03-07.Calling
day-of-weekon the new date gives7. This makes the result easy to check: a date exactly one week later must fall on the same weekday as the original, and2027-02-28is a Sunday (7) too — so a7here is the answer you expect.