[rt-users] problems getting dates parsed with RT::Date
darren chamberlain
darren at boston.com
Wed Aug 21 11:56:37 EDT 2002
* Ted Serreyn <ted at serreyn.com> [2002-08-21 11:44]:
> I am trying to get a date that looks like "Fri Mar 08 12:14:32 CST
> 2002" parsed into RT using the RT::Date methods. However it is not
> working.
>
> Is there any documentation on exactly what RT::Date will parse?
From perldoc RT::Date:
Set
takes a param hash with the fields 'Format' and 'Value'
if $args->{'Format'} is 'unix', takes the number of sec
onds since the epoch
If $args->{'Format'} is ISO, tries to parse an ISO date.
If $args->{'Format'} is 'unknown', require Date::Parse and
make it figure things out. This is a heavyweight operation
that should never be called from within RT's core. But
it's really useful for something like the textbox date
entry where we let the user do whatever they want.
If $args->{'Value'} is 0, assumes you mean never.
> @Arrival, @Closed and @LastUpdated all contain dates in the format
> given above?
Turn these lists into scalars (see my example below).
> my $RTCreated = new RT::Date();
> my $RTResolved = new RT::Date();
> my $RTLastUpdated = new RT::Date();
> $RTCreated->Set (Format => 'unknown',
> Value => @Arrival);
> $RTResolved->Set (Format => 'unknown',
> Value => @Closed);
> $RTLastUpdated->Set (Format => 'unknown',
> Value => @LastUpdated);
This shouldn't work. Perl is flattening @Arrival, @Closed, and
@LastUpdated into multiple scalars, which means the these calls look
like:
$RTLastUpdated->Set("Format",
"unknown",
"Value",
"Fri",
"Mar",
"08",
"12:14:32",
"CST",
"2002");
That is, a call to the Set() method with 9 parameters. Try:
$RTLastUpdated->Set(Format => 'unknown',
Value => join " ", @LastUpdated);
And it should work for you.
(darren)
--
Your only obligation in any lifetime is to be true to yourself.
Being true to anyone else or anything else is ... impossible.
-- Richard Bach
More information about the rt-users
mailing list