Proposal for custom time string formatting in std.datetime

Stewart Gordon smjg_1998 at yahoo.com
Fri Dec 23 02:26:05 PST 2011


On 23/12/2011 04:05, Jonathan M Davis wrote:
<snip>
> I mean that you have to be way more careful about how you name the flags. For
> instance, if you have
>
> MMM
>
> and
>
> Month
>
> you have issues with stuff like MMMonth.

To quote directly from the spec of my scheme:
"Each specifier is a letter, or two or more of the same letter consecutively (picked out 
by maximal munch before lookup in the following table)."
So this is a non-issue.

> It can definitely work, but the more
> flags that you have, the more problematic it becomes. It's also easier to
> separate out consecutive flags when reading them if you have %.

Here's the little bit of code in my library that finds the end of a flag:

     char letter = cast(char) std.ctype.tolower(*charPos);
     CPtr!(char) beginSpec = charPos;

     do {
         ++charPos;
     } while (std.ctype.tolower(*charPos) == letter);

Seems to me pretty straightforward.

>>> 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?
>
> It's harder to have modifiers for flags without the %. For instance, what I'm
> doing with filler characters would be much more difficult with your scheme. With
> % delineating the flags, it becomes easier to handle that sort of thing.
<snip>

What are you doing with filler characters?  It appears to me, just allowing space or 0 as 
a filler character in some flags.  In my system, alignment fields provide a more powerful 
way of doing the same thing.

Stewart.


More information about the Digitalmars-d mailing list