From 6d8373830d804b55d532589ed4f356038769409d Mon Sep 17 00:00:00 2001 From: James Raspass Date: Sun, 3 Oct 2021 05:06:32 +0100 Subject: 132: Mirror Dates in Raku by James Raspass $ raku challenge-132/james-raspass/raku/ch-1.raku 2021-09-18 2021-09-22 On the date you were born, someone who was your current age, would have been born on 2021-09-14. Someone born today will be your current age on 2021-09-26. Uses a slightly different date format but shows off coercion beautifully, the errors are very readable for other date formats: $ raku challenge-132/james-raspass/raku/ch-1.raku 2021/09/18 Invalid Date string '2021/09/18'; use yyyy-mm-dd instead --- challenge-132/james-raspass/README | 1 + challenge-132/james-raspass/raku/ch-1.raku | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 challenge-132/james-raspass/README create mode 100644 challenge-132/james-raspass/raku/ch-1.raku diff --git a/challenge-132/james-raspass/README b/challenge-132/james-raspass/README new file mode 100644 index 0000000000..e8b9d803c6 --- /dev/null +++ b/challenge-132/james-raspass/README @@ -0,0 +1 @@ +Solution by James Raspass. diff --git a/challenge-132/james-raspass/raku/ch-1.raku b/challenge-132/james-raspass/raku/ch-1.raku new file mode 100644 index 0000000000..6dc41fb5b8 --- /dev/null +++ b/challenge-132/james-raspass/raku/ch-1.raku @@ -0,0 +1,8 @@ +unit sub MAIN(Date() $birthday, Date() $today = Date.today); + +my $age = $today - $birthday; + +printf q:to/END/, $birthday - $age, $today + $age; + On the date you were born, someone who was your current age, would have been born on %s. + Someone born today will be your current age on %s. + END -- cgit