to calculate the number of business hours between two dates. I am seeing some peculiar results that I can't find reference to in the
section of the docs. When I compare "today at 1PM" with "tomorrow at 10AM" in business mode, the result is 6 hours as I was expecting. However, when I compare "today at 1PM" with "tomorrow at 1PM" in business mode, the result is 24 hours, not 9 hours as I was expecting. I am certain that
is parsing the dates correctly. It is just that
is not returning results as I expect.
Here are my effective
Date::Manip configuration options relating to business mode:
WorkWeekBeg=1
WorkWeekEnd=5
WorkDayBeg=08:00
WorkDayEnd=17:00
WorkDay24Hr=0
TomorrowFirst=1
Here is the code I am using for testing:
use Date::Manip;
use strict;
my $mode = 2; # 2 = business mode, 1 = normal mode
my $dateA = ParseDate("today at 1PM");
my $dateB = ParseDate("tomorrow at $ARGV[0]");
my $err;
my $difference = Delta_Format(DateCalc($dateA,$dateB,\$err,$mode),0,"%
+hh");
print "$difference hours.\n";
Running it this way:
perl busihours.pl 10:00 prints out:
6 hourswhile running this:
perl busihours.pl 13:00prints out:
24 hours.Can anyone explain the behavior?
Dave