[phobos] User define datetime format
Jonathan M Davis
jmdavisProg at gmx.com
Mon Jun 6 21:05:59 PDT 2011
On 2011-06-06 20:41, Jose Armando Garcia wrote:
> On Tue, Jun 7, 2011 at 12:03 AM, Andrei Alexandrescu <andrei at erdani.com>
wrote:
> > Jose,
> >
> >
> > I suggest you use simple Posix positional parameters. Jonathan has a few
> > tips on how to make that fast. You should be able to get many formats
> > that way.
>
> I am planning to use positional parameters internally but I didn't
> want the user to have to remember that %1$s is for timestamp, %2$x is
> for thread id, etc. So instead I was thinking of having the user input
> "%t %i" which internally gets translated to "%1$s %2$x" (I already
> have the code for this).
>
> %t would map to SysTime.toISOString(). If they wanted to create a
> custom date/time format they use "%{...}t". So, for example "%{%a, %d
> %b %Y %T %z}t" would result in "Tue, 07 Apr 2011 00:36:04 +0000".
I would suggest that you either use toISOExtString or toString/toSimpleString
rather than toISOString, because toISOString is nigh-on-unreadable. It's more
compact, and it's standard, but no one is going to want to read it.
toString/toSimpleString would be the easiest to read, but it isn't standard.
toISOExtString is standard and somewhat readable, so take your pick. But I'd
advise against toISOString unless you're specifically going for compactness
over legibility.
- Jonathan M Davis
More information about the phobos
mailing list