Precisely. 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".
Ambiguous 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.
Why 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?
Re:Idea for date formatting strings
by InclinedPlane on Tuesday July 13, 2010 @05:41PM
(#1512865)
You'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.
Re:Idea for date formatting strings
by CoryMathews on Tuesday July 13, 2010 @04:12PM
(#1512561)
and when I forget "man strftime"?
Also, date format strings are pretty standard. If you ever forget them, just type `man strftime` at the command line.