diff options
| author | James Raspass <jraspass@gmail.com> | 2021-10-03 05:06:32 +0100 |
|---|---|---|
| committer | James Raspass <jraspass@gmail.com> | 2021-10-03 05:11:59 +0100 |
| commit | 6d8373830d804b55d532589ed4f356038769409d (patch) | |
| tree | d8bb8e06c5cc30684337171a6db6796d8b39baa5 | |
| parent | 0074f00a8ca3a208cf200029fef3b0443ba35e1c (diff) | |
| download | perlweeklychallenge-club-6d8373830d804b55d532589ed4f356038769409d.tar.gz perlweeklychallenge-club-6d8373830d804b55d532589ed4f356038769409d.tar.bz2 perlweeklychallenge-club-6d8373830d804b55d532589ed4f356038769409d.zip | |
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
| -rw-r--r-- | challenge-132/james-raspass/README | 1 | ||||
| -rw-r--r-- | challenge-132/james-raspass/raku/ch-1.raku | 8 |
2 files changed, 9 insertions, 0 deletions
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 |
