From 521f30c011345b86e08e10d9f65640e442aaf8e0 Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 13 Nov 2002 13:28:45 +0000 Subject: [PATCH] Call strftime instead of formatting the time manually git-svn-id: svn://svn.cc65.org/cc65/trunk@1515 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/common/asctime.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/libsrc/common/asctime.c b/libsrc/common/asctime.c index 3590e2462..15450425e 100644 --- a/libsrc/common/asctime.c +++ b/libsrc/common/asctime.c @@ -46,33 +46,10 @@ char* __fastcall__ asctime (const struct tm* timep) { - static const char days[7][4] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - static const char months[12][4] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; static char buf[26]; - /* Create a copy of the given data and make sure it is valid */ - struct tm t; - t = *timep; - mktime (&t); - - /* Format into given buffer */ - sprintf(buf, - "%s %s%3d %02d:%02d:%02d %d\n", - days[t.tm_wday], - months[t.tm_mon], - t.tm_mday, - t.tm_hour, - t.tm_min, - t.tm_sec, - t.tm_year + 1900); - - /* Return the result */ - return buf; + /* Format into given buffer and return the result */ + return strftime (buf, sizeof (buf), "%c\n", timep)? buf : 0; } -- 2.39.5