[rt-users] Issue with Time
Bryon Baker
bbaker at copesan.com
Tue Apr 22 12:13:51 EDT 2014
Hello all I need to know two things
1 What am I doing wrong with the code below as you can see I need to add a 1 to the month to get the correct month.
2 is there a more efficient way to manipulate dates in Request Tracker?
Other than these question the code is working.
The code
my $self = shift;
my $ticket = $self->TicketObj;
my $datecreated = $ticket->CreatedObj->Unix;
my $dateupdated = $ticket->LastUpdatedObj->Unix;
my $datecreatedstr = $ticket->CreatedObj->AsString;
my $dateupdatedstr = $ticket->LastUpdatedObj->AsString;
my $dateresolved;
my $dateresolvedstr;
my $transactions = $ticket->Transactions;
$transactions->Limit( FIELD => 'Type', VALUE => 'Status', FIELD => 'NewValue', VALUE => 'closed');
while (my $transaction = $transactions->Next)
{
$dateresolved = $transaction->CreatedObj->Unix;
$dateresolvedstr = $transaction->CreatedObj->AsString;
}
print $datecreated," ",$dateupdated," ",$dateresolved, $dateresolvedstr,"\n";
my ($sec, $min, $hour, $day,$month,$year) = (localtime($dateresolved))[0,1,2,3,4,5];
$dateresolvedstr = ($year+1900)."-".($month+1)."-".$day." ".$hour.":".$min.":".$sec;
print $dateresolvedstr,"\n";
$ticket->SetResolved($dateresolvedstr);
print $datecreatedstr," b ",$dateupdatedstr," ",$year+1900,"-09-",$day," ",$hour,":",$min,":",$sec,"\n";
my $timeworked = ($dateresolved - $datecreated)/60 ;
print $timeworked, "\n";
$ticket->SetTimeWorked($timeworked);
return 1;
Thanks for the help
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 * 262-783-6261 ext. 2296
bbaker at copesan.com<mailto:cstephan at copesan.com>
www.copesan.com<http://www.copesan.com/>
"Servicing North America with Local Care"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140422/ef68e02b/attachment.htm>
More information about the rt-users
mailing list