Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Date::Manip hours elapsed not business hours elapsed

Reply
Thread Tools

Date::Manip hours elapsed not business hours elapsed

 
 
rutherf
Guest
Posts: n/a
 
      10-27-2006
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;
================================================== ==

 
Reply With Quote
 
 
 
 
Bob Walton
Guest
Posts: n/a
 
      10-28-2006
rutherf wrote:
> 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.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
 
Reply With Quote
 
 
 
 
rutherf
Guest
Posts: n/a
 
      10-28-2006
DOH...Thanks that makes sence!

Bob Walton wrote:
> rutherf wrote:
> > 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.
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Business hours processing Sławosz Sławiński Ruby 4 08-03-2010 03:10 PM
Recorded 2 hours, deleted 2 hours, no space left? Tony Tee DVD Video 5 07-25-2007 10:20 AM
Calculating Business Hours Left Phrogz Ruby 2 04-06-2007 02:24 PM
1700 series: S0 is up 2 hours, down 2 hours, up, down, arghgh! Ivan Cisco 11 10-14-2004 08:41 AM
Hi im going to make a "time counter" from hours to hours and a loggfile export system Rahmi Acar C++ 0 07-17-2003 08:28 PM



Advertisments