Boost logo

Boost :

From: Powell, Gary (powellg_at_[hidden])
Date: 2004-04-14 16:30:14


>Ummm, OK, you made it work, but why? Why would you want to be
>able to call add_month() on a date and have it always represent
>the day before the last day of the month?

  date d = August 30;

  // add six months.
  add_month(d); // September 30;
  add_month(d); // October 31?
  add_month(d); // November 30
  add_month(d); // December 31?
  add_month(d); // January 30
  add_month(d); // February 28/29
  add_month(d); // March 28? 29? 30? 31?

Just looking this there is no way to predict which
day of the month the last call is going to be. I'd find
it surprising that

  (d + year) != (12 * months) + d;
  

I think you are looking for a simplistic function for a complex
problem. IMO its a trap for the unwary and should be called out
as such.

I can see the need for LAST, but my contention is that its not
enough information to do the least surprising thing.

The easiest way to resolve this is to either write a FAQ, and or
have a dumb rounding month adding function that can screw up the
dates for those times when "meet you next month" is the right answer.

  Yours,
  -Gary-


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk