]> mj.ucw.cz Git - ywho.git/commitdiff
Better formatting of current time
authorMartin Mares <mj@ucw.cz>
Fri, 20 Aug 2010 15:29:20 +0000 (17:29 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 20 Aug 2010 15:29:20 +0000 (17:29 +0200)
Use strftime(), drop UE and display years in 4 digits.

ywho.c

diff --git a/ywho.c b/ywho.c
index 09e8cc55b718ed9df93b12490293570f82124446..192c308a10f04e05e41b17bd9cea6fff5fd59b39 100644 (file)
--- 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);
   }
 }