Some simple functions to adjust my time formatting
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