
From: "Jeff Garland" <jeff@crystalclearsoftware.com>
Bottom line, if you want reversability at the date level everything needs to be done in terms of days and weeks.
Right.
5) Implementing LAST-1, LAST-2, etc At the very beginning of this thread I agreed that having functions like: date d(...);//arbitrary date date fd = first_date_of_month(d); date ld = last_date_of_month(d);
would be valueable additions. LAST-2 can be trivially implemented for fully specified dates as follows:
days_before_end_of_month(const date& d, days days_before) { return last_date_of_month(d) - days_before; }
That generates such a date, but doesn't carry the "n days before the end of the month" concept along with it. That is, the idea was to apply the concept to any month and year pair to get "n days before the end."
However, it might be useful to have another date generator which would not require a full date and could represent the last day of the month variants. I'm thinking something like:
last_day_of_month ldom; date d = ldom.getDate(2003, Feb); //feb 28 before_last_day_of_month ldom(2); date d = ldom.getDate(2003, Feb); //feb 26
That provides the means to overload the date ctors with the concept. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;