diff options
| -rw-r--r-- | print.go | 23 | ||||
| -rw-r--r-- | statistics.go | 8 |
2 files changed, 13 insertions, 18 deletions
@@ -102,21 +102,14 @@ func printRecentActivity(installedVersion string, atime time.Time) { } // print usage info - var format string - var humanReadableDuration string - - humanReadableDuration = durafmt.ParseShort(time.Since(atime)).String() - format = func() string { - if atime.Nanosecond() == 0 { - return "► You never used this." - } else if time.Since(atime) < 24*7*time.Hour { - return "► You used this in %s." - } else { - return "► You haven't used this for %s." - } - }() - - color.Blue(format, humanReadableDuration) + humanReadableDuration := durafmt.ParseShort(time.Since(atime)).String() + if atime.Nanosecond() == 0 { + color.Blue("► You never used this.") + } else if time.Since(atime) < 24*7*time.Hour { + color.Blue("► You used this in %s.", humanReadableDuration) + } else { + color.Blue("► You haven't used this for %s.", humanReadableDuration) + } } // === #Section: Metadata# === // diff --git a/statistics.go b/statistics.go index 428d19c..c83a25f 100644 --- a/statistics.go +++ b/statistics.go @@ -58,13 +58,15 @@ func UnifyInfo(formula *FormulaInfo, cask *CaskInfo, pkgName string) (*statistic // === general === // // get system atime + var atime time.Time binPath := filepath.Join("/opt/homebrew/bin", pkgName) info, err := os.Stat(binPath) if err != nil { - return nil // skip if no binary is found + atime = time.Time{} // skip if no binary is found + } else { + atime = time.Unix(info.Sys().(*syscall.Stat_t).Atimespec.Unix()) } - atime := info.Sys().(*syscall.Stat_t).Atimespec - statObject.LastAccessTime = time.Unix(atime.Unix()) + statObject.LastAccessTime = atime return &statObject } |
