Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-04-19 13:11:48


From: David Abrahams <dave_at_[hidden]>
>
> That said, I'd really like to de-emphasize the importance of this
> clipping behavior. We already have a plausible way to represent a

Agreed.

> particular month, e.g. Feb/2003. I'd like to be able to write:
>
> 30/(Feb/2003 + 3*month)
>
> To get 30/May/2003.

I like it, but I'm not sure I'm seeing in that what you meant. If
May were an enumerator of type boost::gregorian::months, or
whatever, then:

   day_and_month
   operator /(greg_day, months)
   { return day_and_month(greg_day, months); }

   date
   operator /(day_and_month d_m, greg_year y)
   { return date(y, d_m.month, d_m.day); }

   date
   operator /(greg_day d, month_and_year m_y)
   { return date(m_y.year, m_y.month, day); }

   month_and_year
   operator /(months, greg_year)
   { return month_and_year(months, greg_year); }

plus operators for adding 3*month to a month_and_year should
allow:

   date d(30/May/2003);
   d = 30/(Feb/2003 + 3*month);

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk