/* asctime — форматирует struct tm как "Day Mon DD HH:MM:SS YYYY\n"
 * в статический буфер (перезаписывается следующим вызовом). */

#include <stdio.h>
#include <time.h>

static const char *const dnames[7] = {
    "Sun","Mon","Tue","Wed","Thu","Fri","Sat"
};
static const char *const mnames[12] = {
    "Jan","Feb","Mar","Apr","May","Jun",
    "Jul","Aug","Sep","Oct","Nov","Dec"
};

/* "Day Mon DD HH:MM:SS YYYY\n" — 25 символов + NUL. */
static char asctime_buf[26];

char *asctime(struct tm *tm)
{
    sprintf(asctime_buf, "%s %s %2d %02d:%02d:%02d %d\n",
            dnames[tm->tm_wday % 7],
            mnames[tm->tm_mon  % 12],
            tm->tm_mday,
            tm->tm_hour, tm->tm_min, tm->tm_sec,
            tm->tm_year + 1900);
    return asctime_buf;
}
