cde4fa851d
- Formatted by clang-format (WebKit-style). - Removed unnecessary errno linux. - Added KOS error codes. - String functions have been replaced with more optimal ones for x86. - Changed wrappers for 70 sysfunction. git-svn-id: svn://kolibrios.org@9765 a494cfbc-eb01-0410-851d-a64ba20cac60
35 lines
926 B
C
35 lines
926 B
C
#include "stddef.h"
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
const char* wday_str[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
|
|
const char* mon_str[12] = { "Jan", "Feb", "Mar", "Ap", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
|
|
|
#pragma GCC push_options
|
|
#pragma GCC optimize("O0")
|
|
|
|
#define TIME_STR_MAX 27
|
|
|
|
char* asctime(const struct tm* tm)
|
|
{
|
|
if (!tm) {
|
|
__errno = EINVAL;
|
|
return NULL;
|
|
}
|
|
if (tm->tm_wday > 6 || tm->tm_wday < 0 || tm->tm_mon < 0 || tm->tm_mon > 11) {
|
|
errno = EINVAL;
|
|
return NULL;
|
|
}
|
|
static char time_str[TIME_STR_MAX];
|
|
snprintf(time_str, TIME_STR_MAX - 1, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
|
|
wday_str[tm->tm_wday],
|
|
mon_str[tm->tm_mon],
|
|
tm->tm_mday, tm->tm_hour,
|
|
tm->tm_min, tm->tm_sec,
|
|
1900 + tm->tm_year);
|
|
return time_str;
|
|
}
|
|
#pragma GCC pop_options
|