Re:Idea for date formatting strings
by defrex on Tuesday July 13, 2010 @05:28PM
(#1512818)
To remove ambiguity, you could say months should be represented by December, days by the 31st, weeks by Friday, and so on. In that way it would be easy to implement and easy to write to. Then the case of "01-01-01" becomes "31-12-99", for example. Still easy to read, still easy to implement.
[ Parent
| on HN ]
This removes a lot of flexibility, which is the whole point of date format strings. "31st" doesn't give you the choice to print just the number, or the number and its ordinal suffix ("-st," "-rd," etc.). Also, preferably "Friday" should stand for the day, not the week. :)
All of the things you say can be had by doing things grandparent's way with minor tweaks.
But then you're left with essentially the standard php date format, except instead of one-letter tokens, they're all longer.
But concrete and equal in all languages, which is the point of the OP.
the strftime format is an open standard that's already the same in all languages.
Re:Idea for date formatting strings
by InclinedPlane on Tuesday July 13, 2010 @05:36PM
(#1512849)
I like this idea.
Pick some date that is perfectly suitable to using in an example formatted date such that the format can be inferred from the example (for all reasonable formats). I propose: 1:23:45pm, Friday, December 31st, 1999, which has the advantage of making it easy to determine whether am/pm should be used or 24h time.