From: Val Samko (boost_at_[hidden])
Date: 2004-04-12 01:59:36
Sunday, April 11, 2004, 4:01:02 PM, you wrote:
JG> Hmm, point taken. That said, if I add this to the library people will
JG> (correctly, I think) expect the following:
JG> date d1 += months(3);
JG> date d2 = d1 - months(2);
JG> date d3 -= months(2);
JG> date d3 = d3 + months(-2);
JG> to work correctly. The code we have sketched so far won't handle this
JG> correctly. Going even further, I don't see why the following isn't allowed:
JG> ptime t1(d1); //d1 at midnight
JG> t1 = t1 + months(2);
JG> And I think this same logic applies to 'years' and 'weeks' as well. This
JG> would finally unify the arithmetic concepts in the library -- not to mention
JG> make an awful lot of date calculation code very clean.
The main problem I see with this syntax is that
d + months(MONTHS) + DAYS;
is not equivalent to
d + DAYS + months(MONTHS);
and I sometimes this might lead to the error prone code. This is why
I prefer to use add_month function.
>> Anyway, I think, three namespace level functions would be sufficient.
JG> As you can see, I have a slightly grander plan, but it should be compatible
JG> with your needs. Do you want these functions in CVS now or are you going to
JG> patch your release for now?
I'm currently using my home grown date classes. I will switch to
the Date-Time, once these changes will be available in the boost release.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk