tommorris.org

Discussing software, the web, politics, sexuality and the unending supply of human stupidity.


Ruby 1.9 doesn't implement ISO 8601 properly

Quelle surprise!

In Ruby 1.9, Date.iso8601("2012-12") == Date.iso8601("2012-012"). Why bother calling the method ISO 8601 if it isn’t actually ISO 8601 compliant?

2012-12 represents the twelfth month of 2012, December. 2012-012 represents the twelfth day of 2012, January 12. It doesn’t support year-only or year-month-only levels of granularity for dates, and treats year-month as an ordinal date.

Why is it doing this? Because it doesn’t support year-only or year-month granularity. Like everyone. Because they suck. Because they think that there is no reason why one would want to represent the concept of a whole month or whole year in data. Because they are programmers and programmers don’t do vagueness well. Because programmers seem to think that we wander around with microsecond-precision atomic clocks in our pockets.

(I hope Rails apps are doing input validation on date-times from user input.)

Of course, Date.iso8601("99-01-01") == Date.iso8601("1999-01-01"). It implements pre-Y2K two-digit dates…

One of these days, Tantek and I are gonna go all vigilante on the authors of date-time libraries.