On 22/12/2011 03:41, Jonathan M Davis wrote:
<snip>
Stewart Gordon has a library that takes a different approach (
http://pr.stewartsplace.org.uk/d/sutil/datetime_format.html ). It does away
with % flags and uses maximul munch with each of the flags being name such that
they don't overlap in a way that would make certain combinations of flags
impossible.

If you mean such things as writing a datum twice consecutively in two different formats, it can be done using an empty literal. For example, "Mmm''m" would today generate "Dec12". Not that I can see any use for such a format, just showing that it can be done.

It then requires that characters which are not part of the flags be
surrounded by single quotes.

Wrong. It requires _letters_ that aren't flags to be literalised, and that can be done either by surrounding with '...' or by prefixing with `. Other characters that have no meaning are automatically literal.

It's an interesting approach, but it isn't as
flexible as it could be because of its use of maximul munch instead of % flags.

How do you mean?

So, I've come up with something new which tries to take the best of both. On
the whole, I think that it's fairly straightforward, and the flags are
generally recognizable and memorable (though there are a lot). It's also
definitely extremely flexible (e.g. you can pass it functions to generate
portions of the string if the existing flags don't get you quite what you
need). But I'd like some feedback on it before I spend a lot of time on the
implementation.

This page has the docs for std.datetime with everything else but the proposed
custom formatting functions for SysTime stripped out of it:

http://jmdavis.github.com/d-programming-language.org/std_datetime.html

Looks complicated compared to mine at first sight. Maybe I just need to spend a bit of time looking at it in more detail.

Stewart.

Reply via email to