From 9c7b7f2f9be4cd453587f095b058a24402f7bf03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20B=C3=BCtow?= <1224732+snonux@users.noreply.github.com> Date: Fri, 20 Jun 2025 23:02:15 +0300 Subject: Describe due formatting --- internal/ui/table.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/ui/table.go b/internal/ui/table.go index 5ac329f..4b13b4b 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -95,8 +95,8 @@ func newTable(rows []atable.Row) atable.Model { {Title: "ID", Width: 4}, {Title: "Pri", Width: 4}, {Title: "Age", Width: 6}, - {Title: "Due", Width: 10}, {Title: "Urg", Width: 5}, + {Title: "Due", Width: 10}, {Title: "Tags", Width: 15}, {Title: "Description", Width: 45}, {Title: "Annotations", Width: 20}, @@ -524,14 +524,17 @@ func taskToRow(t task.Task) atable.Row { style.Render(strconv.Itoa(t.ID)), formatPriority(t.Priority), style.Render(age), - formatDue(t.Due), style.Render(urg), + formatDue(t.Due), style.Render(tags), style.Render(t.Description), style.Render(strings.Join(anns, "; ")), } } +// formatDue returns a formatted due date string. Dates due today or tomorrow +// are returned as "today" or "tomorrow" respectively. Past due dates are +// highlighted in red. func formatDue(s string) string { if s == "" { return "" @@ -542,7 +545,15 @@ func formatDue(s string) string { } days := int(time.Until(ts).Hours() / 24) - val := fmt.Sprintf("%dd", days) + var val string + switch days { + case 0: + val = "today" + case 1: + val = "tomorrow" + default: + val = fmt.Sprintf("%dd", days) + } style := lipgloss.NewStyle() if days < 0 { style = style.Background(lipgloss.Color("1")) @@ -631,8 +642,8 @@ func taskToRowSearch(t task.Task, re *regexp.Regexp) atable.Row { idStr, priStr, ageStr, - dueStr, urgStr, + dueStr, tagStr, descStr, annStr, -- cgit v1.2.3