Date::Manip hours elapsed not business hours elapsed

R

rutherf

Hello
Why does this print 49Hs and not 17Hrs as *I* expected???
Ive tryed bus mode 2 and 3 in DateCalc and other things but it always
gives me elapsed hrs not elapsed bus hrs
any help appreciated!


==========================================
use Date::Manip;

Date_Init("TZ=GMT","WorkWeekBeg=1","WorkWeekEnd=5","WorkDay24Hr=0","WorkDayBeg=09:00","WorkDayEnd=17:00");
$start = 'Oct 03 2006 09:34:28';
$end = 'Oct 05 2006 10:34:28';

$date1=ParseDate($start);
$date2=ParseDate($end);

$delta=DateCalc($date1,$date2,,2);
$bus_hrs=Delta_Format($delta,2,,"%ht");

print $bus_hrs;
====================================================
 
B

Bob Walton

rutherf said:
Hello
Why does this print 49Hs and not 17Hrs as *I* expected???
Ive tryed bus mode 2 and 3 in DateCalc and other things but it always
gives me elapsed hrs not elapsed bus hrs
any help appreciated!


==========================================
use Date::Manip;

Date_Init("TZ=GMT","WorkWeekBeg=1","WorkWeekEnd=5","WorkDay24Hr=0","WorkDayBeg=09:00","WorkDayEnd=17:00");
$start = 'Oct 03 2006 09:34:28';
$end = 'Oct 05 2006 10:34:28';

$date1=ParseDate($start);
$date2=ParseDate($end);

$delta=DateCalc($date1,$date2,,2);
$bus_hrs=Delta_Format($delta,2,,"%ht");

print $bus_hrs;
====================================================
I think the confusion is in assuming that the second argument ($mode) to
Delta_Format is the same as the fourth argument (also described as
$mode) to DateCalc. This is not the case -- for Delta_Format, the
second argument is either "exact" or "approx", as is hinted at in the
documentation and may be seen by examining the Date::Manip source code.
If you print out $delta directly, you will see that DateCalc computed
2 days and 1 hour, which would be correct for "business mode" with the
parameters you supplied. Delta_Format, however, knows nothing about
"business mode", and assumes the two days are 48 hours.
 
R

rutherf

DOH...Thanks that makes sence!

Bob said:
I think the confusion is in assuming that the second argument ($mode) to
Delta_Format is the same as the fourth argument (also described as
$mode) to DateCalc. This is not the case -- for Delta_Format, the
second argument is either "exact" or "approx", as is hinted at in the
documentation and may be seen by examining the Date::Manip source code.
If you print out $delta directly, you will see that DateCalc computed
2 days and 1 hour, which would be correct for "business mode" with the
parameters you supplied. Delta_Format, however, knows nothing about
"business mode", and assumes the two days are 48 hours.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top