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.
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@lists.boost.org 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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Larry
-
qplace