[rt-users] Dates

Matthew 'Chewy' Trewhella matt at winweb.net
Thu Jun 27 09:03:27 EDT 2002


Date::Parse is a little weak at recognising European dates:

I include this code in lib/Date.pm and it seems to work ok:

    elsif ($args{'Format'} =~ /^unknown$/i) {
        require Date::Parse;
        require POSIX;
        #Convert it to an ISO format string

        my $date = Date::Parse::str2time($args{'Value'});

#### New from here
        # Major bug in that it doesn't recognise European Dates. Perhaps a
new version of Date::Parse works better? Slow connection, so no time to find
out.
        # if date is still undef, assume format mm/dd/yy[yy]
        if($date eq undef) {
          my ($chewy_d, $chewy_m, $chewy_y);
          ($chewy_d, $chewy_m, $chewy_y) = split(/\//, $args{'Value'});
          $chewy_y = int($chewy_y);
          $chewy_m = int($chewy_m);
          $chewy_d = int($chewy_d);
          if($chewy_y > 2000) { $chewy_y -= 1900; }
          elsif($chewy_y < 100) { $chewy_y += 100 };
          $date = POSIX::mktime(0, 0, 17, $chewy_d, ($chewy_m - 1),
$chewy_y);
          $RT::Logger->debug("RT::Date used Chewy's mechanism to make
($chewy_d, $chewy_m, $chewy_y) ". $args{'Value'} . " $date\n");
        }
#### To here

        #This date has now been set to a date in the _local_ timezone.
        #since ISO dates are known to be in GMT (for RT's purposes);

        $RT::Logger->debug("RT::Date used date::parse to make
".$args{'Value'} . " $date\n");

______________
Ecce Potestas Casei





More information about the rt-users mailing list