|
Boost Users : |
From: kingos_at_[hidden]
Date: 2006-08-31 22:51:07
I am hoping to use boost::date_time to do some date calculations. What I want to do is
basically work out the number of days to a given date with various exclusions applied.
eg.
How many working days are there to christmas?
using namespace boost::gregorian;
int CalculateDaysToChristmas()
{
date_period someHoliday(date(2006, Dec, 01), date_duration(1));
date today(2006, Sep, 1);
date christmas(2006, Dec, 25);
int days = 0;
for (day_iterator i = today; i != christmas; ++i)
{
if (is_weekday(*i) && !someHoliday.contains(*i))
++days;
}
return days;
}
However, I can't find a simply way to work out is_weekday ...
Secondly, is there some way to put every sunday in as a date_period?
Thirdly, this doesn't seem very optimal ... is there a better way of doing this?
Thanks,
Andrew
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