On Wednesday, December 20, 2017 21:36:00 bauss via Digitalmars-d-learn wrote: > On Wednesday, 20 December 2017 at 18:50:37 UTC, Jonathan M Davis > > wrote: > > On Wednesday, December 20, 2017 14:30:55 bauss via > > > > Digitalmars-d-learn wrote: > >> I can't seem to find anything in Phobos that allows you to > >> specify custom formats for dates. > >> > >> Am I on my own or is there already such functionality? > >> > >> I'm interested in a formatter with the possibility to output > >> ex.: > >> > >> December 20th, 2017 10:00 AM > >> > >> All I could find was toSimpleString(), but it seem to use a > >> pre-defined format like: > >> YYYY-Mon-DD HH:MM:SS > > > > At present, the only formats that Phobos supports are ISO, ISO > > Extended, and Boost's simple time format. It does not yet have > > support for custom date/time formatting beyond constructing the > > string yourself from the properties on a DateTime or SysTime. > > > > This was posted about recently in the Announce group though: > > > > http://code.dlang.org/packages/datefmt > > > > It might do what you want. > > > > - Jonathan M Davis > > Unfortunately I can't rely on any third-party packages for it :p > > But thanks anyway @ both of you. > > I'll write my own function to do it :)
Well, if you can't use a 3rd party package, I suspect that you'd have to write your own solution even if Phobos does finally get custom date/time formatting, because what you're trying to do includes "th", which is English-specific, and I'm not about to add localization/i18n stuff to std.datetime. One of the reasons that I regret porting Boost's simple time format over to std.datetime is that it includes English in it, which has occasionally resulted in localization requests, and i18n is really way too involved to put into Phobos. I expect that I'll get around to finishing custom date/time formatting for Phobos at some point, but it's not a high priority for me, and I have yet to come up with a scheme for defining the formatting that doesn't seem terrible to me. - Jonathan M Davis