Skip to content

Instantly share code, notes, and snippets.

@NeilHanlon
Created Sep 19, 2019
Embed
What would you like to do?
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