Closed TexanFoxx closed 2 years ago
@TexanFoxx thanks for reporting this. The reason you can't use the "-" instead of the "/" in the date is because of the calcDateTime
function. This function looks for subject lines that have multi-day events (e.g. "5/10-5/14"). See this line in the script that looks for the dash. You could take out the capability of searching for multi-day events and doing the split on the dash would probably work in your case.
Problem: It seems to break when the parseDate(rawDate) function is called, the date gets passed down wrong. I have also switched it to US format to see if that would fix it and still no dice. I believe it's breaking right before that. Newish to this language and hitting wall, would appreciate your help. :)
Notes: Subject line looks like this: Patch Series, 23-4, 5 PM
I can't change the subject format from a - to a / I replaced the var dateDetails = date.split("/") with var dateDetails = date.split("-") Added some console.log trying to debug what's going on but running into date getting passed as just the day and not the dd-mm that we're looking for.
Execution log: 3:45:25 PM Notice Execution started 3:45:26 PM Info 23-4 3:45:26 PM Info 23 3:45:25 PM Error
TypeError: Cannot read property 'trim' of undefined parseDate @ Code.gs:121 calcDateTime @ Code.gs:96 parseEmail @ Code.gs:38 getEmail @ Code.gs:23
calcDateTime(rawDate, rawTime, isAllDay) { var dashModifierIndex = rawDate.indexOf("-") var isMultiDay = dashModifierIndex == -1 ? false : true console.log(rawDate)
// Get time if event is not an all-day event if (isAllDay == false && isMultiDay == false) { var [month, day, year] = parseDate(rawDate) var [hours, minutes] = convertTime12to24(rawTime) var newDateStart = new Date(year, month - 1, day, hours, minutes) var newDateEnd = new Date(newDateStart) newDateEnd.setMinutes(newDateStart.getMinutes() + DEFAULT_EVENT_TIME) } else { // Set start and end date if event is multi-day if (isMultiDay) { var startDate = rawDate.substring(0, dashModifierIndex) var endDate = rawDate.substring(dashModifierIndex + 1, rawDate.length) var [startMonth, startDay, startYear] = parseDate(startDate) var [endMonth, endDay, endYear] = parseDate(endDate) var newDateStart = new Date(startYear, startMonth - 1, startDay) var newDateEnd = new Date(endYear, endMonth - 1, endDay) isAllDay = true } else { var [month, day, year] = parseDate(rawDate) var newDateStart = newDateEnd = new Date(year, month - 1, day) }
} return [newDateStart, newDateEnd, isAllDay] }
// Get month, day, year from date with slash function parseDate(date) { console.log(date) var dateDetails = date.split("-")