Start=due-x functionality working again. Time set by user is now also included in the diff calculation

pull/30/head
Hoffelhas 2023-01-08 18:42:16 +01:00
parent 81769968ae
commit 4aad462ce3
1 changed files with 31 additions and 41 deletions

View File

@ -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( if f2:
# 'd') # Find 'd' from 'due' offset = f2.groups()[0]
# 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.groups()[1] == 'd':
# offset = task.content[f+10:f+10+f_end-1] td = timedelta(days=int(offset))
# else: elif f2.groups()[1] == 'w':
# offset = task.content[f+10:-1] td = timedelta(weeks=int(offset))
# try: # Determine start-date
# task_due_date = task.due['date'][:10] try:
# task_due_date = datetime.strptime( due_date = datetime.strptime(task.due.datetime, "%Y-%m-%dT%H:%M:%S")
# task_due_date, '%Y-%m-%d') except:
# except: due_date = datetime.strptime(task.due.date, "%Y-%m-%d")
# 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 start_date = due_date - td
# td = timedelta(days=int(offset))
# elif f2 > -1: # If we're not in the offset from the due date yet, remove all labels
# td = timedelta(weeks=int(offset)) future_diff = (
datetime.today()-start_date).days
# # If we're not in the offset from the due date yet, remove all labels if future_diff < 0:
# start_date = task_due_date - td remove_label(
# future_diff = ( task, next_action_label, overview_task_ids, overview_task_labels)
# datetime.today()-start_date).days [remove_label(child_task, next_action_label, overview_task_ids,
# if future_diff < 0: overview_task_labels) for child_task in child_tasks]
# remove_label( continue
# 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: except:
# logging.warning( logging.warning(
# 'Wrong start-date format for task: %s. Please use "start=due-<NUM><d or w>"', task.content) 'Wrong start-date format for task: %s. Please use "start=due-<NUM><d or w>"', task.content)
# continue 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?