
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 -- 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); x.contains(d); But we already have date_period for this: date start_of_month(...), end_of_month(...); date_period dp(start_of_month, end_of_month); dp.contains(d); 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, ... Jeff ps: And where I live you can bank on June being hot :-)