On Tue, 29 Jul 2003, Dan Sully wrote: > 0.13 2003-05-05 > > [ IMPROVEMENTS ] > > - DateTime now does more validation of parameters given to > constructors and to the set() method, so bogus values like a month of > 13 are a fatal error. > > I'm not entirely sure I'd call this an improvement.
This has been beaten to death in the archives, but once again for the record, it's going to stay like this. > my $month = 12; > > my $dt1 = DateTime->new('month' => $month, 'year' => 2002); > > print join(' ', $dt1->ymd(), $dt1->hms()) . "\n"; > > #### > > my $dt2 = DateTime->new('month' => $month + 1, 'year' => 2002, 'second' => > -1); > > print join(' ', $dt2->ymd(), $dt2->hms()) . "\n"; > > To get the beginning and ending times of a month: > > 2002-12-01 00:00:00 > 2002-12-31 23:59:59 > > How would one do this with >= 0.13 releases? my $dt1 = DateTime->new( month => $month, year => 2002 ); my $dt2 = $dt1->clone->add( months => 1 )->subtract( seconds => 1 ); There are several variations on the above that'd work. > This seems like useful functionality to me. No, it seems like a way to encourage people to write really weird code that doesn't really demonstrate their _intent_. The next person after you to read the code you posted will be sitting there think "second = -1, WTF?". If they read the code above, they'll think "datetime math, ok". -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/