Skip to content

Instantly share code, notes, and snippets.

@taylormitchell
Created February 14, 2022 22:01
Show Gist options
  • Select an option

  • Save taylormitchell/092cb3aa9774597ac422cff9373e5ad5 to your computer and use it in GitHub Desktop.

Select an option

Save taylormitchell/092cb3aa9774597ac422cff9373e5ad5 to your computer and use it in GitHub Desktop.
function createWorkSessionReminder() {
let Reminders = Application('Reminders');
let app = Application.currentApplication()
app.includeStandardAdditions = true
let now = new Date()
// Set start time to now
let startTime = `${now.getHours()}:${now.getMinutes()}`
// Get end time from user
let defaultEndTime = `${now.getHours() + 1}:00`
let response = app.displayDialog("End time?", {
defaultAnswer: defaultEndTime,
withIcon: "note",
buttons: ["Cancel", "Continue"],
defaultButton: "Continue"
})
let endTime = response["textReturned"]
// Create reminder
let reminder = Reminders.Reminder({
name: `End of ${startTime} - ${endTime} work session!`,
remindMeDate: new Date(now.toDateString() + " " + endTime)
})
Reminders.reminders.push(reminder)
}
createWorkSessionReminder()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment