4 * Function to generate RFC822-compliant textual time/date stamp
13 #if TIME_WITH_SYS_TIME
14 # include <sys/time.h>
18 # include <sys/time.h>
27 static char *months[] = {
28 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
29 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
32 static char *weekdays[] = {
33 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
38 * Supplied with a unix timestamp, generate an RFC822-compliant textual
39 * time and date stamp.
41 void datestring(char *buf, time_t xtime, int which_format) {
47 t = localtime(&xtime);
49 /* Convert "seconds west of GMT" to "hours/minutes offset" */
58 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
60 switch(which_format) {
62 case DATESTRING_RFC822:
63 sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
76 sprintf(buf, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",