On Friday, April 20, 2012 13:29:34 H. S. Teoh wrote: > Is there a way to format std.datetime.Date objects with a custom format > string? In particular, I'd like to reuse month short names defined in > std.datetime, but it appears that the names are private. I'd really > rather not duplicate them by hand, if there's a way to get them. > > Alternatively, if there's a date formatting function that lets you use > strftime-like format strings, that would work too.
Such functionality does not currently exist. It was too much to design it on top of everything else when std.datetime was initially put up for review. There was a lot to it already. There has been some discussion on how to design the format strings ( http://forum.dlang.org/thread/mailman.1806.1324525352.24802.digitalmars- d...@puremagic.com ), but nothing has been actually added to std.datetime yet. My proposed format is very good, I think, but the examples that I chose were nasty enough that a number of people weren't all that happy with it. Stewart's proposal is more user-friendly for the basic stuff, but I don't think that it does as well with the more complicated stuff. I haven't decided what I'm going to do about it yet. It's on my TODO list. As for the month names, they're private and will stay that way. Really, they're an internationalization issue, and having them in the first place was already debatable (they're there primarily because of toSimpleString, which came from Boost and they almost didn't end up in there at all). Once the custom format string stuff has been sorted out, it will end up with a way to indicate that you want either the English abbreviations (which std.datetime currently uses) or the locale-specific ones, but that's the closest that you're ever going to get to have access to them without copying them yourself. - Jonathan M Davis