I could confirm that from your script and shared Spreadsheet, the values of NewWeekday
are WEDNESDAY
and MONDAY
of the string type. In this case, how about the following modification?
From:
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(weekday);
event.setRecurrence(recurrence, tstart, tstop);
To:
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(CalendarApp.Weekday[NewWeekday]); // Modified
event.setRecurrence(recurrence, tstart, tstop);
References:
If I misunderstood your question and this was not the result you want, I apologize.
Added:
- You want to use
tstop
as "until".
For this, how about the following modification?
From:
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(weekday);
event.setRecurrence(recurrence, tstart, tstop);
To:
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(CalendarApp.Weekday[NewWeekday]).until(tstop); // Modified
event.setRecurrence(recurrence, tstart); // Modified