[rt-users] Issue with Time

Bryon Baker bbaker at copesan.com
Tue Apr 22 12:56:24 EDT 2014


I also noticed that my time is off the amount of the time zone.

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"

From: rt-users-bounces at lists.bestpractical.com [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Bryon Baker
Sent: Tuesday, April 22, 2014 11:14 AM
To: RT Users (rt-users at lists.bestpractical.com)
Subject: [rt-users] Issue with Time

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/26ef5099/attachment.htm>


More information about the rt-users mailing list