From 646d672a4af78ce5cc32d01fd7535c21c4113064 Mon Sep 17 00:00:00 2001 From: Moritz Brettschneider <48832228+mbrettschneider@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:18:19 +0200 Subject: [PATCH 1/2] Date: fix days_between ignoring its argument days_between read the year, month and day of both dates from this.dt, so it always returned 0. As a result, the threshold date of a recurring task with both a due and a threshold date was not moved along with the due date when the task was rescheduled. Add a test for that case. Co-Authored-By: Claude Opus 5.5 --- src/Date.vala | 2 +- tests/todo.txt/TaskManagerTest.vala | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Date.vala b/src/Date.vala index c3e6ae01..f91c05bc 100644 --- a/src/Date.vala +++ b/src/Date.vala @@ -123,7 +123,7 @@ public class GOFI.Date { GLib.Date b_date = GLib.Date (); this.dt.get_ymd (out a_year, out a_month, out a_day); - dt.get_ymd (out b_year, out b_month, out b_day); + date.dt.get_ymd (out b_year, out b_month, out b_day); a_date.set_dmy ( (GLib.DateDay) a_day, (GLib.DateMonth) a_month, (GLib.DateYear) a_year diff --git a/tests/todo.txt/TaskManagerTest.vala b/tests/todo.txt/TaskManagerTest.vala index ab597ab0..c737fb28 100644 --- a/tests/todo.txt/TaskManagerTest.vala +++ b/tests/todo.txt/TaskManagerTest.vala @@ -16,6 +16,7 @@ class TaskManagerTest : TestCase { add_test ("Repeat task 2 days from completion date (due date)", test_reschedule_completion_due_date); add_test ("Repeat task 2 days from completion date (threshold date)", test_reschedule_completion_threshold_date); add_test ("Repeat weekly task upon completing", test_reschedule_periodically); + add_test ("Repeat weekly task upon completing (due and threshold date)", test_reschedule_periodically_threshold); add_test ("Repeat task: every 3 months, skipping past dates", test_reschedule_monthly_skip); add_test ("Check drift compensation", test_reschedule_monthly_drift_compensation); add_test ("Repeat task: yearly reschedule", test_yearly_reschedule); @@ -301,6 +302,26 @@ class TaskManagerTest : TestCase { compare_post_schedule (task_copy, completed_task, generated_task, threshold_date, due_date, test_date, test_date); } + private void test_reschedule_periodically_threshold () { + var task_manager = new TaskManager.test_instance (); + var task = build_test_weekly (); + task.due_date = new GOFI.Date.from_ymd (2021, 11, 16); + task.threshold_date = new GOFI.Date.from_ymd (2021, 11, 14); + var task_copy = task.copy (); + task_manager.todo_store.add_task (task); + var test_date = new GOFI.Date.from_ymd (2021, 11, 15); + task_manager.static_date = test_date.dt; + task.set_completed (test_date); + + var completed_task = task_manager.done_store.get_task (0); + var generated_task = task_manager.todo_store.get_task (0); + // The threshold date moves along with the due date + var due_date = new GOFI.Date.from_ymd (2021, 11, 23); + var threshold_date = new GOFI.Date.from_ymd (2021, 11, 21); + + compare_post_schedule (task_copy, completed_task, generated_task, threshold_date, due_date, test_date, test_date); + } + private void test_reschedule_monthly_skip () { var task_manager = new TaskManager.test_instance (); var task = build_test_3month_skip (); From d1ea0ea8494277d92d39605425678bb20897a548 Mon Sep 17 00:00:00 2001 From: Moritz Brettschneider <48832228+mbrettschneider@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:18:19 +0200 Subject: [PATCH 2/2] TaskRow: highlight due and overdue tasks Show the due date in bold if a task is due today and in bold red if it is overdue, and add the due date to the tooltip. Update the row when the due date changes. Co-Authored-By: Claude Opus 5.5 --- src/Todo.txt/Widgets/TaskRow.vala | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Todo.txt/Widgets/TaskRow.vala b/src/Todo.txt/Widgets/TaskRow.vala index 17a3c367..afce28de 100644 --- a/src/Todo.txt/Widgets/TaskRow.vala +++ b/src/Todo.txt/Widgets/TaskRow.vala @@ -342,10 +342,29 @@ class GOFI.TXT.TaskRow: DragListRow { var timer_value_str = Utils.seconds_to_pretty_string (timer_value); new_tooltip_text += "\n%s: %s".printf (_("Timer"), timer_value_str); } + if (task.due_date != null) { + var due_str = task.due_date.dt.format (date_format); + var days_left = days_until_due (); + if (days_left < 0) { + due_str = _("%s (overdue)").printf (due_str); + } else if (days_left == 0) { + due_str = _("%s (today)").printf (due_str); + } + new_tooltip_text += "\n%s: %s".printf (_("Due"), due_str); + } this.tooltip_text = new_tooltip_text; } } + /** + * Number of days until the task is due, negative if it is overdue. + * Only call this if the task has a due date. + */ + private int days_until_due () { + var today = new GOFI.Date (new GLib.DateTime.now_local ()); + return today.days_between (task.due_date); + } + private void gen_markup () { markup_string = make_links (task.get_descr_parts ()); var str_builder = new StringBuilder.sized (100); @@ -379,8 +398,15 @@ class GOFI.TXT.TaskRow: DragListRow { str_builder.append (TxtUtils.dt_to_string (task.threshold_date.dt)); } if (task.due_date != null) { - str_builder.append (" due:"); - str_builder.append (TxtUtils.dt_to_string (task.due_date.dt)); + var due_str = "due:" + TxtUtils.dt_to_string (task.due_date.dt); + var days_left = days_until_due (); + if (done || days_left > 0) { + str_builder.append (" " + due_str); + } else if (days_left == 0) { + str_builder.append (@" $due_str"); + } else { + str_builder.append (@" $due_str"); + } } task.append_recurrence_rule (str_builder); @@ -450,6 +476,7 @@ class GOFI.TXT.TaskRow: DragListRow { task.notify["description"].connect (update); task.notify["priority"].connect (update); task.notify["timer-value"].connect (update); + task.notify["due-date"].connect (update); } } }