5 ms·
It probably would have been better to use entirely different letters (xxxx instead of YYYY) to reduce sources of human error. Notwithstanding these small issue
by kstenerud 8y ago
It probably would have been better to use entirely different letters (xxxx instead of YYYY) to reduce sources of human error.
Notwithstanding these small issues, iso8601 is a godsend, but even with this spec it's amazing how many times we just get it plain wrong dealing with time. Time is hard! It gets even worse in binary formats, dealing with leap second tables, time zones, daylight savings, different epochs etc, which is why I developed the smalltime [1] format.
[1] https://github.com/kstenerud/smalltime https://github.com/kstenerud/smalltime
- rodionos 8y agoIn Java `x` is reserved for time zone offset: https://axibase.com/docs/atsd/shared/time-pattern.html#pattern-letters https://axibase.com/docs/atsd/shared/time-pattern.html#patte...
- colejohnson66 8y agoI thought you’re supposed to use Z for that? What’s the difference then?
- Izkata 8y agoThere's an example column on the link, it has to do with the exact formatting of the offset.
- kevin_thibedeau 8y agoZ is just shorthand for for offset +0.
- gpvos 8y agoThe Twitter bug in December 2014 was caused by using %G instead of %Y. So that won't help much. G comes before Y alphabetically, as does almost ant other letter...
- userbinator 8y agoG comes before Y alphabetically That's irrelevant. There's a comment I made on a discussion about this a while ago: https://news.ycombinator.com/item?id=17059958 https://news.ycombinator.com/item?id=17059958 It's sad that most people seem to put the blame on everything else except the developer --- who was simply not exercising any common sense nor thinking critically. There's a very good reason to how the format specifiers were assigned, and anyone who doesn't notice the pattern (and surprising deviations from it) has no one to blame but his/herself.
- acqq 8y agoBut what is relevant is that the manpage explanation is still "precise but misleading": http://manpages.ubuntu.com/manpages/cosmic/man3/strftime.3.html http://manpages.ubuntu.com/manpages/cosmic/man3/strftime.3.h... "The ISO 8601 week-based year (see NOTES) with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V). " It's still misleading in the sense: "do we want ISO standardized year? Hell yeah! We've found what we want." It induces all the wrong reflexes: is ISO datetime "the name of the most standard date format that can't be read wrongly? Yes. ( https://en.wikipedia.org/wiki/ISO_8601 https://en.wikipedia.org/wiki/ISO_8601 ) Is it "ISO 8601"? Yes. Do we get "four digit" "decimal" year? Yes. Hm... it's "week-based"? "Well every year has weeks, so I guess it's all right." Has references to some other part of documentation, "that means that the details probably don't matter much here." Etc. The proper documentation would be: "%G (short for "wronG in most use cases") returns the "week-number-based-otherwise-wronG-year" used only for the special number-of-weeks-based calendar representations, according to the ISO 8601 rules for such representations, and it only by accident sometimes looks like the common calendar year. Should not be used unless it's specifically needed to produce such a number-of-week-based calendar. For the details about these calendars see (the reference)." In the later case the "don't touch this unless you know you need exactly this" is explicit. It even gives a good mnemotechnic device for remembering the "wrongness" of using it in most of the cases. Good documentation is really important, even if the "traditional" -n-x users feel some kind of satisfaction in having the most misleading or useless documentation, to the point that when somebody asks some specific question they point to the very man pages which exactly don't answer that exact question (there are many such examples on the web). And I've personally seen exactly these same self-satisfied programmers behaving just like the users they subconsciously (or consciously) mock, that is, being equally clueless, once they are in front of any other, probably even a bit better manual, but for the topics they are not familiar with. Like setting up a darned printer. Being user hostile is never a virtue, and never something that should be supported or explained away.
- Moru 8y agoPeople complain a lot about PHP but it's not always horrible. Excerpt from the documentation: o - ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) (https://secure.php.net/manual/en/function.date.php https://secure.php.net/manual/en/function.date.php) We had this problem a long time ago when asp was used. We really needed this Year-week numbering but it didn't work. It was hard-coded to 52 weeks per year and the year was the true year. Someone had to manually fix it every few years when it didn't add up.