On Fri, 15 Aug 2003, Thomas Klausner wrote: > I'm getting strange results when subtracting dates from one another: > > I make a new $dt object, setting the date to e.g. 2003-05-31. If I subtract > one month, I do not get 2003-04-30, but 2005-05-01, which seems wrong to me. > > This problem only occurs in months with 31 days, exept August, which works. > > March gives even stranger results. > > I attached a small script illustrating the problem. > > It's either a bug (if it is I could try to track it down more closely), or > I'm doing something dumb (in which case I'd appreciate some advice...) > > I'm using DateTime-0.1601 and perl.5.8.0
The results are actually consistent with the internal logic, but definitely surprising for end users. If you add "end_of_month => 'preserve'" it does what you are wanting. I wonder if we shouldn't make preserve the default EOM mode when the duration is negative? -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/
