From 5062fd5a81e958da599768911663b3b86481e8f3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 20 Aug 2010 17:29:20 +0200 Subject: [PATCH] Better formatting of current time Use strftime(), drop UE and display years in 4 digits. --- ywho.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ywho.c b/ywho.c index 09e8cc5..192c308 100644 --- a/ywho.c +++ b/ywho.c @@ -256,13 +256,10 @@ line1(void) } { - struct tm *tm; - char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; now = time(NULL); - tm = localtime(&now); - printf(" on %s %02d-%02d-%02d %02d.%02d:%02d", days[tm->tm_wday], tm->tm_mday, tm->tm_mon+1, - tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec); - printf(" (%u UE)\n", (unsigned int) now); + struct tm *tm = localtime(&now); + strftime(line, sizeof(line), "%a %Y-%m-%d %H.%M:%S", tm); + printf(" on %s\n", line); } } -- 2.39.2