[rt-users] Business::Hours script not returning correct time

Martin Dorschler mdorschler at tuscom.com
Mon Aug 17 09:16:35 EDT 2009


The following code using perl module Business::Hours should return 4 business hours from the date specified in $curtime and update the due date.
For some reason it does that minus the minutes left in the current hour, for example
Ticket created Sun Aug 16 16:17:30 2009 is set due at Mon Aug 17 11:17:30 2009 instead of Mon Aug 17 12:00:00 2009
I have been over the code, faq module docs etc. and cannot spot the error. Has anyone else encountered this?

my $duedate = RT::Date->new($RT::SystemUser);
my $hoursuntildue = 4;
use Business::Hours;
my $hours = Business::Hours->new();

    $hours->business_hours(

        0 => { Name     => 'Monday',
               Start    => '08:00',
               End      => '17:00' },
        1 => { Name     => 'Tuesday',
               Start    => '08:00',
               End      => '17:00' },
        2 => { Name     => 'Wednesday',
               Start    => '08:00',
               End      => '17:00' },
        3 => { Name     => 'Thursday',
               Start    => '08:00',
               End      => '17:00' },
        4 => { Name     => 'Friday',
               Start    => '08:00',
               End      => '17:00' },

        holidays => [qw(01-01 12-25 07-04)],
    );

my $curtime = time;
my $bus_hours_duetime = $hours->add_seconds ($curtime, ($hoursuntildue*60*60));
$duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
$self->TicketObj->SetDue($duedate->ISO);
return(1);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090817/b2c33056/attachment.htm>


More information about the rt-users mailing list