3 ms·
Most people, for their entire career, should literally never write out a date/time-format string. Even once. If you want ISO8601, use that constant, don't wri
by Groxx 8y ago
Most people, for their entire career, should literally never write out a date/time-format string. Even once. If you want ISO8601, use that constant, don't write it out.
Use pre-defined formats, like 8601, 3339, Long, Short, etc. Or datetime skeletons if your system supports it and you MUST do something non-standard, and even then do a day or three of research before typing the first letter. Basically nothing else is even remotely acceptable for internationalization (and whatever the "intercalendarization" equivalent would be) and stands a good chance to get even the extreme basics like "yyyy" wrong.
- paulryanrogers 8y agoIIRC, ISO8601 isn't a single constant, fixed format. It's a variety of optional representations that generally follow the rule least-to-most specific. For example 19991231 would be as valid as 1999-12-31.
- Groxx 8y agoYeah, good point on 8601. But that's even more of a reason to use a pre-defined 8601-parser/printer/whatever instead of a hand-written format string. If you're using 8601 for an interchange format... don't. But if you're forced to emit a hard-coded format for whatever consumer can't be forced to do things sanely, this would be one of those exceptions to "most people". And it should immediately stop after that exception.
- bmn__ 8y agohttps://tools.ietf.org/html/rfc3339 https://tools.ietf.org/html/rfc3339 exists as a profile of ISO 8601 for precisely that reason, its representations are much more restricted.