4 * Function to generate RFC822-compliant textual time/date stamp
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
24 # include <sys/time.h>
33 static char *months[] = {
34 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
35 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
38 static char *weekdays[] = {
39 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
44 * Supplied with a unix timestamp, generate an RFC822-compliant textual
45 * time and date stamp.
47 void datestring(char *buf, time_t xtime, int which_format) {
53 t = localtime(&xtime);
55 /* Convert "seconds west of GMT" to "hours/minutes offset" */
56 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
57 offset = t->tm_gmtoff;
68 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
70 switch(which_format) {
72 case DATESTRING_RFC822:
73 sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
86 sprintf(buf, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",