diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-06-16 16:04:21 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-09-02 14:56:41 +0100 |
commit | 32c80504c0f4aad36f7d9eaef5ff3f2f6d851b77 (patch) | |
tree | 2b13714b6419d58ee9025e831fbc02f657e4cfc8 /t/workingdays.t | |
parent | 764a6b7f8056d55aeba4656cba279b27a60d6b1a (diff) |
[Zurich] Factor out working days calculator.
Diffstat (limited to 't/workingdays.t')
-rw-r--r-- | t/workingdays.t | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/t/workingdays.t b/t/workingdays.t new file mode 100644 index 000000000..326cf05c9 --- /dev/null +++ b/t/workingdays.t @@ -0,0 +1,21 @@ +use Test::More; +use DateTime; + +use_ok 'FixMyStreet::WorkingDays'; + + +my $wd = FixMyStreet::WorkingDays->new( + public_holidays => [ + '2020-09-21', + '2020-09-15', + ], +); + +my $dt = DateTime->new(year => 2020, month => 9, day => 19); + +is $wd->add_days($dt, 1)->ymd, '2020-09-22'; +is $wd->sub_days($dt, 5)->ymd, '2020-09-11'; +is $wd->is_public_holiday($dt), undef; +is $wd->is_weekend($dt), 1; + +done_testing; |