Consolidate duplicate formatAge functions in feed TUI (gt-798p0)
This commit is contained in:
committed by
Steve Yegge
parent
4178940d39
commit
f464f87d5b
@@ -305,7 +305,7 @@ func renderConvoyLine(c Convoy, landed bool) string {
|
||||
|
||||
if landed {
|
||||
// Show checkmark and time since landing
|
||||
age := formatConvoyAge(time.Since(c.ClosedAt))
|
||||
age := formatAge(time.Since(c.ClosedAt))
|
||||
status := ConvoyLandedStyle.Render("✓") + " " + ConvoyAgeStyle.Render(age+" ago")
|
||||
return fmt.Sprintf(" %s %-20s %s", id, title, status)
|
||||
}
|
||||
@@ -337,16 +337,3 @@ func renderProgressBar(completed, total int) string {
|
||||
return ConvoyProgressStyle.Render(bar)
|
||||
}
|
||||
|
||||
// formatConvoyAge formats duration for convoy display
|
||||
func formatConvoyAge(d time.Duration) string {
|
||||
if d < time.Minute {
|
||||
return "just now"
|
||||
}
|
||||
if d < time.Hour {
|
||||
return fmt.Sprintf("%dm", int(d.Minutes()))
|
||||
}
|
||||
if d < 24*time.Hour {
|
||||
return fmt.Sprintf("%dh", int(d.Hours()))
|
||||
}
|
||||
return fmt.Sprintf("%dd", int(d.Hours()/24))
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ func (m *Model) renderShortHelp() string {
|
||||
// formatAge formats a duration as a short age string
|
||||
func formatAge(d time.Duration) string {
|
||||
if d < time.Minute {
|
||||
return fmt.Sprintf("%ds", int(d.Seconds()))
|
||||
return "just now"
|
||||
}
|
||||
if d < time.Hour {
|
||||
return fmt.Sprintf("%dm", int(d.Minutes()))
|
||||
|
||||
Reference in New Issue
Block a user