Adjusting and setting the end date and time for CSV format
function createcsv (schedule){
//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