Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MacularDegenerate/8ed1ea4c9f0c5ddd9eb6d69e1935df64 to your computer and use it in GitHub Desktop.
Save MacularDegenerate/8ed1ea4c9f0c5ddd9eb6d69e1935df64 to your computer and use it in GitHub Desktop.
Archive completed Reminders greater than 7 days old
// days: specifies the number of days that a reminder will remain marked as complete before it is moved to the "Completed Archive" list.
let days = 7
let today = new Date()
let arch = await Calendar.forRemindersByTitle("Completed Archive")
let listsToClear = await Calendar.forReminders()
for ( var j = 0; j < listsToClear.length; j++ ) {
let cal = listsToClear[j]
let reminders = await Reminder.allCompleted( [cal] )
for( var i = 0; i < reminders.length; i++ ) {
let reminder = reminders[i]
console.log( reminder.title )
if ((today - reminder.completionDate)/(1000 * 3600 * 24) > days ) {
reminder.calendar = arch
reminder.isCompleted = 0
reminder.save()
}
}
}
Script.complete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment