Rev 8793 | Rev 9765 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9260 | turbocat | 1 | #include "stddef.h" |
8787 | turbocat | 2 | #include |
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | |||
7 | const char *wday_str[7]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; |
||
8 | const char *mon_str[12]={"Jan", "Feb", "Mar", "Ap", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; |
||
9 | |||
10 | #pragma GCC push_options |
||
11 | #pragma GCC optimize("O0") |
||
12 | |||
9260 | turbocat | 13 | #define TIME_STR_MAX 27 |
14 | |||
8787 | turbocat | 15 | char *asctime(const struct tm *tm){ |
9260 | turbocat | 16 | if(!tm){ |
8787 | turbocat | 17 | errno = EINVAL; |
18 | return NULL; |
||
19 | } |
||
9260 | turbocat | 20 | if(tm->tm_wday>6 || tm->tm_wday<0 || tm->tm_mon<0 || tm->tm_mon>11){ |
21 | errno = EINVAL; |
||
22 | return NULL; |
||
23 | } |
||
24 | static char time_str[TIME_STR_MAX]; |
||
25 | snprintf(time_str, TIME_STR_MAX-1, "%.3s %.3s%3d %02d:%02d:%02d %d\n", |
||
26 | wday_str[tm->tm_wday], |
||
27 | mon_str[tm->tm_mon], |
||
28 | tm->tm_mday, tm->tm_hour, |
||
29 | tm->tm_min, tm->tm_sec, |
||
30 | 1900 + tm->tm_year |
||
8787 | turbocat | 31 | ); |
32 | return time_str; |
||
33 | } |
||
34 | #pragma GCC pop_options0>0> |