I've been trying to write a really basic function to determine the difference (in days) between two dates. I am very new to C++ so as you can imagine I am very happy with my work. This function is part of a much larger code so I have missed off my includes, but the function does compile without warnings.
Just looking for some constructive criticism that a reasonable beginner can take on board.
I should add, this function takes two dates as strings in British format DD/MM/YYYY.
int dateDiffs(std::string date1, std::string date2){
int startYear, endYear;
int startMonth, endMonth;
int startDay, endDay;
int startInDays, endInDays;
std::map<int,int> daysInMonth;
daysInMonth[1]=31;
daysInMonth[2]=28;
daysInMonth[3]=31;
daysInMonth[4]=30;
daysInMonth[5]=31;
daysInMonth[6]=30;
daysInMonth[7]=31;
daysInMonth[8]=31;
daysInMonth[9]=30;
daysInMonth[10]=31;
daysInMonth[11]=30;
daysInMonth[12]=31;
startYear = atoi(date1.substr(6,4).c_str());
startMonth = atoi(date1.substr(3,2).c_str());
startDay = atoi(date1.substr(0,2).c_str());
endYear = atoi(date2.substr(6,4).c_str());
endMonth = atoi(date2.substr(3,2).c_str());
endDay = atoi(date2.substr(0,2).c_str());
startInDays = (startYear * 365) + (startMonth * daysInMonth[startMonth]) + startDay;
endInDays = (endYear * 365) + (endMonth * daysInMonth[endMonth]) + endDay;
return (endInDays - startInDays);
}