From daa06599e44d51ba4a9a4fa7145b5251ce231c8c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 9 Dec 2022 11:38:22 -0800 Subject: [PATCH] stat: avoid unix epoch time when printing date (#4398) --- cmd/stat.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/stat.go b/cmd/stat.go index 92eb5217..7e865429 100644 --- a/cmd/stat.go +++ b/cmd/stat.go @@ -248,7 +248,7 @@ func statURL(ctx context.Context, targetURL, versionID string, timeRef time.Time contentURL = strings.TrimPrefix(contentURL, prefixPath) bstat.URL.Path = contentURL - if bstat.Date.IsZero() || bstat.Date.Equal(time.Unix(0, 0)) { + if bstat.Date.IsZero() || bstat.Date.Equal(timeSentinel) { bstat.Date = content.Time } var bu madmin.BucketUsageInfo @@ -400,7 +400,9 @@ func (v bucketInfoMessage) String() string { keyStr = strings.TrimSuffix(keyStr, slashSeperator) key := fmt.Sprintf("%-10s: %s", "Name", keyStr) b.WriteString(console.Colorize("Title", key) + "\n") - b.WriteString(fmt.Sprintf("%-10s: %s ", "Date", v.Date.Format(printDate)) + "\n") + if !v.Date.IsZero() && !v.Date.Equal(timeSentinel) { + b.WriteString(fmt.Sprintf("%-10s: %s ", "Date", v.Date.Format(printDate)) + "\n") + } b.WriteString(fmt.Sprintf("%-10s: %-6s \n", "Size", humanize.IBytes(uint64(v.Size)))) fType := func() string {