date822fmt.c (923B)
1 #include "date822fmt.h" 2 3 #include "datetime.h" 4 #include "fmt.h" 5 6 static char *montab[12] = { 7 "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" 8 }; 9 10 unsigned int date822fmt(s,dt) 11 char *s; 12 struct datetime *dt; 13 { 14 unsigned int i; 15 unsigned int len; 16 len = 0; 17 i = fmt_uint(s,dt->mday); len += i; if (s) s += i; 18 i = fmt_str(s," "); len += i; if (s) s += i; 19 i = fmt_str(s,montab[dt->mon]); len += i; if (s) s += i; 20 i = fmt_str(s," "); len += i; if (s) s += i; 21 i = fmt_uint(s,dt->year + 1900); len += i; if (s) s += i; 22 i = fmt_str(s," "); len += i; if (s) s += i; 23 i = fmt_uint0(s,dt->hour,2); len += i; if (s) s += i; 24 i = fmt_str(s,":"); len += i; if (s) s += i; 25 i = fmt_uint0(s,dt->min,2); len += i; if (s) s += i; 26 i = fmt_str(s,":"); len += i; if (s) s += i; 27 i = fmt_uint0(s,dt->sec,2); len += i; if (s) s += i; 28 i = fmt_str(s," -0000\n"); len += i; if (s) s += i; 29 return len; 30 }