The main part of the createcsv() function, is where the date and time information is adjusted to the appropriate format.  One of the main adjustments that needs to occur for csv calendar formatting, is making sure all date and time information is two digits long.  For example if the date, as posted on the website, is 1/1/12 (January 1st, 2012), then this function would add a ‘0’ where there is none making the date read 01/01/12.  Once complete the function returns x with it’s new value.     

function lessthanten (x) {

if (x < 10){

  x = "0" + x;

return x;

};

};


The next simple function is one that verifies whether the time of day is am or pm.  If the hour entered is greater than 12 the hour changes from military time to regular time.  It also changes the variable ampm to PM.  If the variable hour is less than 12 it simply changes the ampm hours to AM.  Once complete the function returns the new values of ampm and hour.


function adjusthour (hour) {

if (hour > 12){

    hour = hour - 12;

    ampm = " PM";

  }else {

    ampm = " AM";

  };

return [hour, ampm];

};



Now that the dates have functions to help them be adjusted quickly and effectively, it’s time to explain the rest of the function.

Up Next Time: Setting the start date and time of my calendar event in CSV format