3 ms·
Not only that, but ISO 8601 also allows you to just specify the year, but Date.iso8601("2012") raises an ArgumentError "invalid date". Nor does it support "week
by petercooper 14y ago
Not only that, but ISO 8601 also allows you to just specify the year, but Date.iso8601("2012") raises an ArgumentError "invalid date". Nor does it support "week dates", Date.iso8601("2012-W01") raises an ArgumentError too.
I don't know the standard, but either Wikipedia is wrong or the Date implementation is sorely lacking.
- tommorris 14y agoYep. There's a lot more problems than that. I've been reading the source code of one ISO 8601 implementation in JavaScript and writing my own in Java. Looks like I'll have to fix the Ruby one too. Given that it's used by, oh, HTML and XML, not properly implementing ISO 8601 is really no big deal.</sarcasm>
- eli 14y agoIt may well be lacking in completeness, but I bet it covers over 99% of actual real-world ISO8601 dates. When was the last time you ran across a "week date"?
- lobster_johnson 14y agoVery common in Europe, where businesses often operate relative to weeks; we frequently use week numbers for that reason (an abomination in my opinion). Ruby has decent but not great support for ISO week numbers.
- tommorris 14y agoYep, an example: I edit OpenStreetMap. The opening_hours property allows one to represent a wide range of opening hours. https://wiki.openstreetmap.org/wiki/Key:opening_hours https://wiki.openstreetmap.org/wiki/Key:opening_hours A lot of public parks in London are open at different times during summer and winter. Here's an example I added personally, the churchyard of St Anne's Church in Soho. http://www.openstreetmap.org/browse/way/40879988 http://www.openstreetmap.org/browse/way/40879988 "week 1-13 Mo-Su 10:00-16:00; week 14-43 10:00-18:00; week 44-52 10:00-16:00"