Reminders Script


#1

Hi. I’m a novice to JS but I wrote this script which might help someone who wants to get going with Reminders integration. This will create a reminder with a due date and an alarm at 12:30 - either today or tomorrow depending on the current time. Not sure it’ll be useful to anyone but thought I’d post it.
-Lyle

// from the draft var alerttime = "12:30" var title = draft.content

// default to today but if it’s after that time, use tomorrow
var today = new Date();
var tomorrow = new Date(today.getTime() + (24 * 60 * 60 * 1000));
var whichday=today;
var now = today.getHours()*100+today.getMinutes();
if ( now > alerttime.replace(":","")) { var whichday=tomorrow;}

// date and time for the reminder
var datestring=whichday.getFullYear()+"/"+(whichday.getMonth()+1)+"/"+whichday.getDate()+" "+alerttime;
var due=new Date (datestring);

// add the reminder
var list = ReminderList.findOrCreate(“TESTING”);
var rem = list.createReminder();
rem.title = title;
rem.dueDate = due;
rem.addAlarm(Alarm.alarmWithDate(due));
rem.update();