From 3ae75e04ece531165f75bfdb1fb6f65af9ac60a1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 May 2019 16:50:36 +0200 Subject: [PATCH] date: Add "-u" argument for printing current Unix timestamp. --- Userland/date.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Userland/date.cpp b/Userland/date.cpp index 951cfb21cc..d280a7434f 100644 --- a/Userland/date.cpp +++ b/Userland/date.cpp @@ -1,12 +1,16 @@ -#include -#include +#include +#include +#include int main(int argc, char** argv) { - (void) argc; - (void) argv; - time_t now = time(nullptr); + + if (argc == 2 && !strcmp(argv[1], "-u")) { + printf("%u\n", now); + return 0; + } + auto* tm = localtime(&now); printf("%4u-%02u-%02u %02u:%02u:%02u\n", tm->tm_year + 1900,