Created
September 19, 2019 13:23
-
-
Save NeilHanlon/4b38fc029178a2b23cceb7f154350584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DAYSOFWEEK = [ScriptApp.WeekDay.SUNDAY, ScriptApp.WeekDay.MONDAY, ScriptApp.WeekDay.TUESDAY, | |
ScriptApp.WeekDay.WEDNESDAY, ScriptApp.WeekDay.THURSDAY, | |
ScriptApp.WeekDay.FRIDAY, ScriptApp.WeekDay.SATURDAY]; | |
String.prototype.capitalize = function() { | |
return this.charAt(0).toUpperCase() + this.slice(1); | |
} | |
function isValidDate(d) { | |
return d instanceof Date && !isNaN(d); | |
} | |
function SPLITWEEKDAYJOIN(input){ | |
var output = []; | |
var days = input.split("\n"); | |
for(var day in days) { | |
var date = new Date(days[day]); | |
if (isValidDate(date)) { | |
output.push(String(DAYSOFWEEK[date.getDay()]).toLowerCase().capitalize()) | |
} | |
} | |
return output.join("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment