mirror of https://github.com/Hoffelhas/autodoist
Start=due-x functionality working again. Time set by user is now also included in the diff calculation
parent
81769968ae
commit
4aad462ce3
72
autodoist.py
72
autodoist.py
|
@ -1190,52 +1190,42 @@ def autodoist_magic(args, api, connection):
|
||||||
'Wrong start-date format for task: "%s". Please use "start=<DD-MM-YYYY>"', task.content)
|
'Wrong start-date format for task: "%s". Please use "start=<DD-MM-YYYY>"', task.content)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Recurring task friendly - remove label with relative change from due date #TODO FIX THIS
|
# Recurring task friendly - remove label with relative change from due date
|
||||||
f2 = re.search('start=due-(\d)+([dw])', task.content)
|
if task.due is not None:
|
||||||
# try:
|
try:
|
||||||
# f = task.content.find('start=due-')
|
f2 = re.search('start=due-(\d+)([dw])', task.content)
|
||||||
# if f > -1:
|
|
||||||
# f1a = task.content.find(
|
|
||||||
# 'd') # Find 'd' from 'due'
|
|
||||||
# f1b = task.content.rfind(
|
|
||||||
# 'd') # Find 'd' from days
|
|
||||||
# f2 = task.content.find('w')
|
|
||||||
# f_end = task.content[f+10:].find(' ')
|
|
||||||
|
|
||||||
# if f_end > -1:
|
if f2:
|
||||||
# offset = task.content[f+10:f+10+f_end-1]
|
offset = f2.groups()[0]
|
||||||
# else:
|
|
||||||
# offset = task.content[f+10:-1]
|
|
||||||
|
|
||||||
# try:
|
if f2.groups()[1] == 'd':
|
||||||
# task_due_date = task.due['date'][:10]
|
td = timedelta(days=int(offset))
|
||||||
# task_due_date = datetime.strptime(
|
elif f2.groups()[1] == 'w':
|
||||||
# task_due_date, '%Y-%m-%d')
|
td = timedelta(weeks=int(offset))
|
||||||
# except:
|
|
||||||
# logging.warning(
|
|
||||||
# 'No due date to determine start date for task: "%s".', task.content)
|
|
||||||
# continue
|
|
||||||
|
|
||||||
# if f1a != f1b and f1b > -1: # To make sure it doesn't trigger if 'w' is chosen
|
# Determine start-date
|
||||||
# td = timedelta(days=int(offset))
|
try:
|
||||||
# elif f2 > -1:
|
due_date = datetime.strptime(task.due.datetime, "%Y-%m-%dT%H:%M:%S")
|
||||||
# td = timedelta(weeks=int(offset))
|
except:
|
||||||
|
due_date = datetime.strptime(task.due.date, "%Y-%m-%d")
|
||||||
|
|
||||||
# # If we're not in the offset from the due date yet, remove all labels
|
start_date = due_date - td
|
||||||
# start_date = task_due_date - td
|
|
||||||
# future_diff = (
|
|
||||||
# datetime.today()-start_date).days
|
|
||||||
# if future_diff < 0:
|
|
||||||
# remove_label(
|
|
||||||
# task, next_action_label, overview_task_ids, overview_task_labels)
|
|
||||||
# [remove_label(child_task, next_action_label, overview_task_ids,
|
|
||||||
# overview_task_labels) for child_task in child_tasks]
|
|
||||||
# continue
|
|
||||||
|
|
||||||
# except:
|
# If we're not in the offset from the due date yet, remove all labels
|
||||||
# logging.warning(
|
future_diff = (
|
||||||
# 'Wrong start-date format for task: %s. Please use "start=due-<NUM><d or w>"', task.content)
|
datetime.today()-start_date).days
|
||||||
# continue
|
|
||||||
|
if future_diff < 0:
|
||||||
|
remove_label(
|
||||||
|
task, next_action_label, overview_task_ids, overview_task_labels)
|
||||||
|
[remove_label(child_task, next_action_label, overview_task_ids,
|
||||||
|
overview_task_labels) for child_task in child_tasks]
|
||||||
|
continue
|
||||||
|
|
||||||
|
except:
|
||||||
|
logging.warning(
|
||||||
|
'Wrong start-date format for task: %s. Please use "start=due-<NUM><d or w>"', task.content)
|
||||||
|
continue
|
||||||
|
|
||||||
# Mark first found task in section
|
# Mark first found task in section
|
||||||
if next_action_label is not None and first_found[1] == False: #TODO: is this always true? What about starred tasks?
|
if next_action_label is not None and first_found[1] == False: #TODO: is this always true? What about starred tasks?
|
||||||
|
|
Loading…
Reference in New Issue