Continue PR: configure time format in the info column (#751)
* Allow to configure time format in the info column * Update infotimefmt PR from Krzysztof Maicher Add format length, rename options Co-authored-by: Krzysztof Maicher <krzysztof.maicher@gmail.com>
This commit is contained in:
1 parent
cbb80a0d44
commit
b08ab8dfb7
7 files changed
+55
-5
No files matched your search
@@ -279,9 +279,9 @@ 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(gOpts.infotimefmtnew)
|
||||
}
|
||||
return t.Format("Jan _2 2006")
|
||||
return t.Format(gOpts.infotimefmtold)
|
||||
}
|
||||
|
||||
func fileInfo(f *file, d *dir) string {
|
||||
@@ -328,11 +328,11 @@ func fileInfo(f *file, d *dir) string {
|
||||
info = fmt.Sprintf("%s 999+", info)
|
||||
}
|
||||
case "time":
|
||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.ModTime()))
|
||||
info = fmt.Sprintf(fmt.Sprint("%"+"s %", gInfotimefmtMaxLen, "s"), info, infotimefmt(f.ModTime()))
|
||||
case "atime":
|
||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.accessTime))
|
||||
info = fmt.Sprintf(fmt.Sprint("%"+"s %", gInfotimefmtMaxLen, "s"), info, infotimefmt(f.accessTime))
|
||||
case "ctime":
|
||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.changeTime))
|
||||
info = fmt.Sprintf(fmt.Sprint("%"+"s %", gInfotimefmtMaxLen, "s"), info, infotimefmt(f.changeTime))
|
||||
default:
|
||||
log.Printf("unknown info type: %s", s)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user