procmail
[Top] [All Lists]

How I solved the mmm to mm

2004-02-10 14:33:30
   # xDATE is extracted from Date: and contains dd MMM yyyy
   :0
   * $ xDATE ?? $DAYS \/$MONTHS $YEARS
   {
      TEMPMON = $MATCH
      :0
      * 1^0 $TEMPMON ?? JAN
      * 2^0 $TEMPMON ?? FEB
      * 3^0 $TEMPMON ?? MAR
      * 4^0 $TEMPMON ?? APR
      * 5^0 $TEMPMON ?? MAY
      * 6^0 $TEMPMON ?? JUN
      * 7^0 $TEMPMON ?? JUL
      * 8^0 $TEMPMON ?? AUG
      * 9^0 $TEMPMON ?? SEP
      * 10^0 $TEMPMON ?? OCT
      * 11^0 $TEMPMON ?? NOV
      * 12^0 $TEMPMON ?? DEC
      {
         MYMONTH = $=
      }
      :0
      * $ TEMPMON ?? $MONTHS \/$YEARS
      {
         MYYEAR=$MATCH
         DATE_FOLDER=$MYYEAR-$MYMONTH
      }

    }

Ugly? Yes, but under testing with a quarter million messages, it's been very accurate (failing only on messages with a improper Date: header, which are not all that common in my spool).

next step is to get MYMONTH to "05" from "5" but I think that's pretty trivial

TMONTH = "0"$MYMONTH
TMONTH ?? ().*\/..
MYMONTH=$MATCH

or something.

--
There's nothing to do, so you just stay in bed [ah, poor thing] Why live in the world when you can live in your head?


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