Going crazy with RT 3.8 and Timezones for Display Dates

Hi RT Users,
since we are planing our RT 3.8 migration, we are cross checking all our
scrips and some scrips with time calculaltions driving me mad.

Example from RT 3.6.x

We have two CF’s: Date and the other Time

CF.Date
CF.Time

The user is entering the date and the time in utc normally - our RT is
running in UTC

Then i have a tiny scrip:

my $DUEDATE = $self->TicketObj->FirstCustomFieldValue(‘Date’);
my $DUETIME = $self->TicketObj->FirstCustomFieldValue(‘Time’);
my $DUE = $DUEDATE." ".$DUETIME;
$self->TicketObj->SetDue($DUE);
return 1;

Under RT 3.6. RT was setting this simply to the entered values, all was
fine.

Now with RT 3.8 RT the user is able to enter his timezone offset for Display
and RT is adding the Timezone Difference to this value.

Any hints how to prevent this? or to make sure to get the correct value,
entered by the user?

Torsten

MFG

Torsten Brumm

http://www.brumm.me

Hi Torsten,

try this:

my $DUEDATE = $self->TicketObj->FirstCustomFieldValue(‘Date’);
my $DUETIME = $self->TicketObj->FirstCustomFieldValue(‘Time’);
my $DUE = $DUEDATE." ".$DUETIME;
my $DATE = RT::Date->new( $session{‘CurrentUser’} );
$DATE->Set(
Format => ‘unknown’,
Value => $DUE,
Timezone => ‘UTC’,
);
$self->TicketObj->SetDue( $DATE->ISO );
return 1;

ChrisAm 30.06.2010 18:44, schrieb Torsten Brumm:

Hi RT Users,
since we are planing our RT 3.8 migration, we are cross checking all our
scrips and some scrips with time calculaltions driving me mad.

Example from RT 3.6.x

We have two CF’s: Date and the other Time

CF.Date
CF.Time

The user is entering the date and the time in utc normally - our RT is
running in UTC

Then i have a tiny scrip:

my $DUEDATE = $self->TicketObj->FirstCustomFieldValue(‘Date’);
my $DUETIME = $self->TicketObj->FirstCustomFieldValue(‘Time’);
my $DUE = $DUEDATE." ".$DUETIME;
$self->TicketObj->SetDue($DUE);
return 1;

Under RT 3.6. RT was setting this simply to the entered values, all was
fine.

Now with RT 3.8 RT the user is able to enter his timezone offset for
Display and RT is adding the Timezone Difference to this value.

Any hints how to prevent this? or to make sure to get the correct value,
entered by the user?

Torsten


MFG

Torsten Brumm

http://www.brumm.me
http://www.elektrofeld.de

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi Chris,
this i already tried. The problem is more that the timezone offset is only
for display, not for calculation used (so far i figured already) and i have
really no idea how to fix it. one possible way could be:

  1. If a user is entering this fields, check the users timezone and use the
    offset to work with the utc values…

i will play around a little more…

Torsten2010/7/1 Christian Loos cloos@netcologne.de

Hi Torsten,

try this:

my $DUEDATE = $self->TicketObj->FirstCustomFieldValue(‘Date’);
my $DUETIME = $self->TicketObj->FirstCustomFieldValue(‘Time’);
my $DUE = $DUEDATE." ".$DUETIME;
my $DATE = RT::Date->new( $session{‘CurrentUser’} );
$DATE->Set(
Format => ‘unknown’,
Value => $DUE,
Timezone => ‘UTC’,
);
$self->TicketObj->SetDue( $DATE->ISO );
return 1;

Chris

Am 30.06.2010 18:44, schrieb Torsten Brumm:

Hi RT Users,
since we are planing our RT 3.8 migration, we are cross checking all our
scrips and some scrips with time calculaltions driving me mad.

Example from RT 3.6.x

We have two CF’s: Date and the other Time

CF.Date
CF.Time

The user is entering the date and the time in utc normally - our RT is
running in UTC

Then i have a tiny scrip:

my $DUEDATE = $self->TicketObj->FirstCustomFieldValue(‘Date’);
my $DUETIME = $self->TicketObj->FirstCustomFieldValue(‘Time’);
my $DUE = $DUEDATE." ".$DUETIME;
$self->TicketObj->SetDue($DUE);
return 1;

Under RT 3.6. RT was setting this simply to the entered values, all was
fine.

Now with RT 3.8 RT the user is able to enter his timezone offset for
Display and RT is adding the Timezone Difference to this value.

Any hints how to prevent this? or to make sure to get the correct value,
entered by the user?

Torsten


MFG

Torsten Brumm

http://www.brumm.me
http://www.elektrofeld.de

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

MFG

Torsten Brumm

http://www.brumm.me

Hi Torsten,

normally you don’t need to worry about timezones in date calculations.
You should always normalize all dates to UTC and then do the calculations.

May you can give an example of you date calculations?

ChrisAm 01.07.2010 14:10, schrieb Torsten Brumm:

Hi Chris,
this i already tried. The problem is more that the timezone offset is
only for display, not for calculation used (so far i figured already)
and i have really no idea how to fix it. one possible way could be:

  1. If a user is entering this fields, check the users timezone and use
    the offset to work with the utc values…

i will play around a little more…

Torsten

Hi.
I think you want to construct date object using user who set those cfs and
use timezone user. SetDue method has no diff between 3.6 and 3.8, it takes
ISO in utc.

написал:

Hi Chris,
this i already tried. The problem is more that the timezone offset is only
for display, not for calculation used (so far i figured already) and i have
really no idea how to fix it. one possible way could be:

  1. If a user is entering this fields, check the users timezone and use the
    offset to work with the utc values…

i will play around a little more…

Torsten2010/7/1 Christian Loos cloos@netcologne.de

Hi Torsten,

try this:

my $DUEDATE = $self->TicketObj->FirstCustomFieldValue(‘Date’);

MFG

Torsten Brumm

http://www.brumm.me

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com