* Fixed up the "Date:" headers to be RFC822-compliant
[citadel.git] / citadel / genstamp.c
1 /*
2  * Function to generate RFC822-compliant textual time/date stamp
3  *
4  * $Id$
5  *
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <ctype.h>
11 #include <string.h>
12 #include <time.h>
13 #include "genstamp.h"
14
15
16 static char *months[] = {
17         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
18         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
19 };
20
21 static char *weekdays[] = {
22         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
23 };
24
25
26 /*
27  * Supplied with a unix timestamp, generate an RFC822-compliant textual
28  * time and date stamp.
29  */
30 void generate_rfc822_datestamp(char *buf, time_t xtime) {
31         struct tm *t;
32
33         t = localtime(&xtime);
34
35         sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %s",
36                 weekdays[t->tm_wday],
37                 t->tm_mday,
38                 months[t->tm_mon],
39                 t->tm_year + 1900,
40                 t->tm_hour,
41                 t->tm_min,
42                 t->tm_sec,
43                 tzname[0]
44                 );
45 }
46