> [EMAIL PROTECTED]: > > Why not: > > > > $dur1 = new DT::Dur( days => 2 ); > > $dur2 = new DT::Dur( months => 1 ); > > $dur3 = $dur1 - $dur2; > > $dur3->add( days => 3 ); > > > > If you add $dur3 to a date, it would add 2 days and > > subtract a month, then add 3 days again. > > I love that this "does the right thing". However, I don't see why it cannot be > built into the constructor using negative values. > > The real snag is ordering, but this can be handled properly within the > constructor (and adequately documented, not only for the constructor but for the > general case). > > So, yes, the implication is that: > > $dur = DT::Dur->new(days => 2, months => -1); > > would indeed behave differently than: > > $dur = DT::Dur->new(months => -1, days => 2); > > So long as the behavior (intrinsic to durations) is well documented I think it > stands to save lots of typing later.
The idea is to use: $dur = DT::Dur->new(months => -1); $dur->add(days => 2); or $dur = DT::Dur->new(months => -1)->add(days => 2); because the intention is more clear, I think. - Flavio S. Glock
