The article is making two somewhat unrelated complaints: 1. Date.iso8601 does not correctly parse some ISO 8601 formats like ordinal dates or month-only dates. 2. The Date class does not support year-only or year/month granularity. In response to the first, the documentation for Date.iso8601 ( http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#... ) says: "Creates a new Date object by parsing from a string a…
Ruby 1.9 doesn't implement ISO 8601 properly
21–30 of 50 posts
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#22The article is making two somewhat unrelated complaints: 1. Date.iso8601 does not correctly parse some ISO 8601 formats like ordinal dates or month-only dates. 2. The Date class does not support year-only or year/month granularity. In response to the first, the documentation for Date.iso8601 ( http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#... ) says: "Creates a new Date object by parsing from a string a…
of course you can compare them (4 states: before, after, same, overlapping). you cannot put them into an order. that's something different.
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#23Maybe it's rfc3339 and not iso8601? e.g. the method has been named wrong?
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#24The article is making two somewhat unrelated complaints: 1. Date.iso8601 does not correctly parse some ISO 8601 formats like ordinal dates or month-only dates. 2. The Date class does not support year-only or year/month granularity. In response to the first, the documentation for Date.iso8601 ( http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#... ) says: "Creates a new Date object by parsing from a string a…
Maybe a Date should be a Range of Time? Even a specific date is a 24h interval.
However, I strongly agree that ranges of time are a very useful concept, and I spent a lot of time implementing Range Types[1] in postgresql for that reason. I think Ruby should have both ranges of time and points of time (and ideally work with the SQL counterparts seamlessly).
[1] http://www.postgresql.org/docs/9.2/static/rangetypes.html
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#25I think it would make the point much clearer if the author of that article would actually explain a use case for this (apparently incorrectly handled) syntax which I have never ever come in contact with :).
Well the point is that they shouldn't call the method iso8601 if it doesn't implement the whole iso8601 standard
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#26So do tons of other libraries and PL standard libraries. jodatime in Java, moment.js, JS' Date object, python's datetime stdlib module, python-dateutil etc. ISO-8601 is actually quite a difficult standard to program for. 9 out of 10 times, these libraries either don't support just year, year-month, or both. 9 out of 10 times, when a datetime object is formatted to a string, you see inconsistencies about that dangling…
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#27If I understand correctly, the complaint is that: ISO 8601 defines ####-## to be a year and month only, and it should have the granularity of a month; but Ruby treats it as an ordinal date.
It seems like it could be said much more clearly with an example:
irb(main):011:0> Date.iso8601("2012-12")
=> #
It's treating ####-## as an ordinal date, when the standard says that it's a month-granularity date.Re: Ruby 1.9 doesn't implement ISO 8601 properly
#28The article is making two somewhat unrelated complaints: 1. Date.iso8601 does not correctly parse some ISO 8601 formats like ordinal dates or month-only dates. 2. The Date class does not support year-only or year/month granularity. In response to the first, the documentation for Date.iso8601 ( http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#... ) says: "Creates a new Date object by parsing from a string a…
This case seems like an outright violation, however. If the standard says that ####-## is a year-month date with month granularity, and you interpret it as an ordinal date, then that's a clear violation. It means that others communicating with you won't just get an error, they will get the wrong answer, which is much worse.
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#29Not 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.
Re: Ruby 1.9 doesn't implement ISO 8601 properly
#30I think it would make the point much clearer if the author of that article would actually explain a use case for this (apparently incorrectly handled) syntax which I have never ever come in contact with :).
Well the point is that they shouldn't call the method iso8601 if it doesn't implement the whole iso8601 standard
Parsing it incorrectly is bad news.