Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions nshlib/nsh_fscmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
Expand Down Expand Up @@ -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 */
Expand Down
Loading