The main difference when creating the endtime variable is that you have to adjust the starting time that is stored in schedule.   To do that you must increase the start time by the total length of the event.  My soccer games are technically 50 minutes in length, so I need to increase the time by 50 minutes.  I use the getTime() method to do this.  It provides a result that is the time extracted in milliseconds.  Thus, to increase the starting time to the appropriate endtime I need to add 50 minutes to the starting time in the equivalent of milliseconds, which in numerics is (50*60*1000).  Then I add on this newtime to the date using the Date() method.    

function createcsv (schedule){

...see previous entry

  //setting endtime

  var newtime = schedule[i].datetime.getTime() + (50*60*1000);

  newtime = new Date(newtime);

  var endhour = newtime.getHours();

  hourampm = adjusthour(endhour);

  endhour = lessthanten(hourampm[0]);

  var minutes = schedule[i].datetime.getMinutes();

 minutes =  lessthanten(minutes);  

  var endminutes = newtime.getMinutes();

 endminutes =  lessthanten(endminutes);

  var seconds = schedule[i].datetime.getSeconds();

 seconds =  lessthanten(seconds);

  var starttime = hour + ":" + minutes + ":" + seconds + hourampm[1];

  var endtime = endhour + ":" + endminutes + ":" + seconds + endhourampm[1];;

  …additional code explained in next entry


return finalcsv


Once the newtime variable is set I can use it to create the variables endhour and endminutes.  I create these end time variables, but using newtime instead of schedule as I was doing so in my previous entry.  Then I adjust the endhour by using the adjusthour() and lessthanten() functions.  

After I set the endhour variable you can see how next I set the minutes and endminutes variables differently.  I access the original datetime information by setting the minutes variable by accessing schedule.  I set the endminutes like I did endhour by using newtime.  Both minute related variables are adjusted by the lessthanten() function.  Finally the seconds variable is set by using schedule.  The actual start second and end second are no different, and thus I use the same value for starttime and endtime.  This variable is also adjusted by the lessthanten() function.

At the very end of the date and time code in this function I set the variables starttime and endtime.  I do this by simply concatenating the various time related variables I’ve created.  Next time I will continue with the createcsv() function.  I will also discuss some problems I’ve noticed have occurred during my readjustment of this code, namely regarding output of the adjusthour() function.    

Up Next Time: Connecting the final pieces and returning the csv data