5 ms·
Great in theory, but in practice it would be really tough to implement. A lot of assumptions would be made. For example, what should "01-01-01" be interpreted a
by theli0nheart 16y ago
Great in theory, but in practice it would be really tough to implement. A lot of assumptions would be made. For example, what should "01-01-01" be interpreted as?
Also, date format strings are pretty standard. If you ever forget them, just type `man strftime` at the command line.
- CoryMathews 16y agoand when I forget "man strftime"?
- d0m 16y agogoogle date formating (and please, no "if I forget google")
- powrtoch 16y agoPrecisely. Ultimately, no one is going to use a language where there's no way to output a date in a form that will be sometimes ambiguous. And how often do you really even find yourself printing totally unambiguous time stamps? For my part it's way more likely that I'll output "2-11-2009" than "Monday, January 1st 2004 10:43 EST".
- jacabado 16y agoAmbiguous example formatting strings would give an error, as an invalid one does now. I like the proposal, although localization is an issue as the examples would have to be in a concrete language. Removing unneeded abstractions is positive, specially if you have to deal with conflicting models.
- galdosd 16y agoWhy would 01-01-01 be a problem? If you're writing a format string in this "format string by example" scheme, you don't have to be able to express every possible date-time in it, just a single chosen one. Or perhaps force the choice of a particular (memorable) date-time, such as January 2nd, 2000, 3:04 am and 5 seconds?
- InclinedPlane 16y agoYou're letting perfect be the enemy of the good. If you can't unambiguously determine the format from the example, kick it back to the user and ask for a better example. Easy peasy. As it turns out, users are incentivized to give good examples because they want to get work done. They won't provide "01-01-01" as an example unless they want to waste their own time.