procmail
[Top] [All Lists]

date parsing (was: Incrementing a counter)

1997-10-10 00:56:48
Edward J. Sabol writes on 9 October 1997 at 18:20:24
Excerpts from mail: (09-Oct-97) Incrementing a counter by Bill Moseley
TODAY=`date '+%m%y%d'`

Instead of forking a `date' process, I suggest parsing the date from the
From_ header. (Warning: I don't think all From_ headers look exactly the
same, so you should test this first.)
[...]

Alan Stebbens' <aks(_at_)sgi(_dot_)com> procmail library has a date.rc module
which you may find useful.  You can get the entire library from
  http://reality.sgi.com/aks/depot/mail/procmail/procmail-lib.shar
Here's some of the commentary from date.rc

   Dan
------------------- message is author's opinion only ------------------
J. Daniel Smith <DanS(_at_)bristol(_dot_)com>        
http://www.bristol.com/~DanS
Bristol Technology B.V.                   +31 33 450 50 50, ...51 (FAX)
Amersfoort, The Netherlands               {info,jobs}(_at_)bristol(_dot_)com
-----
# Procmail recipe to extract and create some variables related to 
# the date in the message.  If the message has no date reference, 
# either the variables are returned undefined, or set using the 
# current date depending upon DATE_DEFAULT_NOW.

# Currently, this recipe file parses dates with these formats:
#
#  1. Tue(sday), 31 Dec 96
#  2. Tue, 31 Dec 1996
#  3. 12/31/96
#  4. Tuesday, December 31, 1996
#
# If DATE is not defined, then obtain the date from the current input message
# from the following headers, in decreasing priority: Resent-Date:, Date:, 
# and "From ".
# 
# If DATE is defined, it is simply used as the input.
#
# Thus to parse the date from the current mail message do this:
#
#       DATE    INCLUDERC=date.rc
#
# To make this even easier, use "get-date.rc":
#
#       INCLUDERC=get-date.rc
#
# To parse a given date string, simply set DATE:
#
#       DATE=12/31/96   INCLUDERC=date.rc
#       
#
# These variables are set from the parsing of DATE:
#
#  DATE                 # the original, complete date string from which 
#                       # all other variables were derived
#  [...cut...]
#
# These variables are used within date.rc but will not return 
# meaningful values.
#
#  DAYS_RE MONTHS_RE S Y N NN APM ZONE X D

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