On Sat, Jan 24, 2004 at 06:28:38PM +0000, Gavin Kistner wrote:
> I myself am a fan of the way Javascript handles invalid dates. For example:
I like the fact that Date provides both an interface that
raises an exception if a value is out of range, and one (albeit
a trickier one) that handles such numbers transparently:
irb(main):001:0> require 'date'
=> true
irb(main):002:0> Date.new(2003,9,31)
ArgumentError: invalid date
from /usr/lib/ruby/1.8/date.rb:591:in `new'
from (irb):2
irb(main):003:0> puts Date.jd(Date.civil_to_jd(2003,9,31))
2003-10-01
=> nil
Because sometimes you want to know that a date is invalid, instead of
getting November 30, 1 BC because someone entered all zeros. :)
-Mark