<<< Date Index >>>     <<< Thread Index >>>

Re: Setting timezone to local timezone



On Mon, Jan 29, 2007 at 12:37:11PM -0500, Kyle Wheeler wrote:
> On Monday, January 29 at 09:03 AM, quoth Stuart McKim:
> > Is there a way to specify what timezone mutt uses for the "Date:" 
> > header?
> 
> Yes.
> 
> > The server I am using is set correctly to UTC time, but I would like 
> > the date to be shown as Pacific time (currently -0800). I would 
> > really prefer to keep the server on UTC as it integrates better with 
> > the rest of our infrastructure.
> 
> Sounds reasonable.
> 
> > I know that technically the date is correct, but for somebody using 
> > an e-mail client that does not automatically convert dates to the 
> > local time, such as mutt, it would be nice to show the local time of 
> > the sender.
> 
> Wait, which do you want to do?

I had only planned on changing the sending date.

> There are two senses in which the date header is used: in displaying 
> date messages from other messages, and in sending out new messages.
> 
> Mutt SENDS the date in the local time. However, in order to do so, it 
> must (obviously) be made aware of what the local time zone IS. You do 
> this by setting the TZ environment variable. For example, in your 
> case, you would set TZ to be "US/Pacific".

Great. This did exactly what I wanted to accomplish.

> For DISPLAY of already sent messages, mutt DOES convert the date to 
> local time for display in the *index* (it even respects your LC_TIME 
> setting), but does NOT convert the date to local time for display when 
> viewing the message. As before, when it does convert things, it relies 
> on the TZ environment variable.
> 
> When you view the message, mutt does very little to obfuscate the 
> headers as they appeared in the message. In some cases, it decodes 
> them to the correct charset, and removes quotes where appropriate, but 
> the rest is essentially unmodified from exactly what was sent.
> 
> You could change that yourself by creating a display filter. For 
> example:
> 
>     #!/bin/bash
>     # save the message to a file
>     cat - > /tmp/timezoneconvert.$$
>     # extract the date header
>     thedate=$( awk '/^Date: / && !i { $1="" ; print $0 ; i=1}' )
>     # convert to the current timezone (defined by TZ)
>     thedate=$( date -d "$thedate" )
>     # output the modified message
>     awk "{ if (/^Date: /) print \"Date: $thedate\"; else print $0; }" \
>         </tmp/timezoneconvert.$$
>     # clean up
>     rm /tmp/timezoneconvert.$$
> 
> ~Kyle

I hadn't planned on doing this originally, but it is neat. How would
this script be run?

Thanks,
Stuart


-- 
Stuart McKim
mckim@xxxxxxxxxx
Open Source Lab
Oregon State University