Re: mhonarc 1.2.3 bug?

1996-07-25 08:00:44
I'm not sure if this is a bug of mhonarc or of sendmail, however the
format of the date of the mail received is:

Tue, 18 JUN 1996 20:17:04 +0000

which has two problems: the comma after the first field and the name of
the month in uppercase. For this reasons &parse_date fails in parsing
the month and so all mail appear sent in January.

I suggest to modify parse_date so as to eliminate extra commas (as extra
spaces are already eliminated), to modify %Month2Num with the names of
the monts all in lowercase and to use $Month2Num{lc($mon)} (or the
corresponding statement perl4 compatible). This should take into account
the case of month names all lowercase.

I've made the fix, and it will be included in the next release.
The following is the new parse_date routine (UNTESTED!)
(**the Month2Num and WDay2Num keys must be changed to all lowercase**):

sub parse_date {
    local($date) = $_[0];
    local($wday, $mday, $mon, $yr, $time, $hr, $min, $sec, $zone);
    $date =~ s/^\s*//;
    ##  Figure out the date format and get parts
    @array = split(' ', $date);
    if ($array[0] =~ /\d/) {        # DD Mon YY HH:MM:SS Zone
        ($mday, $mon, $yr, $time, $zone) = @array;
    } elsif ($array[1] =~ /\d/) {   # Wdy DD Mon YY HH:MM:SS Zone
        ($wday, $mday, $mon, $yr, $time, $zone) = @array;
    } else {                        # Wdy Mon DD HH:MM:SS Zone YYYY
        ($wday, $mon, $mday, $time, $zone, $yr) = @array;
        if ($zone =~ /\d/) {        # No zone
            $yr = $zone;
            $zone = '';
    ##  Break up time
    ($hr, $min, $sec) = split(/:/, $time);
    $sec = 0  unless $sec;          # Sometime seconds not defined
    # Modify month and weekday for lookup
    $mon =~ tr/A-Z/a-z/;
    $wday =~ s/,//g;  $wday =~ tr/A-Z/a-z/;
    ($WDay2Num{$wday}, $mday, $Month2Num{$mon}, $yr, $hr, $min, $sec, $zone);

<Prev in Thread] Current Thread [Next in Thread>