Hi Joachim,

On Thu, Dec 11, 2014 at 04:44:12PM +0100, Joachim Saul wrote:
> in one particular folder I collect messages for which I would like
> to display the date in the index as UTC. In all other folders I
> want to keep my local time zone.
Dates in the index are built following the index_format variable. For
this purpose, index_format uses the strftime function's string
expansion mechanism, which doesn't provide means to show time as UTC.
However the "date" program can build UTC dates, and mutt can use
external programs to build configuration variables.

Let's say you want to use the default index_format, except that you want
to display hour and minute as well, in local time by default, and in
UTC for the foobar folder.

First write a one-line shell script that displays a date given as
parameter in the UTC (and make it executable). For example
~/.mutt/index_utc.sh :
----------------
#!/bin/bash
echo "%4C %Z $(date --utc --date "$1" '+%b %d %H:%M') %-15.15L (%?l?%4l&%4c?) 
%s%"
----------------

Then, in ~/.muttrc, you create a default folder hook and a specific
folder hook for "foobar" box :
----------------
folder-hook . "set index_format=\"%4C %Z %[%b %d %H:%M] %-15.15L (%?l?%4l&%4c?) 
%s\""
folder-hook =foobar "set index_format = \"$HOME/.mutt/index_utc.sh '%[%Y-%m-%d 
%H:%M %Z]'|\""
----------------

The pipe symbol at the end of the content of the index_format variable
tells mutt to build it using the output of the given command. Percentage
expansion is done before calling the command. If the output of the
command ends with "%", percentage expansion is done again by mutt on the
output. This is explained in chapter 30.3 (Filters) of the official doc.

I tested this setup and it worked. It may be slow with huge boxes since
the script, and the date program, are called for each message.
-- 
Bernard Massot

Reply via email to