due: Add 'add' method

This commit is contained in:
Adam Goldsmith 2016-10-27 12:28:51 -04:00
parent 9b1367e2f8
commit c36a301d08
1 changed files with 7 additions and 0 deletions

7
due
View File

@ -5,6 +5,7 @@ import re
import subprocess
import sys
from datetime import datetime
import parsedatetime
TAGS = ['t', 'due']
@ -46,6 +47,12 @@ class todo_item:
return fancy_text
def add(date_input, desc):
cal = parsedatetime.Calendar()
time_struct, parse_status = cal.parse(date_input)
date = datetime(*time_struct[:6]).strftime("%Y-%m-%d")
subprocess.call(["todo.sh", "add", desc, "t:" + date])
def due(search_term="", relative=False):
command = ["todo.sh", "list"]
command.append(search_term)