RE: [boost] Re: Date-Time

From: Jody Hagins <jody-boost-011304@atdesk.com>
"Powell, Gary" <powellg@amazon.com> 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.
I'd expect March 30th.
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.
I understand what you think you want but in practice I don't think it would work out as nicely as you think now.
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.
Ok, but you need more than just LAST, you need LAST-1, LAST-2, and LAST-3 That's why I use seconds..
date = February 28; add_month(date);
you would want March 28, and not March 31???
Yes.
I would expect this as well. the 28th is either LAST, or just plain old 28th. Personally I like Jeff's solution, that you provide the increment function. Because it sounds like we have different use cases for "next month" The loose case of "see you for your next appointment next month", and "delivery is in One Month". Where 30 days is the "next month" vs the calendar end. Yours, -Gary-

From: "Powell, Gary" <powellg@amazon.com>
From: Jody Hagins <jody-boost-011304@atdesk.com>
"Powell, Gary" <powellg@amazon.com> wrote:
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.
Ok, but you need more than just LAST, you need LAST-1, LAST-2, and LAST-3
Why? I can't imagine a good use case for wanting one, two, or three days before the end of the month as a special form of date.
That's why I use seconds..
You still have to make them useful to humans for I/O.
date = February 28; add_month(date);
you would want March 28, and not March 31???
Yes.
I would expect this as well. the 28th is either LAST, or just plain old 28th.
Right. I took that example to mean it was the 28th day of the month of February. That is happened to be the last day of the month is irrelevant. The "LAST" or "END" form is quite separate.
Personally I like Jeff's solution, that you provide the increment function. Because it sounds like we have different use cases for "next month" The loose case of "see you for your next appointment next month", and "delivery is in One Month". Where 30 days is the "next month" vs the calendar end.
Yes, but I think it is reasonable for the library to provide one or two implementations and even make one the default. If the opportunity to customize the behavior exists, you've provided for the other cases. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
participants (2)
-
Powell, Gary
-
Rob Stewart