Days difference between two dates using boost::date_time

Are there any APIs available in boost::date_time to get the number of days between two dates that is also calendar specific?

Example, Number of days between 2005/01/01 and 2006/12/31 would be 730 in a seven day calendar and would be 504 in a five day calendar.
501 days.

I presume you are talking about discounting weekends and public holidays and not a Soviet calendar.

I don't know enough about Boost's calendar and date_time facilities to give a very good answer, but it seems to me that it would be a fairly simple calculation to make on your own.

Given a begin date and and end date, find the total number of weeks that elapse. Subtract twice that from your days. Subtract an extra day or two when the start and end dates are weekends.

Then you will have to do some special counting for non-weekend holidays. You'll have to generate a list of holiday dates in the given range for that. (The vast majority of holiday dates are easy to calculate -- even Easter. For the really obnoxious ones you'll need a historical archive.)


Hopefully someone else (like JLBorges or cire) will have a much better answer than this. If not, you may want to subscribe to the Boost Users mailing list and ask.
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Good luck!
Topic archived. No new replies allowed.