procmail
[Top] [All Lists]

Fw: original date (again)

2001-09-05 05:56:56
 This really should be posted to the list, so that other people can
 contribute and make use of the information.  Feel free to post my
 reply there.


"Frank" <duranicub(_at_)gmx(_dot_)net> writes:
i asked i the Courier-Maillist and the Answer is
Could it be the mtime of the file?

Yes.  The INTERNALDATE IMAP attribute is taken from the mtime of the
file,
which is the time the message was delivered to the maildir.

Now we have enough Informations ?

Yes.  It'll be ugly and complicated, but now that we have a goal,
it can be done: we need to extract the date from the second Received:
header field and use that to set the mtime on message file.

Step 1: extract the date from the second Received: header field

:0
* ^Received:.*$(.*$)*Received:.*;\/[^;]+
{
DATE = $MATCH

Step 2: reformat the date into something understandable by 'touch'

:0
* DATE ?? ()\/[0-9]+
{ DAY = $MATCH }

:0
* DATE ?? ()\/(A(pr|ug)|Dec|Feb|J(an|u[ln])|Ma[ry]|Nov|Oct|Sep)
{ MONTH = $MATCH }

MON2N ="Jan = 01 Feb = 02 Mar = 03 Apr = 04
May = 05 Jun = 06 Jul = 07 Aug = 08
Sep = 09 Oct = 10 Nov = 11 Dec = 12"
:0
* MON2N ?? $ $MONTH = \/[0-9]+
{ MNUM = $MATCH }

:0
* DATE ?? $ $MONTH.*\/[0-9]+
{ YEAR = $MATCH }

:0
* DATE ?? ()\/[0-2][0-9]:[0-5][0-9]:[0-6][0-9]
{ TIME = $MATCH }

:0
* TIME ?? ^^\/[0-9]+
{ HOUR = $MATCH }

:0
* TIME ?? :\/[0-9]+
{ MIN = $MATCH }

:0
* TIME ?? :[0-9]+:\/[0-9]+
{ SEC = $MATCH }

TOUCHTIME = "$YEAR$MNUM$DAY$HOUR$MIN.$SEC"
}


Step 3: perform the delivery, then set the mtime:

:0 c
/path/to/whatever/maildir/here/

:0 ai
|touch -t $TOUCHTIME $LASTFOLDER


Adjusting for timezones and/or doing the touch via a TRAP assignment
is left as an exercise for the student.


Philip Guenther


PS: Unlike in German, only 'proper' nouns (those that designate a
particular being or thing) are capitalized.  Normal usage would therefore
capitalize neither "Answer" nor "Information".



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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