Date seems good at parsing dates and I am not into reinventing the wheel,
so:
#### The Date date ###################
# remove the variable
DATE_SECS
: 0
* ^Date: \/.*
{
DATE_SECS=`date --date "$MATCH" +%s`
}
# check for missing or bad date outside the recipe
DATE_SECS=${DATE_SECS:-"Bad date"}
and can check for numeric with scoring:
:0
* 1^0
* -1^1 FROM_SECS ?? [^0123456789]
* -1^1 DATE_SECS ?? [^0123456789]
and then do a comparison with scoring.
Firstly, I am a little worried about whether or not date is clever enough
to identify all possible valid date formats in the date: header,
and secondly, I found an example of a bad date in a spam that didn't cause
date to fail:
date -d "Wed, Jun 2002 23:01:09"
gives:
Fri Nov 23 23:01:09 GMT 2007
As it happens, this result is OK for the next 5 years as variations of
this always seem to result in the year 2007 but it is not ideal.
So maybe I should look to an alternative to date? Are there other date
parsers available?
Alan
( Please do not email me AS WELL as replying to the list. Personal
email may invoke a password autoresponder. )
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail