function startOfInterval(startOfEmployment, startOfLeave) {
const employmentDate = new Date(startOfEmployment);
const leaveDate = new Date(startOfLeave);
employmentDate.setMonth(employmentDate.getMonth() + 2);
employmentDate.setDate(0);
leaveDate.setMonth(leaveDate.getMonth() - 6);
if (employmentDate > leaveDate) {
employmentDate.setDate(1);
return employmentDate;
} else {
return leaveDate;
}
}