2 * Function to generate RFC822-compliant textual time/date stamp
11 #if TIME_WITH_SYS_TIME
12 # include <sys/time.h>
16 # include <sys/time.h>
25 static char *months[] = {
26 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
27 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
30 static char *weekdays[] = {
31 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
36 * Supplied with a unix timestamp, generate an RFC822-compliant textual
37 * time and date stamp.
39 long datestring(char *buf, size_t n, time_t xtime, int which_format) {
45 localtime_r(&xtime, &t);
47 /* Convert "seconds west of GMT" to "hours/minutes offset" */
48 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
60 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
62 switch(which_format) {
64 case DATESTRING_RFC822:
67 "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
82 "%02d-%s-%04d %02d:%02d:%02d %c%04ld",