aboutsummaryrefslogtreecommitdiffstats
path: root/t/workingdays.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-06-16 16:04:21 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-09-02 14:56:41 +0100
commit32c80504c0f4aad36f7d9eaef5ff3f2f6d851b77 (patch)
tree2b13714b6419d58ee9025e831fbc02f657e4cfc8 /t/workingdays.t
parent764a6b7f8056d55aeba4656cba279b27a60d6b1a (diff)
[Zurich] Factor out working days calculator.
Diffstat (limited to 't/workingdays.t')
-rw-r--r--t/workingdays.t21
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;