Open brechtm opened 9 years ago
I suspect this is because I'm using the 24-hour time format.
Changing the date format string in plugin.py
to +%m/%d/%Y %H:%M:%S
(from +%m/%d/%Y %I:%M:%S %p
) fixes things for me.
The following might work regardless of the 24-hour setting (replaces the run
function in plugin.py
:
def run(parsed):
from applescript import asrun
get_date = ''
set_date = ''
if '@date' in parsed:
get_date = 'set theDueDate to (date "Thursday 1 January 1970 00:00:00") + (time to GMT) + {0}'.format(parsed['@date']['timestamp'])
set_date = "set due date of newReminder to theDueDate"
script = """{0}
tell application "Reminders"
set newReminder to make new reminder
set name of newReminder to "{1}"
{2}
display notification "Created reminder" with title "Flashlight"
end tell
""".format(get_date, parsed['~message'], set_date)
print script
asrun(script)
I'm not 100% confident that this will work in all timezones and with daylight savings though. And the date calculation should be encapsulated into a function, but my AppleScript knowledge is lacking.
Ugh, Applescript.....
You can submit a pull request to try to fix this if you'd like — ultimately, I think the best solution is to find some way to avoid applescript (probably by using EventKit, although it's not working perfectly via PyObjc)
Remind Me will always create tasks in the AM. If I enter "remind me something at 5pm" or "remind me something else at 17", it will create a reminder due 5 AM.