
"Janusz Piwowarski" <jpiw@go2.pl> writes:
Rob Stewart writes:
That makes the result of the expression quite explicit. I can't see any problems with that approach. I'd expect an exception if the resulting month doesn't have the requested day. OTOH, if date's ctor were to take an extra argument, or if there was a date factory function supplying the different behavior, you could specify that you want clipping to the last day of the designated month:
date(d.month() + 2 * months, d.day(), clip_to_eom) make_date_clipped_to_end_of_month(d.month() + 2 * months, d.day())
IMHO, simple date wrappers can give more readability:
d.allow_clipping_to_eom() + 2*months; d.disallow_clipping_to_eom() + 2*months;
or
allow_clipping_to_eom(d) + 2*months; disallow_clipping_to_eom(d) + 2*months;
where adding months to date directly isn't allowed.
That said, I'd really like to de-emphasize the importance of this clipping behavior. We already have a plausible way to represent a particular month, e.g. Feb/2003. I'd like to be able to write: 30/(Feb/2003 + 3*month) To get 30/May/2003. Cheers, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com