From 45dc306132933bd9ae4c8db5af102f11b4c383dd Mon Sep 17 00:00:00 2001 From: Sajal Sharma Date: Sat, 7 Oct 2017 01:18:35 -0700 Subject: [PATCH] changes to calendar --- calendar.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/calendar.js b/calendar.js index d40520b..d9fcba0 100644 --- a/calendar.js +++ b/calendar.js @@ -1,28 +1,37 @@ +console.log("hey"); + function getInformation(information) { - var elements = information.split(" ")[]; + var elements = information.split(" "); + console.log(elements); date = elements[1]; + console.log(date); datePortion = "20" + date.substring(6) + "-" + date.substring(0, 2) + "-" + date.substring(3, 5); + console.log(datePortion); militaryTime = true; - for (var x = 0; x < elements.length(), x++) + for (var i = 0; i < elements.length; i++) { - if elements[x].toLowerCase() == "pm" || elements[x].toLowerCase() == "am" + if (elements[i].toLowerCase() === "pm" || elements[i].toLowerCase() === "am") { militaryTime = false; } } + console.log(militaryTime); + timePortion1 = ""; timePortion2 = ""; - if isMilitaryTime + if (militaryTime) { timePortion1 = elements[2] + ":00-07:00"; timePortion2 = elements[3] + ":00-07:00"; + console.log(timePortion1); + console.log(timePortion2); } else { - if elements[2].substring(5).toLowerCase() == "am" + if (elements[2].substring(5).toLowerCase() === "am") { timePortion1 = elements[2].substring(0, 5) + ":00-07:00"; } @@ -32,7 +41,7 @@ function getInformation(information) timePortion1 = hour + elements[2].substring(2, 5); } - if elements[3].substring(5).toLowerCase() == "am" + if (elements[3].substring(5).toLowerCase() === "am") { timePortion2 = elements[3].substring(0, 5) + ":00-07:00"; } @@ -42,6 +51,7 @@ function getInformation(information) timePortion2 = hour + elements[3].substring(2, 5); } } + console.log([elements[0], datePortion + "T" + timePortion1, datePortion + "T" + timePortion2]); return [elements[0], datePortion + "T" + timePortion1, datePortion + "T" + timePortion2]; } @@ -86,3 +96,5 @@ function makeEvent(information) appendPre('Event created: ' + event.htmlLink); }); } + +getInformation("Bob's 01/24/24 12:33AM 1:23AM");