use year instead of hh:mm for old files in info

Related #507
This commit is contained in:
Gokcehan 2020-11-22 17:18:17 +03:00
parent c629b3d4ce
commit ce5c5845e7

15
ui.go
View File

@ -262,6 +262,15 @@ func (win *win) printReg(screen tcell.Screen, reg *reg) {
}
}
var gThisYear = time.Now().Year()
func infotimefmt(t time.Time) string {
if t.Year() == gThisYear {
return t.Format("Jan _2 15:04")
}
return t.Format("Jan _2 2006")
}
func fileInfo(f *file, d *dir) string {
var info string
@ -300,11 +309,11 @@ func fileInfo(f *file, d *dir) string {
info = fmt.Sprintf("%s 999+", info)
}
case "time":
info = fmt.Sprintf("%s %12s", info, f.ModTime().Format("Jan _2 15:04"))
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.ModTime()))
case "atime":
info = fmt.Sprintf("%s %12s", info, f.accessTime.Format("Jan _2 15:04"))
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.accessTime))
case "ctime":
info = fmt.Sprintf("%s %12s", info, f.changeTime.Format("Jan _2 15:04"))
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.changeTime))
default:
log.Printf("unknown info type: %s", s)
}