From: Jeff Garland (jeff_at_[hidden])
Date: 2004-04-25 16:33:19
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:
some_month_type x(2004, Jun);
But we already have date_period for this:
date start_of_month(...), end_of_month(...);
date_period dp(start_of_month, end_of_month);
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, ...
ps: And where I live you can bank on June being hot :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk