-
-
Save linglung/3a019876932712988b8526eaa88b2878 to your computer and use it in GitHub Desktop.
Google Apps Script snippet to run time based triggers during specified periods
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 scheduledCollection(){ | |
var schedule = []; | |
// dates/times in mm/dd/yyyy hh:mm - timezone matches settings in File > Project properties | |
schedule.push({start:"08/29/2012 15:00", end:"08/29/2012 16:00"}); | |
schedule.push({start:"08/29/2012 20:00", end:"08/29/2012 22:00"}); | |
checkCollect(schedule); | |
} | |
function checkCollect(schedule){ | |
var now = new Date(); | |
for (i in schedule){ | |
var start = new Date(schedule[i].start); | |
var end = new Date(schedule[i].end); | |
if (now > start && now < end){ | |
// insert function you want to run here | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment