diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 797048f6c39..952556ce185 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -599,6 +600,19 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, nsh_output(vtbl, "%12" PRIdOFF, buf.st_size); } } + + /* Display modification time in long format */ + + if ((lsflags & LSFLAGS_LONG) != 0 && buf.st_mtime != 0) + { + struct tm tm; + char timebuf[20]; + time_t mtime = (time_t)buf.st_mtime; + + gmtime_r(&mtime, &tm); + strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M", &tm); + nsh_output(vtbl, " %s", timebuf); + } } /* Then provide the filename that is common to normal and verbose output */