4 * Function to generate RFC822-compliant textual time/date stamp
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
23 # include <sys/time.h>
32 static char *months[] = {
33 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
34 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
37 static char *weekdays[] = {
38 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
43 * Supplied with a unix timestamp, generate an RFC822-compliant textual
44 * time and date stamp.
46 void datestring(char *buf, size_t n, time_t xtime, int which_format) {
52 localtime_r(&xtime, &t);
54 /* Convert "seconds west of GMT" to "hours/minutes offset" */
55 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
67 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
69 switch(which_format) {
71 case DATESTRING_RFC822:
72 snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
85 snprintf(buf, n, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",