Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2002-10-21 14:18:59


> I have a question about usage. Say i have a date such as
>
> using namespace boost::gregorian;
> date vl_Date_date(2002, Feb, 03);
>
> I would like to define a date_period such that the date is within that
> period. But further I would like this period to cover exactly the month in
> which the date exists. I had a look at some of the examples etc but could
> not see a stright forward way of doing this. Is it just me?

I haven't compiled this, but something like this should work:

greg_year year = v1_Date_date.year();
greg_month month = v1_Data_data.month();
greg_day end_of_month = gregorian_calendar::end_of_month_day(year,month)
date_period dp(date(year, month,1), date(year, month, end_of_month));

> Also, if i have a date_period object, how do i find out the duration of the
> period?

Hmm, this function should probably be added to the period class. In
the meantime this should work:

date_duration dd = dp.end() - dp.begin();

Jeff


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net