MCPcopy
hub / github.com/Jguer/yay / FormatAgeTag

Function FormatAgeTag

pkg/text/time.go:43–59  ·  view source on GitHub ↗

FormatAgeTag returns a colored "[Xd]" age badge for an AUR package's LastModified timestamp. Returns "" when no AUR LastModified timestamp is available.

(lastModified int64)

Source from the content-addressed store, hash-verified

41// FormatAgeTag returns a colored "[Xd]" age badge for an AUR package's LastModified timestamp.
42// Returns "" when no AUR LastModified timestamp is available.
43func FormatAgeTag(lastModified int64) string {
44 if lastModified == 0 {
45 return ""
46 }
47
48 age := NowFunc().Sub(time.Unix(lastModified, 0))
49 tag := "[" + FormatDuration(age) + "]"
50
51 switch {
52 case age < veryRecentPkgThreshold:
53 return Bold(Red(tag))
54 case age < recentPkgThreshold:
55 return Bold(Yellow(tag))
56 default:
57 return Cyan(tag)
58 }
59}
60
61// Formats a unix timestamp to ISO 8601 date (yyyy-mm-dd).
62func FormatTime(i int) string {

Callers 4

printUpdateListFunction · 0.92
aurPkgSearchStringFunction · 0.92
PrintMethod · 0.92
PrintDepsMethod · 0.92

Calls 5

FormatDurationFunction · 0.85
BoldFunction · 0.85
RedFunction · 0.85
YellowFunction · 0.85
CyanFunction · 0.85

Tested by

no test coverage detected