Problem with date

I am attempting use the following code to update the Resolved date in a ticket. Thanks for the help in advance.

package RT::Action::CSRUpdateResolvedTest;
use base ‘RT::Action’;
use strict;
use warnings;

sub Prepare
{
return 1;
}

sub Commit
{

            my %mon2num = qw(
                            jan 1  feb 2  mar 3  apr 4  may 5  jun 6
                            jul 7  aug 8  sep 9  oct 10 nov 11 dec 12
            );
            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 @dateresolvedstr;
my $transactions = $ticket->Transactions;
$transactions->Limit( FIELD => ‘Type’, VALUE => ‘Status’, FIELD => ‘NewValue’, VALUE => ‘closed’);
while (my $transaction = $transactions->Next)
{
$dateresolved = localtime($transaction->CreatedObj->Unix);
@dateresolvedstr = split(" ",$dateresolved);
$dateresolvedstr = $dateresolvedstr[4] . “-” . $mon2num{lc substr($dateresolvedstr[1], 0, 3)} . “-” . $dateresolvedstr[2] . " " . $dateresolvedstr[3];
}

            print $dateresolvedstr . " " . $dateresolved . "\n";
            $ticket->SetResolved($dateresolvedstr);

            return 1;

}

The dates printed to the console are correct but when I view the ticket the resolved date is different than the dates printed to the console by 6 hours. This seems to me to be the off set for the time zone. What do I need to add for Request Tracker to take the date as is?

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 * 262-783-6261 ext. 2296
bbaker@copesan.commailto:cstephan@copesan.com
www.copesan.comhttp://www.copesan.com/
“Servicing North America with Local Care”

Landon Thanks for the fast response

So if I understand you correctly then when I am update the Resolved date I need to subtract 6 hours making it UTC time and the store that value.

Is the procedure correct?

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 • 262-783-6261 ext. 2296
bbaker@copesan.commailto:cstephan@copesan.com
www.copesan.comhttp://www.copesan.com/
"Servicing North America with Local Care"From: Landon Stewart [mailto:lstewart@iweb.com]
Sent: Wednesday, November 19, 2014 4:07 PM
To: Bryon Baker
Cc: RT Users (rt-users@lists.bestpractical.com)
Subject: Re: [rt-users] Problem with date

The dates printed to the console are correct but when I view the ticket the resolved date is different than the dates printed to the console by 6 hours. This seems to me to be the off set for the time zone. What do I need to add for Request Tracker to take the date as is?

Hi Byron,

AFAIK RT provides it’s own offset when printing dates/times in the UI so one must store the date/time as UTC. What is printed on the console should actually be UTC. Date/Time entered by users or stored in any way need to be converted to UTC first.

More info:
http://bestpractical.com/docs/rt/latest/RT_Config.html#Date-and-time-handling

Landon Stewart : lstewart@iweb.commailto:lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

The dates printed to the console are correct but when I view the ticket the resolved date is different than the dates printed to the console by 6 hours. This seems to me to be the off set for the time zone. What do I need to add for Request Tracker to take the date as is?

Hi Byron,

AFAIK RT provides it’s own offset when printing dates/times in the UI so one must store the date/time as UTC. What is printed on the console should actually be UTC. Date/Time entered by users or stored in any way need to be converted to UTC first.

More info:
RT Config - RT 5.0.5 Documentation - Best Practical http://bestpractical.com/docs/rt/latest/RT_Config.html#Date-and-time-handling

Landon Stewart : lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

signature.asc (203 Bytes)

Hi,

as far as I understand you script you try to set the ticket resolved
date to the transaction date when the ticket status is set to closed.

If you have configured you RT correct this is done automatically by RT.

So what is your intent with this script?

ChrisAm 19.11.2014 um 20:18 schrieb Bryon Baker:

I am attempting use the following code to update the Resolved date in a
ticket. Thanks for the help in advance.

package RT::Action::CSRUpdateResolvedTest;

use base ‘RT::Action’;

use strict;

use warnings;

sub Prepare

{

            return 1;

}

sub Commit

{

            my %mon2num = qw(

                            jan 1  feb 2  mar 3  apr 4  may 5  jun 6

                            jul 7  aug 8  sep 9  oct 10 nov 11 dec 12

            );

            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 @dateresolvedstr;

            my $transactions = $ticket->Transactions;

            $transactions->Limit( FIELD => 'Type', VALUE =>

‘Status’, FIELD => ‘NewValue’, VALUE => ‘closed’);

            while (my $transaction = $transactions->Next)

            {

        $dateresolved = localtime($transaction->CreatedObj->Unix);

                       @dateresolvedstr = split(" ",$dateresolved);

                       $dateresolvedstr = $dateresolvedstr[4] . "-"

. $mon2num{lc substr($dateresolvedstr[1], 0, 3)} . “-” .
$dateresolvedstr[2] . " " . $dateresolvedstr[3];

             }



            print $dateresolvedstr . " " . $dateresolved . "\n";

            $ticket->SetResolved($dateresolvedstr);



            return 1;

}

