diff options
Diffstat (limited to 'date822fmt.c')
| -rw-r--r-- | date822fmt.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/date822fmt.c b/date822fmt.c new file mode 100644 index 0000000..7674bd1 --- /dev/null +++ b/date822fmt.c | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #include "datetime.h" | ||
| 2 | #include "fmt.h" | ||
| 3 | #include "date822fmt.h" | ||
| 4 | |||
| 5 | static char *montab[12] = { | ||
| 6 | "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" | ||
| 7 | }; | ||
| 8 | |||
| 9 | unsigned int date822fmt(s,dt) | ||
| 10 | char *s; | ||
| 11 | struct datetime *dt; | ||
| 12 | { | ||
| 13 | unsigned int i; | ||
| 14 | unsigned int len; | ||
| 15 | len = 0; | ||
| 16 | i = fmt_uint(s,dt->mday); len += i; if (s) s += i; | ||
| 17 | i = fmt_str(s," "); len += i; if (s) s += i; | ||
| 18 | i = fmt_str(s,montab[dt->mon]); len += i; if (s) s += i; | ||
| 19 | i = fmt_str(s," "); len += i; if (s) s += i; | ||
| 20 | i = fmt_uint(s,dt->year + 1900); len += i; if (s) s += i; | ||
| 21 | i = fmt_str(s," "); len += i; if (s) s += i; | ||
| 22 | i = fmt_uint0(s,dt->hour,2); len += i; if (s) s += i; | ||
| 23 | i = fmt_str(s,":"); len += i; if (s) s += i; | ||
| 24 | i = fmt_uint0(s,dt->min,2); len += i; if (s) s += i; | ||
| 25 | i = fmt_str(s,":"); len += i; if (s) s += i; | ||
| 26 | i = fmt_uint0(s,dt->sec,2); len += i; if (s) s += i; | ||
| 27 | i = fmt_str(s," -0000\n"); len += i; if (s) s += i; | ||
| 28 | return len; | ||
| 29 | } | ||
