From: Sam Roberts Date: 2004-03-21T04:25:35+09:00 Subject: Re: bug in Time, it wraps some dates to next month Quoteing hal9000@hypermetrics.com, on Sun, Mar 21, 2004 at 04:04:47AM +0900: > Sam Roberts wrote: > >Maybe this is a feature, but I don't think so: > > > >[ensemble] ~/p/ruby/src/ruby $ ./ruby -e "p Time.local(2004, 'feb', 31, 1, > >1, 1)" > >Tue Mar 02 01:01:01 EST 2004 > > > >So it wraps into the next month if the day-of-month is past the end of > >the month. Arguably a feature. > > > >But: > > > >[ensemble] ~/p/ruby/src/ruby $ ./ruby -e "p Time.local(2004, 'feb', 32, 1, > >1, 1)" > >-e:1:in `local': argument out of range (ArgumentError) from -e:1 > > > >It doesn't do it if the day-of-month is past 31? > > > >So, I think it is a bug, not a feature. > > > >[ensemble] ~/p/ruby/src/ruby $ ./ruby --version > >ruby 1.8.1 (2004-03-20) [powerpc-darwin] > > I think (correct me if I'm wrong) this is related to the traditional > behavior of the underlying C libraries. You're correct that mktime() allows outofrange values (I didn't know that, is it standard?), an example from my man page is For example, October 40 is changed into November 9, But the second example shows Time doesn't allow this traditional usage! Cheers, Sam