procmail
[Top] [All Lists]

Some date checking code.

2003-05-12 18:21:21
I have seen several examples of some date checking ideas
in the archive and cobbled this together.  I believe it
is much more detailed (ie. operational recipe rather
than snippets) than anything I saw posted.  Anyhow I
am throwing it out to see if there are any comments,
corrections, insights, simplifications, etc.:

-------------------------------------
:0 H
* ^Date.*\/[+-]1[4-9]00|\
  ^Date.*\/[+-][2-9][0-9]00
{
  :0 H
  * $ ${WEIGHT}^0
  * 12^0
  { }
  WEIGHT="$="
  LOG="Weight adjusted for phoney timezone: $WEIGHT $NL"
}

DATE_SECS
TODAY_SECS
:0 H
* ^Date:[       ]+\/.*
{
  DATE_SECS=`date --date "$MATCH" +%s`
  TODAY_SECS=`date +%s`
}
DATE_SECS=${DATE_SECS:-"Bad date"}

:0 H
* DATE_SECS ?? [^0123456789]
{
  :0 H
  * $ ${WEIGHT}^0
  * 6^0
  { }
  WEIGHT="$="
  LOG="Weight adjusted for bad date: $WEIGHT $NL"
}

:0 H
* -172800^0
* $ -$TODAY_SECS^0
* $ $DATE_SECS^0
{
  :0 H
  * $ ${WEIGHT}^0
  * 12^0
  { }
  WEIGHT="$="
  LOG="Weight adjusted for date more than 2 days in the future: $WEIGHT $NL"
}

:0 H
* -345600^0
* $ $TODAY_SECS^0
* $ -$DATE_SECS^0
{
  :0 H
  * $ ${WEIGHT}^0
  * 12^0
  { }
  WEIGHT="$="
  LOG="Weight adjusted for date more than 4 days in the past: $WEIGHT $NL"
}
-------------------------------------

There you go.  It seems to work for me but I am interested
in any comments.

--
Daryle A. Tilroe


_______________________________________________
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>