4 * Function to generate RFC822-compliant textual time/date stamp
17 #if TIME_WITH_SYS_TIME
18 # include <sys/time.h>
22 # include <sys/time.h>
31 static char *months[] = {
32 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
33 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
36 static char *weekdays[] = {
37 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
42 * Supplied with a unix timestamp, generate an RFC822-compliant textual
43 * time and date stamp.
45 void datestring(char *buf, time_t xtime, int which_format) {
51 t = localtime(&xtime);
53 /* Convert "seconds west of GMT" to "hours/minutes offset" */
54 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
55 offset = t->tm_gmtoff;
66 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
68 switch(which_format) {
70 case DATESTRING_RFC822:
71 sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
84 sprintf(buf, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",