|
Boost Users : |
Subject: [Boost-users] DateTime library - how to count "working days"?
From: qplace (admin_at_[hidden])
Date: 2014-05-10 11:14:59
I need to find a day that stands 30 working days from a specific date,
ignoring holidays. Currently I am doing it like this:
boost::gregorian::date lastdate;
int maxdays(30);
for (int i = maxdays; i != 0; --i)
{
// skip weekends
gregorian_calendar::day_of_week_type dow = lastdate.day_of_week();
while ( (dow == Sunday ) || (dow == Saturday) )
{
lastdate -= boost::gregorian::date_duration(1);
dow = lastdate.day_of_week();
}
lastdate -= boost::gregorian::date_duration(1);
}
I did not find the iterator that can do it cleaner, but may be there is one?
Thanks.
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