The dates printed to the console are correct but when I view the ticket
the resolved date is different than the dates printed to the console by
6 hours. This seems to me to be the off set for the time zone. What do
I need to add for Request Tracker to take the date as is?

Thanks

Bryon Baker

Network Operations Manager

/Copesan/**/- Specialists in Pest Solutions/

800-267-3726 � 262-783-6261 ext. 2296

bbaker@copesan.com mailto:cstephan@copesan.com

www.copesan.com http://www.copesan.com/

/“Servicing North America with Local Care”/

Thanks for your response Christian.

So where it RT is that configuration?

This is why I developed the script to update the resolved date and timeworked. I have been trying to get this to work for months and I have completely missed the configuration you are talking about.

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 . 262-783-6261 ext. 2296
bbaker@copesan.com

"Servicing North America with Local Care"From: Christian Loos [mailto:cloos@netcologne.de]
Sent: Thursday, November 20, 2014 1:52 AM
To: Bryon Baker; RT Users (rt-users@lists.bestpractical.com)
Subject: Re: Problem with date

Hi,

as far as I understand you script you try to set the ticket resolved date to the transaction date when the ticket status is set to closed.

If you have configured you RT correct this is done automatically by RT.

So what is your intent with this script?

Chris

RT saves dates in the DB in UTC.

In the web interface dates are displayed based on the RT_SiteConfig.pm
[1] or User timezone.

Maybe just your timezone config is wrong.

Chris

[1] RT Config - RT 5.0.5 Documentation - Best Practical 20.11.2014 um 15:17 schrieb Bryon Baker:

Thanks for your response Christian.

So where it RT is that configuration?

This is why I developed the script to update the resolved date and timeworked. I have been trying to get this to work for months and I have completely missed the configuration you are talking about.

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 . 262-783-6261 ext. 2296
bbaker@copesan.com
www.copesan.com
“Servicing North America with Local Care”

-----Original Message-----
From: Christian Loos [mailto:cloos@netcologne.de]
Sent: Thursday, November 20, 2014 1:52 AM
To: Bryon Baker; RT Users (rt-users@lists.bestpractical.com)
Subject: Re: Problem with date

Hi,

as far as I understand you script you try to set the ticket resolved date to the transaction date when the ticket status is set to closed.

If you have configured you RT correct this is done automatically by RT.

So what is your intent with this script?

Chris

Am 19.11.2014 um 20:18 schrieb Bryon Baker:

I am attempting use the following code to update the Resolved date in
a ticket. Thanks for the help in advance.

package RT::Action::CSRUpdateResolvedTest;

use base ‘RT::Action’;

use strict;

use warnings;

sub Prepare

{

            return 1;

}

sub Commit

