Talk:SetTimeWorkedAutomatically/@comment-BlaecHrim-20130513105807
Jump to navigation
Jump to search
This only counts business hours worked (you need perl module Date::Manip) :
use Date::Manip;
Date_Init("WorkDayBeg = 08:00", "WorkDayEnd = 16:00");
my $stringStart = $self->TicketObj->Started;
my $stringResolved = $self->TicketObj->Resolved;
my $parsedStart = &ParseDate($stringStart);
my $today_date = &ParseDate("$stringResolved");
my $err;
my $delta = DateCalc(ParseDate($parsedStart),$today_date,\$err,3);
$delta = Delta_Format($delta,2,'%st');
my $minutes = int( $delta / 60 );
my $hours = int( $delta / 3600 );
$RT::Logger->debug("Setting TimeWorked to: $minutes");
$self->TicketObj->SetTimeWorked( $minutes );