procmail
[Top] [All Lists]

Re: my Resent-Date: kludge

1996-08-24 17:59:38
David W. Tamkin wrote:

Because the mail for which I need a Resent-Date: always has just had the
timestamp in the From_ line freshly updated by procmail -f-, I decided to
build the Resent-Date: from the new From_ line.  (So maybe it's a couple
seconds slow because of the time procmail needs to do the rest of its work
between updating the timestamp and handing the outgoing message over to
Smail; big deal.)

Well, if I remember your previous posts on the subject, you don't
want to run the "date" program or any other.  Not sure why; if it
happens a lot, the thing should be cached anyway.  But since you seem
willing below to cave in and run it *sometimes*... for a week at a
time...

The only thing lacking in the From_ line is the timezone.  In the US we set
clocks ahead on the first Sunday in April and back on the last Sunday in
October, so ten months out of the year (if the location of one's machine
is static) the timezone is obvious from the month; and from April 8 through
April 30 and from October 1 through October 24 we're on Daylight Savings
Time.

(Unless you're in parts of Indiana or a few other places.  And in other
parts of the world, the dates are different as well.  So if you want
to be general, read on as well.)

For the remaining fourteen days of the year -- April 1 through April 7
and October 25 through October 31 -- I cave in and run date +%Z to get the
time zone.

With a much more complicated rcfile I could further examine the data in early
April and late October and compare day of the week to date of the month, and
finally on Sundays check the hour, reducing the need to run date from four-
teen days a year to two hours a year (1 AM CDT to 2 AM CST -- i.e., 0600 UTC
to 0800 UTC -- on the last Sunday in October), but I'm just not up to coding
that yet.

Or you can do that stuff before the following as well.  But why the
bother, really? You can use your above to decide whether to do the
following (which involve running date) or not, but I think it's wrong.
People time (i.e., yours) is more costly and valuable than a huge
number of executions of the date program, and you could still end up
with bugs.

I see two choices.  The simplest is just construct your
Resent-Date: header from `date -u` (with appropriate format) and send
it out as GMT (or in the now-preferred "+0000" form).  Actually, I'd
recommend this because it should *ALWAYS* work, even if they change
the first Sunday in April to the third Sunday in February next year
(or something). Well worth the extra times you'll run the
date program, given the mental anguish you'll save.  Plus the fact
you'll surely forget to change your script when Congress changes
the law or when you send a computer off to Indiana (or when you
start running on a computer that uses native GMT, period).

The second choice is to get the hour from both `date` and `date -u`,
do a little arithmetic, and you'll have the time zone.  Tiny little
race condition at the two critical moments of the year, though.
To be portable, you'll have to worry about half-hour time zones in
a few places though  :-)

Cheers,
Stan.

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