{

            my %mon2num = qw(

                            jan 1  feb 2  mar 3  apr 4  may 5  jun 

6

                            jul 7  aug 8  sep 9  oct 10 nov 11 dec 

12

            );

            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 @dateresolvedstr;

            my $transactions = $ticket->Transactions;

            $transactions->Limit( FIELD => 'Type', VALUE => 

‘Status’, FIELD => ‘NewValue’, VALUE => ‘closed’);

            while (my $transaction = $transactions->Next)

            {

        $dateresolved = localtime($transaction->CreatedObj->Unix);

                       @dateresolvedstr = split(" 

",$dateresolved);

                       $dateresolvedstr = $dateresolvedstr[4] . "-"

. $mon2num{lc substr($dateresolvedstr[1], 0, 3)} . “-” .
$dateresolvedstr[2] . " " . $dateresolvedstr[3];

             }



            print $dateresolvedstr . " " . $dateresolved . "\n";

            $ticket->SetResolved($dateresolvedstr);



            return 1;

}

The dates printed to the console are correct but when I view the
ticket the resolved date is different than the dates printed to the
console by
6 hours. This seems to me to be the off set for the time zone. What
do I need to add for Request Tracker to take the date as is?

Thanks

Bryon Baker

Network Operations Manager

/Copesan/**/- Specialists in Pest Solutions/

800-267-3726 . 262-783-6261 ext. 2296

bbaker@copesan.com mailto:cstephan@copesan.com

www.copesan.com http://www.copesan.com/

/“Servicing North America with Local Care”/

The time zone is configured correctly.

Maybe I state the issue wrong in the current configuration when a ticket is closed the TimeWorked and the Resolved date are not updated.

Is there a configuration I need to add to turn on this automated feature?

All other dates seem to be populating. Created, Started, Last Contact, Updated and they are showing the correct dates. But when a ticket is closed the “closed date” does not get populated nor does the timework.

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 . 262-783-6261 ext. 2296
bbaker@copesan.com

"Servicing North America with Local Care"From: Christian Loos [mailto:cloos@netcologne.de]
Sent: Thursday, November 20, 2014 8:33 AM
To: Bryon Baker; RT Users (rt-users@lists.bestpractical.com)
Subject: Re: Problem with date

RT saves dates in the DB in UTC.

In the web interface dates are displayed based on the RT_SiteConfig.pm [1] or User timezone.

Maybe just your timezone config is wrong.

Chris

[1] RT Config - RT 5.0.3 Documentation - Best Practical

The ticket resolved date is updated if the ticket status changes to an
inactive one.
Maybe you have configured you lifecycle wrong as “closed” isn’t one of
the status that RT ships with.

See: RT Config - RT 5.0.5 Documentation - Best Practical 20.11.2014 um 15:40 schrieb Bryon Baker:

The time zone is configured correctly.

Maybe I state the issue wrong in the current configuration when a ticket is closed the TimeWorked and the Resolved date are not updated.

Is there a configuration I need to add to turn on this automated feature?

All other dates seem to be populating. Created, Started, Last Contact, Updated and they are showing the correct dates. But when a ticket is closed the “closed date” does not get populated nor does the timework.

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 . 262-783-6261 ext. 2296
bbaker@copesan.com
www.copesan.com
“Servicing North America with Local Care”

-----Original Message-----
From: Christian Loos [mailto:cloos@netcologne.de]
Sent: Thursday, November 20, 2014 8:33 AM
To: Bryon Baker; RT Users (rt-users@lists.bestpractical.com)
Subject: Re: Problem with date

RT saves dates in the DB in UTC.

In the web interface dates are displayed based on the RT_SiteConfig.pm [1] or User timezone.

Maybe just your timezone config is wrong.

Chris

[1] RT Config - RT 5.0.5 Documentation - Best Practical

Am 20.11.2014 um 15:17 schrieb Bryon Baker:

Thanks for your response Christian.

So where it RT is that configuration?

This is why I developed the script to update the resolved date and timeworked. I have been trying to get this to work for months and I have completely missed the configuration you are talking about.

Thanks
Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726 . 262-783-6261 ext. 2296 bbaker@copesan.com
www.copesan.com “Servicing North America with Local Care”

-----Original Message-----
From: Christian Loos [mailto:cloos@netcologne.de]
Sent: Thursday, November 20, 2014 1:52 AM
To: Bryon Baker; RT Users (rt-users@lists.bestpractical.com)
Subject: Re: Problem with date

Hi,

as far as I understand you script you try to set the ticket resolved date to the transaction date when the ticket status is set to closed.

If you have configured you RT correct this is done automatically by RT.

So what is your intent with this script?

Chris

Am 19.11.2014 um 20:18 schrieb Bryon Baker:

I am attempting use the following code to update the Resolved date
in a ticket. Thanks for the help in advance.

package RT::Action::CSRUpdateResolvedTest;

use base ‘RT::Action’;

use strict;

use warnings;

sub Prepare

{

            return 1;

}

sub Commit

{

            my %mon2num = qw(

                            jan 1  feb 2  mar 3  apr 4  may 5  

jun
6

                            jul 7  aug 8  sep 9  oct 10 nov 11 

dec
12

            );

            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 @dateresolvedstr;

            my $transactions = $ticket->Transactions;

            $transactions->Limit( FIELD => 'Type', VALUE => 

‘Status’, FIELD => ‘NewValue’, VALUE => ‘closed’);

            while (my $transaction = $transactions->Next)

            {

        $dateresolved = 

localtime($transaction->CreatedObj->Unix);

                       @dateresolvedstr = split(" 

",$dateresolved);

                       $dateresolvedstr = $dateresolvedstr[4] . "-"

. $mon2num{lc substr($dateresolvedstr[1], 0, 3)} . “-” .
$dateresolvedstr[2] . " " . $dateresolvedstr[3];

             }



            print $dateresolvedstr . " " . $dateresolved . "\n";

            $ticket->SetResolved($dateresolvedstr);



            return 1;

}

The dates printed to the console are correct but when I view the
ticket the resolved date is different than the dates printed to the
console by
6 hours. This seems to me to be the off set for the time zone. What
do I need to add for Request Tracker to take the date as is?

Thanks

Bryon Baker

Network Operations Manager

/Copesan/**/- Specialists in Pest Solutions/

800-267-3726 . 262-783-6261 ext. 2296

bbaker@copesan.com mailto:cstephan@copesan.com

www.copesan.com http://www.copesan.com/

/“Servicing North America with Local Care”/