MCPcopy Create free account
hub / github.com/Facets-cloud/flow / humanizeLastUsed

Function humanizeLastUsed

internal/app/workdir.go:119–138  ·  view source on GitHub ↗

humanizeLastUsed renders last_used_at as "(used 2d ago)" / "(never used)".

(ts sql.NullString, now time.Time)

Source from the content-addressed store, hash-verified

117
118// humanizeLastUsed renders last_used_at as "(used 2d ago)" / "(never used)".
119func humanizeLastUsed(ts sql.NullString, now time.Time) string {
120 if !ts.Valid || ts.String == "" {
121 return "(never used)"
122 }
123 t, err := time.Parse(time.RFC3339, ts.String)
124 if err != nil {
125 return "(used " + ts.String + ")"
126 }
127 d := now.Sub(t)
128 switch {
129 case d < time.Minute:
130 return "(used just now)"
131 case d < time.Hour:
132 return fmt.Sprintf("(used %dm ago)", int(d.Minutes()))
133 case d < 24*time.Hour:
134 return fmt.Sprintf("(used %dh ago)", int(d.Hours()))
135 default:
136 return fmt.Sprintf("(used %dd ago)", int(d.Hours()/24))
137 }
138}
139
140// cmdWorkdirAdd registers <path> (making it absolute), auto-detects git
141// remote from .git/config, and upserts. Accepts --name and --description

Callers 1

cmdWorkdirListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected