]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/asctime.c
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / common / asctime.c
index 76c7d92f94519986d3421048ad4fcfc656e19202..15450425ecda96a710797939300e99b21732014e 100644 (file)
 
 
 
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
 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;
 }