Subversion Repositories Kolibri OS

Rev

Rev 8787 | Rev 9765 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <errno.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <stdio.h>
  5.  
  6. const char *wday_str[7]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
  7. const char *mon_str[12]={"Jan", "Feb", "Mar", "Ap", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  8.  
  9. #pragma GCC push_options
  10. #pragma GCC optimize("O0")
  11.  
  12. char *asctime(const struct tm *tm){
  13.         static char time_str[30];
  14.     if(tm->tm_wday>7 || tm->tm_wday<1 || tm->tm_mon<1 || tm->tm_mon>12){
  15.         errno = EINVAL;
  16.         return NULL;
  17.     }
  18.     snprintf(time_str, 26, "%.3s %.3s%3d %2d:%2d:%2d %d\n",
  19.         wday_str[tm->tm_wday-1],
  20.         mon_str[tm->tm_mon-1],
  21.                 tm->tm_mday, tm->tm_hour,
  22.                 tm->tm_min, tm->tm_sec,
  23.                 1900 + tm->tm_year
  24.     );
  25.     return time_str;
  26. }
  27. #pragma GCC pop_options
  28.