Compare and combine Javascript date ranges