diff --git a/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c b/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c index 3e5fa2b4e4..099c9a3797 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c @@ -1,3 +1,4 @@ +#include "stddef.h" #include #include #include @@ -9,18 +10,24 @@ const char *mon_str[12]={"Jan", "Feb", "Mar", "Ap", "May", "Jun", "Jul", "Aug", #pragma GCC push_options #pragma GCC optimize("O0") +#define TIME_STR_MAX 27 + char *asctime(const struct tm *tm){ - static char time_str[30]; - if(tm->tm_wday>7 || tm->tm_wday<1 || tm->tm_mon<1 || tm->tm_mon>12){ + if(!tm){ errno = EINVAL; return NULL; } - snprintf(time_str, 26, "%.3s %.3s%3d %2d:%2d:%2d %d\n", - wday_str[tm->tm_wday-1], - mon_str[tm->tm_mon-1], - tm->tm_mday, tm->tm_hour, - tm->tm_min, tm->tm_sec, - 1900 + tm->tm_year + 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; } diff --git a/programs/develop/ktcc/trunk/libc.obj/source/time/mktime.c b/programs/develop/ktcc/trunk/libc.obj/source/time/mktime.c index a41c5c4f20..e5cbbae04f 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/time/mktime.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/time/mktime.c @@ -2,7 +2,7 @@ time_t mktime (struct tm * timeptr) { - int utcdiff = -3; +// int utcdiff = -3; const int mon_days [] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; unsigned long int tyears, tdays, leaps, utc_hrs; int i; @@ -17,7 +17,7 @@ time_t mktime (struct tm * timeptr) tdays += timeptr->tm_mday-1; // days of month passed. tdays = tdays + (tyears * 365) + leaps; - utc_hrs = timeptr->tm_hour + utcdiff; // for your time zone. - return (tdays * 86400) + (utc_hrs * 3600) + (timeptr->tm_min * 60) + timeptr->tm_sec; +// utc_hrs = timeptr->tm_hour + utcdiff; // for your time zone. + return (tdays * 86400) + (timeptr->tm_hour * 3600) + (timeptr->tm_min * 60) + timeptr->tm_sec; } diff --git a/programs/develop/ktcc/trunk/libc.obj/source/time/time.c b/programs/develop/ktcc/trunk/libc.obj/source/time/time.c index 1e772dfd1f..b53916a696 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/time/time.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/time/time.c @@ -1,9 +1,8 @@ #include #include -static struct tm __buffertime; - time_t time(time_t *timer){ + static struct tm __buffertime; int kos_date, kos_time; kos_date = _ksys_get_date().val; kos_time = _ksys_get_time().val; @@ -29,6 +28,5 @@ time_t time(time_t *timer){ if(timer){ *timer=ret; } - return ret; }