From: Martin Mares Date: Fri, 20 Aug 2010 15:29:20 +0000 (+0200) Subject: Better formatting of current time X-Git-Tag: v1.12~4 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=5062fd5a81e958da599768911663b3b86481e8f3;p=ywho.git Better formatting of current time Use strftime(), drop UE and display years in 4 digits. --- 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); } }