I think this'll work (C++):

/** Given a run of days, length total_days, starting on
* start_day_of_week, where 0=Sunday, 6=Saturday, return the number of
* days that are a particular day, given by find_day_of_week
*/
int dayCount(int total_days, int start_day_of_week, int find_day_of_week)
{
if (total_days == 0)
return 0;

int total_weeks = total_days / 7;
int days_remaining = total_days % 7;

// If I've got entire weeks, then I've got one find_day_of_week in
// each.

// To see if our remaining days contain the one we're looking for
// we 'unmodulo' the maths, and then do a range comparison.
if (find_day_of_week < start_day_of_week + days_remaining)
return total_weeks + 1;

return total_weeks;
}

_________________________
-- roger