1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

Userland: Pretty-print modification times in /bin/ls.

This commit is contained in:
Andreas Kling 2019-02-03 02:14:41 +01:00
parent 5751063c63
commit 10fde0d707

View file

@ -4,6 +4,7 @@
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <AK/AKString.h>
@ -162,7 +163,14 @@ int do_dir(const char* path)
else
printf(" %10u ", st.st_size);
printf(" %10u ", st.st_mtime);
auto* tm = localtime(&st.st_mtime);
printf(" %4u-%02u-%02u %02u:%02u:%02u ",
tm->tm_year + 1900,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
print_name(st, de->d_name, pathbuf);