FormatAgeTag returns a colored "[Xd]" age badge for an AUR package's LastModified timestamp. Returns "" when no AUR LastModified timestamp is available.
(lastModified int64)
| 41 | // FormatAgeTag returns a colored "[Xd]" age badge for an AUR package's LastModified timestamp. |
| 42 | // Returns "" when no AUR LastModified timestamp is available. |
| 43 | func 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). |
| 62 | func FormatTime(i int) string { |
no test coverage detected