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);

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [email protected]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to