time between dates

I have this function (CalculateFare) that is suppose to calculate the cost of a few different things but will give a discount based on when you made the order. I'm having issues getting the days between the two dates to work successfully.

this is the function and what I have so far. Any help would be great. the code is not complete just hit a brick wall and can't find anything to help with adjustments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  string CalculateFare(UserData& data, int monSail, int daySail, int yearSail, int bookMon, int bookDay, int bookYear)
{
	stringstream ss;
	
	int people = data.numPeople;
	int excursions = data.numExcursions;
	float ticketPrice = 1769.00 * people;
	float excursionPrice = 225.00 * excursions;
	float sumPrice = ticketPrice + excursionPrice;
	ss << sumPrice << endl;

	tm date1;
	tm date2;
	const const time_t ONE_DAY = 24 * 60 * 60;
	time_t sailing = mktime(&date1);
	time_t booking = mktime(&date2);
	time_t between = sailing - booking;
	ss << between << endl;
	float discount = sumPrice * between;

	
	

	return ss.str(); 
}
Last edited on
more specific to my question would be how could I jam in (int monSail, int daySail, int yearSail) into (date1) and (int bookMon, int bookDay, int bookYear) into (date2)?
is it even possible or do I need to look at a different method to doing so?
Last edited on
Topic archived. No new replies allowed.