diff options
| -rw-r--r-- | challenge-259/mark-anderson/raku/ch-1.raku | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-259/mark-anderson/raku/ch-1.raku b/challenge-259/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..26c0180e8e --- /dev/null +++ b/challenge-259/mark-anderson/raku/ch-1.raku @@ -0,0 +1,25 @@ +#!/usr/bin/env raku +use Test; + +is banking-day-offset('2018-06-28', 3), '2018-07-03'; +is banking-day-offset('2018-06-28', 3, ['2018-07-03']), '2018-07-04'; +is banking-day-offset('2018-06-30', 0), '2018-07-02'; +is banking-day-offset('2018-06-30', 8, ['2018-07-04', '2018-07-03']), '2018-07-16'; +is banking-day-offset('2018-07-02', 0), '2018-07-02'; +is banking-day-offset('2018-07-16', 4), '2018-07-20'; + +sub banking-day-offset($date is copy, $offset is copy, @holidays=[]) +{ + $date .= Date; + + loop + { + given $date++ + { + if all(.day-of-week ~~ 1..5, .yyyy-mm-dd !(elem) @holidays) + { + return .yyyy-mm-dd unless $offset-- + } + } + } +} |
