Skip to content

Instantly share code, notes, and snippets.

@franklinokech
Created March 13, 2019 13:36
Show Gist options
  • Save franklinokech/28d6b286642f6bacf5d5eef6e33e21ad to your computer and use it in GitHub Desktop.
Save franklinokech/28d6b286642f6bacf5d5eef6e33e21ad to your computer and use it in GitHub Desktop.
Google app script to make a trigger not run on a weekend
function shouldRunTrigger() {
var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
var date = new Date();
var day = days[date.getDay()];
var hours = date.getHours();
if ((day === "Fri" && hours >= 17) || (day === "Sat" && hours <= 22)) {
return false;
}
return true;
}
function myTrigger() {
if (!shouldRunTrigger()) return;
// trigger code here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment