[phobos] User define datetime format
Jonathan M Davis
jmdavisProg at gmx.com
Mon Jun 6 17:35:35 PDT 2011
On 2011-06-06 17:10, Jose Armando Garcia wrote:
> Hi Jonathan et al.,
>
> Is there any plan to add support for user define format string.
> Windows, Linux and MacOS define the following function:
>
> strftime -
> http://msdn.microsoft.com/en-us/library/fe06s4ak%28v=VS.100%29.aspx -
> http://linux.die.net/man/3/strftime
> - http://www.manpagez.com/man/3/strftime/
>
> I would like to add support in std.log to customize the date and time
> format in a log line and it would be great if this was supported by
> std.datetime. Support for the inverse function strptime would be nice
> too.
I do intend to add support for user-defined strings, but I'm pretty sure that
strftime isn't going to cut it. It makes assumptions based on the local time
zone, and I'm not sure that it'll work across the appropriate range of values
even in 64-bit (and it definitely won't in 32-bit, since you'll have a 32-bit
time_t). It's going to have to be designed and implemented in D. And the
difficulty of doing that is why I haven't done it yet.
The first issue is a matter of API - in particular the format string. What
does it accept? I have yet to look into the proper way to do that. If there's
a standard set of escape sequences for date-time strings, then that that's
what we should go with. But if there isn't, then I/we need to figure out what
the best solution is. It may be that following what strftime does would be the
way to go, but I don't know. And once that's figured out, then I have to
implement it, and I have no idea how long that will take.
If you think that you need it for std.log, then I can make it a higher
priority than I have, but it's not an easy problem. I've been putting it off
while I get other, more generally useful stuff done with the idea that custom
date-time formats are really more of a nice-to-have than a necessity.
- Jonathan M Davis
More information about the phobos
mailing list