1 // This program is open source software. Use, duplication, or disclosure
2 // is subject to the terms of the GNU General Public License, version 3.
5 // Function to generate RFC822-compliant textual time/date stamp
15 static char *months[] = {
16 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
17 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
20 static char *weekdays[] = {
21 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
24 // Supplied with a unix timestamp, generate an RFC822-compliant textual
25 // time and date stamp.
26 long datestring(char *buf, size_t n, time_t xtime, int which_format) {
32 localtime_r(&xtime, &t);
34 // Convert "seconds west of GMT" to "hours/minutes offset"
35 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
47 offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
49 switch(which_format) {
51 case DATESTRING_RFC822:
54 "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
69 "%02d-%s-%04d %02d:%02d:%02d %c%04ld",