On Wed, Jan 05, 2011 at 05:20:19PM -0600, David Champion wrote:
> * On 05 Jan 2011, Toby Cubitt wrote: 
> > 
> > If I remember correctly, the date_conditional patch doesn't *quite*
> > let you have a different date/time string for today, rather it gives
> > you a different date/time string for the last 24h.
> 
> The best documentation I've seen is the changelog entry that I wrote for
> my mercurial patch queue:
> 
>     Allows you to construct format expressions based on relative dates.
> 
>     This adds conditionality features to mutt's date-formatting
>     operators, so that you can build conditions based on whether the
>     date in question is less than or grater than some amount in the
>     past.
> 
>     Example: %?[1y?less than one year&greater than one year?
>     Example: %?[3d?less than three days&greater than three days?
> 
>     This is particularly useful in concert with nested_if.  For example,
>     this expression:
>         %<[1y?%<[1w?%<[1d?%[ %H:%M]&%[%a %d]>&%[%b %d]>&%[%y%m%d]>
> 
>     means to show the YYMMDD date for messages older than one year,
>     the "mon dd" date for messages from one week to one year, the "day
>     dd" date for messages from 1 to 7 days old, and the HH:MM time for
>     messages under one day old.
> 
> So it can handle a single split point as it stands (less than 24h,
> greater than 24h).

Yes, but how would you use this to e.g. print only the time for all
emails received today, but print the date for all emails received
yesterday or earlier? A split point of 24h is no use. If it's currently
10am, say, then all mails since 10am the previous day will display the
time only. Whereas what's wanted is all emails since midnight to display
the time, and emails prior to midnight to display the date.

I don't think this can be done with the date_conditional patch as it
stands, because the split point would have to depend on the current time,
and I know of no way of putting that calculation into the date-format
string.

I just modified the time comparisons in my version of the
date_conditional patch so that an interval of 1 day implies fractions of
a day are discarded before comparing with the current time, an interval
of 1 month discards days and below, an interval of a year discards months
and below, etc.

This lets me display just the time for today's emails, the day and month
for this year's emails, and the full date for older emails. That way, I
can see at a glance which emails arrived today, which arrived this year,
and which are older than a year. (As opposed to which arrived within the
last 24h, which arrived within the last 30 days, which arrived within the
last 365 days.)

> > A while back, I wrote a modified version of the date_conditional
> > patch so that it could be used to produce different formats for mails
> > from today, from the current month, from the current year, etc. I
> > haven't gotten around to making it available online, but if you want
> > a copy I'd be happy to mail it to you.
> 
> That's what I want as well, but I do it by using date_conditional in
> conjunction with the more general nested_if patch. Nested_if, as its
> name suggests, lets you nest mutt's ternary conditionals arbitrarily
> deep.

Indeed, I use nested_if with my modified date_conditional patch.

Toby
-- 
Dr T. S. Cubitt
Mathematics and Quantum Information group
Department of Mathematics
Complutense University
Madrid, Spain

email: ts...@cantab.net
web: www.dr-qubit.org

Reply via email to