> -----Original Message----- > From: rt-users-boun...@lists.bestpractical.com [mailto:rt-users- > boun...@lists.bestpractical.com] On Behalf Of Kevin Falcone > Sent: Thursday, 7 June 2012 1:00 PM > To: rt-users@lists.bestpractical.com > Subject: Re: [rt-users] TicketSQL Date parse weird.. > > On Tue, Jun 05, 2012 at 06:06:09PM +1000, Stuart Browne wrote: > > When doing a TicketSQL search similar to the following: <snip> > > RT actually passes a number of arguments to parsedate: > > grep can find where it's called (not in SQL.pm) > > $ grep -r Time::ParseDate::parsedate lib/ > lib/RT/Articles.pm: my $seconds = Time::ParseDate::parsedate( > $args{$date}, FUZZY => 1, PREFER_PAST => 1 ); > lib/RT/Date.pm: my $date = Time::ParseDate::parsedate( > > -kevin
Ok, further test (see attached perl routine): [root@psg-apps tmp]# ./test.pl.txt current time() output: 1339054410 fixed-date Time::ParseDate: 1339113600 tomorrow 10am Time::ParseDate: 1339113600 fixed-date RT::Date output: 1339149600 tomorrow 10am RT::Date output: 1339200000 timezone according to RT::Date: 36000 Using either 'user' or 'server' as the timezone I get the same result but I'm probably missing something here for the fixed-date (I can accept that the date might be being modified elsewhere I'm yet to find), but the 'tomrorow 10am' shouldn't be a full day off. So the adding of the timezone offset before Time::ParsEdate::parsedate then removing it again appears to be causing the issue here; pushing today past the end of the day boundary. I'll try this routine tomorrow morning (before 10am) to see if it shows the right thing, then try to figure out a way to get it to return the same result for the two RT::Date outputs. Stuart
#!/usr/bin/perl use lib '/opt/rt3/lib'; package RT; use strict; use Time::ParseDate; use RT::Interface::CLI qw(CleanEnv); CleanEnv(); RT::LoadConfig(); RT::Init(); use RT::Date; my $now = time; printf("current time() output: %s\n", $now); print "\n"; printf("fixed-date Time::ParseDate: %s\n", Time::ParseDate::parsedate('2012-06-08 10:00:00')); printf("tomorrow 10am Time::ParseDate: %s\n", Time::ParseDate::parsedate('tomorrow 10am')); print "\n"; my $date = new RT::Date($RT::SystemUser); printf("fixed-date RT::Date output: %s\n", $date->Set(Format => 'sql', Value => '2012-06-08 10:00:00')); printf("tomorrow 10am RT::Date output: %s\n", $date->Set(Format => 'unknown', Value => 'tomorrow 10am')); printf("timezone according to RT::Date: %s\n", ($date->Localtime( 'user', $now ))[9]);