From 11a97b0ab87efc01253bf554e5c11fff4162bf38 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Mon, 19 Jan 2015 18:33:35 +0100 Subject: [PATCH 1/1] Initial commit --- on-add-shift-all-recurrence | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 on-add-shift-all-recurrence diff --git a/on-add-shift-all-recurrence b/on-add-shift-all-recurrence new file mode 100755 index 0000000..0a0f065 --- /dev/null +++ b/on-add-shift-all-recurrence @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import sys +from tasklib.task import Task, TaskWarrior + +time_attributes = ('wait', 'until', 'scheduled') + +def is_new_local_recurrence_child_task(task): + # Do not affect tasks not spun by recurrence + if not task['parent']: + return False + + # Newly created recurrence tasks actually have + # modified field copied from the parent, thus + # older than entry field (until their ID is generated) + if (task['modified'] - task['entry']).total_seconds() < 0: + return True + +task = Task.from_input() +tw = TaskWarrior() + +if is_new_local_recurrence_child_task(task): + parent = tw.tasks.get(uuid=task['parent']) + parent_due_shift = task['due'] - parent['due'] + for attr in time_attributes: + if parent[attr]: + task[attr] = parent[attr] + parent_due_shift + +print task.export_data() -- 2.39.5