Bug 13368 – std.datetime.monthToString should be public

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-08-24T15:39:00Z
Last change time
2015-06-09T05:14:58Z
Assigned to
nobody
Creator
kevin.lamonte

Comments

Comment #0 by kevin.lamonte — 2014-08-24T15:39:43Z
I am implementing a logging library and need to convert DateTime.month to a 3-letter month abbreviation, e.g. 0 --> "Jan". monthToString (which is used by toSimpleString()) already has this functionality. Note that to!string(DateTime.month) returns a fully-lowercase month name, which is not what I need. Making monthToString public would also give one easy access to "January", "February", etc.
Comment #1 by issues.dlang — 2014-08-24T16:51:18Z
Sorry, but it was decided some time ago, that nothing in std.datetime which deals with English would be made public, because that opens the question of internationalization, and std.datetime is not the place for that. In addition, IMHO, it was a mistake to include any of the functionality in std.datetime which involves the names of months in strings (in particular toSimpleString and fromSimpleString). It's an unnecessary and not particularly useful complication, and it results in questions about internationlization. So, we're not about to expose any of the functions that deal with English. If you see any functionality in there that you want that is not public, feel free to copy it into your own codebase. It's boost licensed, whose only restriction is that the code is supposed to retain the copyright. And for something this small and simple, I don't even care if you do that, and I wrote the code.
Comment #2 by kevin.lamonte — 2014-08-24T23:18:47Z
Fair enough. My library is also Boost 1.0 licensed, all I took was the shortMonthNames array. Is the plan to eventually have localization support in Phobos, and then deprecate toSimpleString()?
Comment #3 by issues.dlang — 2014-08-24T23:38:01Z
Well, I'd love to just deprecate toSimpleString, since it's not a standard format (it comes from Boost, not something like ISO), and it increases confusion, but doing so would break code (even if it wouldn't be immediately, thanks to the deprecated keyword), so I don't know if I'd be allowed to deprecate and remove it or not if I tried. I'll probably try one of these days though (probably after I split std.datetime into a package), since I definitely think that it was a mistake to have it, and I don't think that anyone should be using it. That would probably go over better though once I've done custom time format support, but that's also in line after splitting std.datetime, which I will hopefully get to over the next month or so, but I'm changing jobs and moving at the moment, so that will probably delay things. In any case, toSimpleString will probably go away at some point, but it may not to avoid forcing folks to change their code to avoid having it broken. As for internationalization, it would be very cool for it to be in Phobos, but that's a pretty big endeavor. If there were a good cross-platform C/C++ library which did it well, we might have a wrapper for it in Phobos, but someone would have to care about it enough and have enough time to spare to actually put forth the effort to implement it and get it through the review process and get it into Phobos. And no one has done that yet. There's nothing really stopping it AFAIK except for that.
Comment #4 by issues.dlang — 2014-08-24T23:42:41Z
The custom time format stuff will probably have some internationalization, since there are standard C functions which support it (at least for the local time zone as opposed to English specifically), but full-blown internationalization is another beast entirely.