var feb29Between = function(date1, date2) {
var year1 = date1.getFullYear();
var mar1year1 = new Date(year1, 2, 1);
if (isLeapYear(year1) && date1 < mar1year1 && date2 >= mar1year1) {
return true;
}
var year2 = date2.getFullYear();
var mar1year2 = new Date(year2, 2, 1);
return isLeapYear(year2) && date2 >= mar1year2 && date1 < mar1year2;
};
var ylength = 365;
if (
sy === ey ||
(sy + 1 === ey && (sm > em || (sm === em && sd >= ed)))
) {
if (
(sy === ey && isLeapYear(sy)) ||
feb29Between(start_date, end_date) ||
(em === 1 && ed === 29)
) {
ylength = 366;
}
return daysBetween(start_date, end_date) / ylength;
}
var years = ey - sy + 1;
var days =
(new Date(ey + 1, 0, 1) - new Date(sy, 0, 1)) / 1000 / 60 / 60 / 24;
var average = days / years;
return daysBetween(start_date, end_date) / average;
case 2: