From: David Abrahams (dave_at_[hidden])
Date: 2004-04-25 17:43:03
"Jeff Garland" <jeff_at_[hidden]> writes:
> On Sun, 25 Apr 2004 17:03:18 -0400, David Abrahams wrote
>> >> So maybe a new type should be made that just represents year &
>> >> month. Every year still only has 12 months. Of course, your
>> >> problem comes back if you want to mix days in.
>> > Exactly, and I don't know what I would do with this type without mixing them
>> > back in...
>> if (some_date.is_in(Jun/2004))
>> std::cout << "that's a hot one!";
> You didn't need to invent a type to do this
The type is that of Jun/2004
> -- you just added a function to the date. You would have to
> reverse it to be what Daryle is suggesting:
> date d(...);
> some_month_type x(2004, Jun);
I don't see how they differ, where types are concerned. You just
changed how the function is invoked.
> But we already have date_period for this:
> date start_of_month(...), end_of_month(...);
> date_period dp(start_of_month, end_of_month);
That looks painful, though I don't neccessarily understand it.
> So why not a date_period generator function instead?
> date_period make_month_period(greg_year y, greg_month m);
> Then it would be:
> date_period dp = make_month_period(2004, Jun);
> if (dp.contains(d)) // or is_after, is_before, ...
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com