{"size": 1677, "ext": "js", "max_stars_repo_path": "js/medtrack.js", "max_stars_repo_name": "probablyatraitor/hackhershey_sageSite", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/medtrack.js", "max_issues_repo_name": "probablyatraitor/hackhershey_sageSite", "max_issues_repo_issues_event_min_datetime": "2021-06-25T04:14:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-25T04:14:02.000Z", "max_forks_repo_path": "js/medtrack.js", "max_forks_repo_name": "probablyatraitor/hackhershey_sageSite", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 31.641509434, "max_line_length": 89, "alphanum_fraction": 0.5491949911}
var dates = [];
var d = new Date();
var returnString = "";

function createSchedule(name, desc, recurrance, amount) {
  recurrance = parseInt(recurrance);
  amount = parseInt(amount);
  var d = new Date(); //Date Object
  var da = d.getDate(); //Current day
  var daysinmonth = 30; //Days in current Month
  var year = d.getYear() + 1900;
  var month = d.getMonth() + 1; //CUrrent Month
  if (month === 4 || month === 6 || month === 9 || month === 12) {
    daysinmonth = 30;
  }
  if (month === 2) daysinmonth = 28;
  else daysinmonth = 31;
  console.log(daysinmonth);
  console.log(da);
  console.log(month);
  console.log(d.getYear());
  for (var i = 0; i < amount; i++) {
    if (da + recurrance >= daysinmonth) { //recaclute month if over days
      month++;
      if (month === 4 || month === 6 || month === 9 || month === 12) {
        daysinmonth = 30;
      }
      if (month === 2) daysinmonth = 28;
      else daysinmonth = 31;
      da = da-daysinmonth;
      if (month > 12) { //recaclute month if over days
        month=1;
        year++;
      }
    }
    da += recurrance; //Move to next intake day
    console.log(da);
    dates[i] = "" + month + "/" + da + "/" + year; //MM/DD/YY
  }


  for (var i = 0; i < dates.length; i++) {
    returnString += "" + dates[i] + " -- " + name + ""; //Format into html ul element
    if (desc != "") {
      returnString += ": " + desc;
    }
    returnString += "<br>"
  }
  console.log(returnString);
  document.getElementById('dates').innerHTML = returnString; //Return dates as html list
  document.getElementById('next').innerHTML = dates[0]; //return next dosage
}
