Boost logo

Boost Users :

Subject: Re: [Boost-users] DateTime library - how to count "working days"?
From: Larry (lknain_at_[hidden])
Date: 2014-05-13 10:23:16


Did you look at the date period calculation example? It has been a long time
since I looked at it but I believe it does, at least in part, what you want.

Larry

-----Original Message-----
From: qplace
Sent: Saturday, May 10, 2014 11:14 AM
To: boost-users_at_[hidden]
Subject: [Boost-users] DateTime library - how to count "working days"?

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 mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


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