I’m getting weird timestamps in rt2 (running on Linux RH8). I’m in Auckland,
New Zealand (GMT +12). I have set the timezone setting in config.pm to
‘NZDT’, which I believe linux understands (at least “date” returns in NZDT,
eg Tue Nov 26 09:43:12 NZDT 2002) but in RT the timestamp seems to be for
GMT.
You’re referring to things like the Search page displaying dates in GMT
(eg: Search Criteria … Created > 2002-07-31 22:00:00 GMT), yes?
RT will always store dates in GMT/UTC format, and you really don’t want
to change the storage of the dates.
However, the presentation of the dates during a search, thats another
matter. The RT::Date->AsString() method returns dates in the local
timezone, so we could change the descriptive text for the search criteria.
After a little poking around, we see that /Search/Listing.html relies on
RT::Tickets->DescribeRestrictions(). Another bit of poking around shows
that this is the only reference to the call, and the text stored in the
RT::Tickets object is used only by humans.
So, lets look at where that field is set. Obviously, its in
RT::Tickets->LimitDate, where we see that we’re setting the DESCRIPTION
manually, ie:
unless ($args{'DESCRIPTION'} ) {
$args{'DESCRIPTION'} = $args{'FIELD'} . " " .$args{'OPERATOR'}. " ". $args{'VALUE'} . " GMT"
}
Note the GMT on the end. What we want to do is to show the date in the
local timezone. Since RT has a nice RT::Date object that we can use, we
don’t need to do date manipulations ourselves:
unless ($args{'DESCRIPTION'} ) {
# Create a RT::Date object.
my $tdate = RT::Date->new( $RT::SystemUser );
# Set it to the specific time.
$tdate->Set( Format => 'ISO',
Value => $args{'VALUE'} );
# The old line commented out.
# $args{'DESCRIPTION'} = $args{'FIELD'} . " " .$args{'OPERATOR'}. " ". $args{'VALUE'} . " GMT"
# If we use AsString, we get it in the localtimezone.
$args{'DESCRIPTION'} = $args{'FIELD'} . " " .$args{'OPERATOR'}. " ". $tdate->AsString() . " " . $tdate->LocalTimezone();
}
Note that you will need to set $Timezone in etc/config.pm to be
something that your machine recognises. After editing it, you will need
to stop and then start your apache instance to flush the mod_perl cache
and have changes be visible.
Regards,
Bruce Campbell RIPE
Systems/Network Engineer NCC
www.ripe.net - PGP562C8B1B Operations/Security