Modifying {isodate} to include seconds?

Giorgos Keramidas keramida at ceid.upatras.gr
Mon Mar 17 12:09:48 CDT 2008


On 2008-03-17 12:02, Matt Mackall <mpm at selenic.com> wrote:
>On Mon, 2008-03-17 at 17:49 +0200, Giorgos Keramidas wrote:
>> I just noticed that {date|isodate} does not include seconds in our
>> templater.
>>
>> $ pwd
>> /home/keramida/hg/mercurial/crew/mercurial
>> $ fgrep isodate *
>> templatefilters.py:    "isodate": lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2'),
>> $
>>
>> Is it ok to modify this template to include the seconds?
>
> Ugh. That might break stuff. We may need to add an isodatesec.

You are right.  We will definitely have to update the Mercurial test
suite, if we change this (I'm doing it as I type this message).

'isodatesec' is an easy change, I guess.

> Alternately, we can come up with a scheme to pass arguments to
> formatters, eg:
>
> {date|datefmt(%Y-%m-%d %H:%M:%S %1%2)}
>
> ..which will give us a lot more flexibility.

I've thought about this too, but the templater is a bit beyond my Python
foo to handle.  It may be a bit ambiguous to use {date|datefmt(...)} for
example.  The templater would have to include lookahead, to see if the
next template in a row is a new {function} or arguments to the previous
function.  Then it would be tempting to keep chaining `options' like:

  {date|datefmt(%Y-%m-%d %H:%M:%S %1%2)|datezone(UTC)|firstline}

I'm not sure how useful this would be, but it would probably increase
the complexity of the templater even more :(



More information about the Mercurial-devel mailing list