2014-01-14 05:52:21 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => 'workdays_between';
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[
|
|
|
|
'DDG::Goodie::WorkdaysBetween'
|
|
|
|
],
|
|
|
|
|
|
|
|
# Standard work week
|
|
|
|
'workdays between 01/06/2014 01/10/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/10/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
'workdays between 01/06/2014 01/10/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/10/2014, inclusive.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
|
2014-01-14 14:59:16 -08:00
|
|
|
# Ending date first
|
|
|
|
'workdays between 01/10/2014 01/06/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/10/2014.'),
|
2014-01-14 14:59:16 -08:00
|
|
|
'workdays between 01/10/2014 01/06/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/10/2014, inclusive.'),
|
2014-01-14 14:59:16 -08:00
|
|
|
|
2014-01-14 05:52:21 -08:00
|
|
|
# Ending date on a weekend
|
|
|
|
'workdays between 01/06/2014 01/12/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/12/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
'workdays between 01/06/2014 01/12/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/12/2014, inclusive.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
|
|
|
|
# Including the weekend
|
|
|
|
'workdays between 01/06/2014 01/13/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/13/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
'workdays between 01/06/2014 01/13/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 6 workdays between 1/6/2014 and 1/13/2014, inclusive.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
|
2014-01-14 14:59:16 -08:00
|
|
|
# Including the weekend -- Backwards
|
|
|
|
'workdays between 01/13/2014 01/06/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/13/2014.'),
|
2014-01-14 14:59:16 -08:00
|
|
|
'workdays between 01/13/2014 01/06/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 6 workdays between 1/6/2014 and 1/13/2014, inclusive.'),
|
2014-01-14 14:59:16 -08:00
|
|
|
|
2014-01-14 05:52:21 -08:00
|
|
|
# Starting on a Saturday
|
|
|
|
'workdays between 01/11/2014 01/14/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 2 workdays between 1/11/2014 and 1/14/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
'workdays between 01/11/2014 01/14/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 2 workdays between 1/11/2014 and 1/14/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
|
|
|
|
# Starting on a Sunday
|
|
|
|
'workdays between 01/12/2014 01/14/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 2 workdays between 1/12/2014 and 1/14/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
'workdays between 01/12/2014 01/14/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 2 workdays between 1/12/2014 and 1/14/2014.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
|
|
|
|
# Workdays in a year
|
|
|
|
'workdays between 01/01/2014 01/01/2015' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 261 workdays between 1/1/2014 and 1/1/2015.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
'workdays between 01/01/2014 01/01/2015 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 262 workdays between 1/1/2014 and 1/1/2015, inclusive.'),
|
2014-01-14 05:52:21 -08:00
|
|
|
|
2014-01-15 12:58:05 -08:00
|
|
|
# Business Days
|
|
|
|
'business days between 01/06/2014 01/10/2014' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/10/2014.'),
|
2014-01-15 12:58:05 -08:00
|
|
|
'business days between 01/06/2014 01/10/2014 inclusive' =>
|
2014-01-15 13:59:49 -08:00
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/10/2014, inclusive.'),
|
2014-01-15 12:58:05 -08:00
|
|
|
|
2014-01-15 14:15:44 -08:00
|
|
|
# Month and Date are backwards
|
|
|
|
'workdays between 16/06/2014 20/06/2014' =>
|
|
|
|
test_zci('There are 4 workdays between 6/16/2014 and 6/20/2014.'),
|
|
|
|
|
2014-01-15 14:40:42 -08:00
|
|
|
# Single digit days and months
|
|
|
|
'workdays between 1/6/2014 1/10/20146' =>
|
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/10/2014.'),
|
|
|
|
'workdays between 1/6/2014 1/10/2014 inclusive' =>
|
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/10/2014, inclusive.'),
|
|
|
|
|
2014-01-15 14:36:01 -08:00
|
|
|
# Unambiguous date format
|
|
|
|
'workdays between jan 6 2014 jan 10 2014' =>
|
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/10/2014.'),
|
|
|
|
'workdays between jan 6 2014 jan 10 2014 inclusive' =>
|
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/10/2014, inclusive.'),
|
|
|
|
|
2014-01-15 14:38:36 -08:00
|
|
|
# Unambiguous date format with comma separator
|
|
|
|
'workdays between jan 6, 2014 jan 10, 2014' =>
|
|
|
|
test_zci('There are 4 workdays between 1/6/2014 and 1/10/2014.'),
|
|
|
|
'workdays between jan 6, 2014 jan 10, 2014 inclusive' =>
|
|
|
|
test_zci('There are 5 workdays between 1/6/2014 and 1/10/2014, inclusive.'),
|
|
|
|
|
2014-01-14 05:52:21 -08:00
|
|
|
# Invalid input
|
|
|
|
'workdays between 01/2014 01/2015' => undef,
|
|
|
|
'workdays between 01/2014/01' => undef,
|
|
|
|
'workdays between 01/01/2014 inclusive' => undef,
|
2014-01-15 14:15:44 -08:00
|
|
|
'workdays between 01/01/2014' => undef,
|
|
|
|
'workdays between 20/01/2014 inclusive' => undef,
|
2014-01-15 14:17:24 -08:00
|
|
|
'workdays between 19/19/2014 20/24/2015' => undef,
|
|
|
|
'workdays between 19/19/2014 20/24/2015 inclusive' => undef,
|
2014-01-14 05:52:21 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|