4 * Function to generate RFC822-compliant textual time/date stamp
14 #if TIME_WITH_SYS_TIME
15 # include <sys/time.h>
19 # include <sys/time.h>
28 static char *months[] = {
29 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
30 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
33 static char *weekdays[] = {
34 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
39 * Supplied with a unix timestamp, generate an RFC822-compliant textual
40 * time and date stamp.
42 void datestring(char *buf, size_t n, time_t xtime, int which_format) {
48 localtime_r(&xtime, &t);
50 /* Convert "seconds west of GMT" to "hours/minutes offset" */
51 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
63 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
65 switch(which_format) {
67 case DATESTRING_RFC822:
68 snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
81 snprintf(buf, n, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",