I have a Google Form for customers to enter event details for Catering. App Script then creates a Google Calendar event, opens a Google Doc Template to replace corresponding text, converts the doc to a pdf and emails me a copy of it before deleting it from my Drive.
In the code here the Calendar Event is using the "var timeString". And the Rename Text in Document is using "var timeFormat" in order to not show the seconds and GSM. They both are pulling the data from the "time = newRequest[0][14]" cell in the spreadsheet. But for some reason that I can not explain when a time of 10:15, 10:45, 11:15, 11:45, 12:15 and 12:45 are entered the script changes the time on the Doc Template to **:10, **:40. It doesn't happen if the time is a single digit hour. I don't understand why this is happening, please help?
//rename data into useable tags
timestamp = newRequest[0][0],
company = newRequest[0][1],
contact_name = newRequest[0][2],
contact_email = newRequest[0][3],
contact_phone = newRequest[0][4],
onsite_name = newRequest[0][5],
onsite_phone = newRequest[0][6],
pickup_delivery = newRequest[0][7],
day = newRequest[0][8],
address = newRequest[0][9],
location = newRequest[0][10],
parking = newRequest[0][11],
guests = newRequest[0][12],
other = newRequest[0][13],
time = newRequest[0][14];
date = newRequest[0][15]
//create new calendar event
var dateString = date.toDateString();
var dateFormat = dateString.substr(4,11);
var timeString = time.getHours() + ":" + time.getMinutes();
var timeFormat = time.toLocaleTimeString().substr(0,4) + time.toLocaleTimeString().substr(7,4);
var endtimeString = (time.getHours() + 1) + ":" + time.getMinutes();
var calendar = CalendarApp.getCalendarById('haleyhouse.org_1oicreouarl3je785ltupuoppg@group.calendar.google.com');
var event = calendar.createEvent(contact_name + ", " + company + ", " + contact_phone,
new Date(dateString + " " + timeString),
new Date(dateString + " " + endtimeString),
{description: timestamp + " received form request - google", location: address});
//rename text in the document
copyBody.replaceText('keyDay', day);
copyBody.replaceText('keyDate', dateFormat)
copyBody.replaceText('keyTime', timeFormat)
copyBody.replaceText('keyCompany', company);
copyBody.replaceText('keyContact_Name', contact_name);
copyBody.replaceText('keyContact_Email', contact_email);
copyBody.replaceText('keyContact_Phone',contact_phone);
copyBody.replaceText('keyOnsite_Name', onsite_name);
copyBody.replaceText('keyOnsite_Phone', onsite_phone);
copyBody.replaceText('keyDelivery', pickup_delivery);
copyBody.replaceText('keyAddress', address);
copyBody.replaceText('keyLocation', location);
copyBody.replaceText('keyGuests', guests);