MCPcopy Create free account
hub / github.com/compozy/agh / formatAge

Function formatAge

internal/cli/format.go:370–390  ·  view source on GitHub ↗
(now func() time.Time, then time.Time)

Source from the content-addressed store, hash-verified

368}
369
370func formatAge(now func() time.Time, then time.Time) string {
371 if then.IsZero() {
372 return ""
373 }
374 current := time.Now().UTC()
375 if now != nil {
376 current = now().UTC()
377 }
378 delta := max(current.Sub(then.UTC()), 0)
379
380 switch {
381 case delta < time.Minute:
382 return fmt.Sprintf("%ds", int(delta.Seconds()))
383 case delta < time.Hour:
384 return fmt.Sprintf("%dm", int(delta.Minutes()))
385 case delta < 24*time.Hour:
386 return fmt.Sprintf("%dh", int(delta.Hours()))
387 default:
388 return fmt.Sprintf("%dd", int(delta.Hours()/24))
389 }
390}
391
392func stringOrDash(value string) string {
393 trimmed := strings.TrimSpace(value)

Callers 12

daemonStatusBundleFunction · 0.85
bridgeListBundleFunction · 0.85
bridgeRoutesBundleFunction · 0.85
bridgeTargetsBundleFunction · 0.85
TestFormatHelpersFunction · 0.85
renderStatusHumanFunction · 0.85
renderStatusToonFunction · 0.85
renderSessionHumanFunction · 0.85
sessionListBundleFunction · 0.85
vaultRecordsBundleFunction · 0.85
memoryListBundleFunction · 0.85
memoryHistoryBundleFunction · 0.85

Calls 2

IsZeroMethod · 0.45
NowMethod · 0.45

Tested by 1

TestFormatHelpersFunction · 0.68