Course of Raku / Advanced / More about built-in types / Date and time / Date arithmetic

Quiz — Adding months

What does the following program print?

say Date.new(2026, 1, 31).later(:months(1));
12026-02-28
02026-03-03
02026-02-31
02026-03-31

One month after 31 January would be “31 February”, which does not exist. later clamps the result to the last valid day of the target month, so it lands on 28 February 2026 (2026 is not a leap year, so February has 28 days).

Course navigation

Quiz — Date arithmetic   |   Working with time