From 6dc5cda50d8bc0d3179928780cbb2c62c396601a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 6 Sep 2020 19:12:21 +0200 Subject: [PATCH] Userland: Bring back improved "LOGIN@" column in "w" This actually looks a lot nicer if we slim down the datetime format. Also remove the "FROM" column which was the one I actually didn't want. --- Userland/w.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/w.cpp b/Userland/w.cpp index 4d2124ae60..d4059f7326 100644 --- a/Userland/w.cpp +++ b/Userland/w.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -53,13 +54,15 @@ int main() auto now = time(nullptr); printf("\033[1m%-10s %-12s %-16s %-6s %s\033[0m\n", - "USER", "TTY", "FROM", "IDLE", "WHAT"); + "USER", "TTY", "LOGIN@", "IDLE", "WHAT"); json.value().as_object().for_each_member([&](auto& tty, auto& value) { const JsonObject& entry = value.as_object(); auto uid = entry.get("uid").to_u32(); auto pid = entry.get("pid").to_i32(); (void)pid; - auto from = entry.get("from").to_string(); + + auto login_time = Core::DateTime::from_timestamp(entry.get("login_at").to_number()); + auto login_at = login_time.to_string("%b%d %H:%M:%S"); auto* pw = getpwuid(uid); String username; @@ -89,7 +92,7 @@ int main() printf("%-10s %-12s %-16s %-6s %s\n", username.characters(), tty.characters(), - from.characters(), + login_at.characters(), idle_string.characters(), what.characters()); });