Hello, Peter!

I have applied the following patch to your mailfs script. Now it can find
dates for all messages in my inbox, even those with Y2K bugs and tabs
after "Date:".

The matching rules have been sligtly relaxed to accomodate single-digit
hour (1:35:00) and missing seconds (01:35).

Messages from aolmail.aol.com have a different format for dates, it's also
recognized and supported now.

Regards,
Pavel Roskin

_________________________________
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,12 @@
+2001-02-11  Pavel Roskin  <[EMAIL PROTECTED]>
+
+       * extfs/mailfs (parse_date): Workaround for Y2K bugs. Support
+       for dates found in AOLMail(SM) messages. Accept single-digit
+       hours and missing seconds. Provide a fallback if cannot parse
+       the date.
+       (process_header): Typo fix. Use \s instead of space in regular
+       expressions.
+
 2001-02-10  Pavel Roskin  <[EMAIL PROTECTED]>

        * extfs/uzip.in: Preserve permissions of FAT and NTFS archives,
--- extfs/mailfs
+++ extfs/mailfs
@@ -20,25 +20,41 @@
     $parse_date= sub {
        # assumes something like: Mon, 5 Jan 1998 16:08:19 +0200 (GMT+0200)
        # if you have mails with another date format, add it here
-       if (/(\d\d?) ([A-Z][a-z][a-z]) (\d\d\d\d) (\d\d:\d\d):\d\d/) {
+       if (/(\d\d?) ([A-Z][a-z][a-z]) (\d\d\d\d) (\d\d?:\d\d)/) {
            return "$2 $1 $3 $4";
        }
+       # Y2K bug.
+       # Date: Mon, 27 Mar 100 16:30:47 +0000 (GMT)
+       if (/(\d\d?) ([A-Z][a-z][a-z]) (1?\d\d) (\d\d?:\d\d)/) {
+           $correct_year = 1900 + $3;
+           if ($correct_year < 2000) {
+               $correct_year += 100;
+           }
+           return "$2 $1 $correct_year $4";
+       }
+       # AOLMail(SM).
+       # Date: Sat Jul 01 10:06:06 2000
+       if (/([A-Z][a-z][a-z]) (\d\d?) (\d\d?:\d\d)(:\d\d)? (\d\d\d\d)/) {
+           return "$1 $2 $5 $3";
+       }
+       # Fallback
+       return "Jan 1 1980 00:00";
     }
 }

 sub process_header {
     while (<IN>) {
        last if /^$/;
-       die "unexpeced EOF\n" if eof;
-       if (/^Date: (.*)$/) {
+       die "unexpected EOF\n" if eof;
+       if (/^Date:\s(.*)$/) {
            $date=&$parse_date($1);
-       } elsif (/^Subject: (.*)$/) {
+       } elsif (/^Subject:\s(.*)$/) {
            $subj=$1;
-           $subj=~ s/^(re: ?)+//gi;  # no leading Re:
+           $subj=~ s/^(re:\s?)+//gi;  # no leading Re:
            $subj=~ tr/a-zA-Z0-9//cd; # strip all "special" characters
-       } elsif (/^From: .*?(\w+)\@/) {
+       } elsif (/^From:\s.*?(\w+)\@/) {
            $from=$1;
-       } elsif (/^To: .*?(\w+)\@/) {
+       } elsif (/^To:\s.*?(\w+)\@/) {
            $to=$1;
        }
     }
_________________________________


Reply via email to