nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] %(timenow) -- does it have a purpose?

2017-06-30 21:20:29
On Fri, 30 Jun 2017 00:29:57 -0400 Ken Hornstein <kenh(_at_)pobox(_dot_)com> 
sez:

Does %(timenow) have a purpose?

Yeah, although probably not what you're thinking of.

The idea is that you could use that in calculations against a
date header.  (e.g., %(timenow) - %(clock) would give you an
offset, although there is %(rclock that does that for you).

That's what I thought (both using it in a calculation, and that
the most obvious one is already handled by %(rclock)).

Things like %(month) are designed to parse a date header, since
that's hard to do from the shell.  I could see the value of
maybe doing something to break out a inside of mh-format, but
... what would that look like?  Maybe take a strftime() format
string?  Might need some thought.  Not sure we could use
existing functions since they really want a component.

These days, at least with GNU date(1), it's pretty trivial to
parse and (re)print a (valid) date string in any format your
heart desires -- e.g.

     % date -d 'Fri, 30 Jun 2017 00:29:57 -0400' +"Year %Y, month %B, day %-d"
     Year 2017, month June, day 29

Given that no one has asked for this in the decades (N)MH has
been around, that means it's (likely) one of those things that
only 1 person (me B-) wants or needs.  After all, the more
"general" solution might be to create conversion functions -- in
the vein of the existing %(compval) function -- for the various
registers, (e.g. %(strtodate), which would (almost) bridge the
gap for me, which would then tempt you to bring in more features
that are better done using existing Unix commands.  Very deep,
this rabbit hole appears.  B-)

Separately, does anyone have a suggestion for generating the
current date in a reply?

Sure.  Have a wrapper script shove it into an enviroment
variable and use %(getenv).

Thanks!  I keep forgetting about %(getenv).

                                Bob

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

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