Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for syncing events for more than one day #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ function myFunction() {

// we'll be looking at syncing events for today
var today = new Date()

// Uncomment following line if you want to test this script for a day in the future
// today.setDate(today.getDate() + 1)

// Modify the following line if you want to sync events for more than one day
var endDaysFromNow = 1
var endDate = new Date()
endDate.setDate(today.getDate() + endDaysFromNow)

var gSuiteEvents = gSuiteCalendar.getEvents(today, endDate);

var gSuiteEvents = gSuiteCalendar.getEventsForDay(today)
var trackGSuiteEvents = {}

gSuiteEvents.forEach(function(event){
Expand Down Expand Up @@ -153,14 +158,14 @@ function checkForEventUpdates(rows, trackGSuiteEvents, personalCalendar, persona

function markOldEvents(row, oldEvents, sheet, index) {
var today = new Date()

// Uncomment following line if you want to test this script for a day in the future
// Uncomment following line if you want to test this script beginning on a day in the future
// today.setDate(today.getDate() + 1)


var now = today.getTime()
var storedDay = new Date(row[3])

// if the current event doesn't match today's date, then mark it for deletion
if (storedDay.getDate() != today.getDate()) {
if (storedDay.getTime() < now) {
// to avoid marking the same row number multiple times we first check for it
if (oldEvents.indexOf(index+1) == -1) {
oldEvents.push(index+1)
Expand Down