|
Boost : |
From: Rob Stewart (stewart_at_[hidden])
Date: 2004-04-14 10:49:59
From: Jody Hagins <jody-boost-011304_at_[hidden]>
> "Powell, Gary" <powellg_at_[hidden]> wrote:
>
> > That would surprise me as well.
> >
> > date = January 30;
> >
> > add_month(date);
> > add_month(date);
> >
> > date == March 30 ? Not March 28/29 No?
I'd expect April 1st or 2nd, depending upon whether it was a leap
year. I'm not sure what you're saying you'd expect.
> > Which means of course a lot of state has to be held by date, because
> > otherwise February does rounding. As in the number of days until the
> > end of the month.
For my expected result, it would simply increment the month and
then check for the corresponding day of the month. If it's past
the end of the month, it falls back to advancing by 30 days.
Then, the logic is repeated by the second call.
> Or, instead, you use something like...
>
> date = January END or LAST;
>
> meaning the last day of the month. Then, adding a month would always
> jump to the last day of the next month. I imagine with...
That would work well.
> date = February 28;
> add_month(date);
>
> you would want March 28, and not March 31???
Yes.
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk