Created
March 13, 2019 13:36
-
-
Save franklinokech/28d6b286642f6bacf5d5eef6e33e21ad to your computer and use it in GitHub Desktop.
Google app script to make a trigger not run on a weekend
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
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