<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">I also noticed that my time is off the amount of the time zone.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Bryon Baker<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Network Operations Manager<o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">Copesan</span></i></b><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"> - Specialists in Pest Solutions<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">800-267-3726 • 262-783-6261 ext. 2296<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><a href="mailto:cstephan@copesan.com">bbaker@copesan.com</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"><a href="http://www.copesan.com/"><span style="color:black">www.copesan.com</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">"Servicing North America with Local Care"</span></i></b><span style="color:#1F497D"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com]
<b>On Behalf Of </b>Bryon Baker<br>
<b>Sent:</b> Tuesday, April 22, 2014 11:14 AM<br>
<b>To:</b> RT Users (rt-users@lists.bestpractical.com)<br>
<b>Subject:</b> [rt-users] Issue with Time<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hello all I need to know two things <o:p></o:p></p>
<p class="MsoNormal"> 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.<o:p></o:p></p>
<p class="MsoNormal"> 2 is there a more efficient way to manipulate dates in Request Tracker?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Other than these question the code is working.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The code<o:p></o:p></p>
<p class="MsoNormal"> my $self = shift;<o:p></o:p></p>
<p class="MsoNormal"> my $ticket = $self->TicketObj;<o:p></o:p></p>
<p class="MsoNormal"> my $datecreated = $ticket->CreatedObj->Unix;<o:p></o:p></p>
<p class="MsoNormal"> my $dateupdated = $ticket->LastUpdatedObj->Unix;<o:p></o:p></p>
<p class="MsoNormal"> my $datecreatedstr = $ticket->CreatedObj->AsString;<o:p></o:p></p>
<p class="MsoNormal"> my $dateupdatedstr = $ticket->LastUpdatedObj->AsString;<o:p></o:p></p>
<p class="MsoNormal"> my $dateresolved;<o:p></o:p></p>
<p class="MsoNormal"> my $dateresolvedstr;<o:p></o:p></p>
<p class="MsoNormal"> my $transactions = $ticket->Transactions;<o:p></o:p></p>
<p class="MsoNormal"> $transactions->Limit( FIELD => 'Type', VALUE => 'Status', FIELD => 'NewValue', VALUE => 'closed');<o:p></o:p></p>
<p class="MsoNormal"> while (my $transaction = $transactions->Next) <o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> $dateresolved = $transaction->CreatedObj->Unix;<o:p></o:p></p>
<p class="MsoNormal"> $dateresolvedstr = $transaction->CreatedObj->AsString;<o:p></o:p></p>
<p class="MsoNormal"> } <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">print $datecreated," ",$dateupdated," ",$dateresolved, $dateresolvedstr,"\n";<o:p></o:p></p>
<p class="MsoNormal"> my ($sec, $min, $hour, $day,$month,$year) = (localtime($dateresolved))[0,1,2,3,4,5];
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> $dateresolvedstr = ($year+1900)."-".($month+1)."-".$day." ".$hour.":".$min.":".$sec;<o:p></o:p></p>
<p class="MsoNormal">print $dateresolvedstr,"\n";<o:p></o:p></p>
<p class="MsoNormal"> $ticket->SetResolved($dateresolvedstr);<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">print $datecreatedstr," b ",$dateupdatedstr," ",$year+1900,"-09-",$day," ",$hour,":",$min,":",$sec,"\n";<o:p></o:p></p>
<p class="MsoNormal"> my $timeworked = ($dateresolved - $datecreated)/60 ;<o:p></o:p></p>
<p class="MsoNormal">print $timeworked, "\n";<o:p></o:p></p>
<p class="MsoNormal"> $ticket->SetTimeWorked($timeworked);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> return 1;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for the help<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Bryon Baker<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Network Operations Manager<o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">Copesan</span></i></b><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"> - Specialists in Pest Solutions<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">800-267-3726 • 262-783-6261 ext. 2296<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><a href="mailto:cstephan@copesan.com">bbaker@copesan.com</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"><a href="http://www.copesan.com/"><span style="color:black">www.copesan.com</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">"Servicing North America with Local Care"</span></i></b><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>