summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 23:02:15 +0300
committerPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 23:02:15 +0300
commit9c7b7f2f9be4cd453587f095b058a24402f7bf03 (patch)
tree8753eb2640607f89f5a337b05dd250d01c334fde /internal
parentda8c880889801c72f12dbdef2d2e677a0f510bc3 (diff)
Describe due formatting
Diffstat (limited to 'internal')
-rw-r--r--internal/ui/table.go19
1 files changed, 15 insertions, 4 deletions
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,