nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

myctime.c (873B)


      1 #include "myctime.h"
      2 
      3 #include "datetime.h"
      4 #include "fmt.h"
      5 
      6 static char *daytab[7] = {
      7 "Sun","Mon","Tue","Wed","Thu","Fri","Sat"
      8 };
      9 static char *montab[12] = {
     10 "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
     11 };
     12 
     13 static char result[30];
     14 
     15 char *myctime(t)
     16 datetime_sec t;
     17 {
     18  struct datetime dt;
     19  unsigned int len;
     20  datetime_tai(&dt,t);
     21  len = 0;
     22  len += fmt_str(result + len,daytab[dt.wday]);
     23  result[len++] = ' ';
     24  len += fmt_str(result + len,montab[dt.mon]);
     25  result[len++] = ' ';
     26  len += fmt_uint0(result + len,dt.mday,2);
     27  result[len++] = ' ';
     28  len += fmt_uint0(result + len,dt.hour,2);
     29  result[len++] = ':';
     30  len += fmt_uint0(result + len,dt.min,2);
     31  result[len++] = ':';
     32  len += fmt_uint0(result + len,dt.sec,2);
     33  result[len++] = ' ';
     34  len += fmt_uint(result + len,1900 + dt.year);
     35  result[len++] = '\n';
     36  result[len++] = 0;
     37  return result;
     38 }