#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <general.h>
#include <rfc1123date.h>
#include <stringtools.h>
using namespace std;
char *rfc_months[12]=
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"
};
char *rfc_wdays[12]=
{
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
string make_date(const time_t &gm_time, long diff)
{
struct tm tm;
char s[TEXTLEN];
time_t local_time=gm_time+diff;
tm=*gmtime(&local_time);
snprintf(s, TEXTLEN, "%s, %02d %s %d %02d:%02d:%02d",
rfc_wdays[tm.tm_wday], tm.tm_mday, rfc_months[tm.tm_mon],
tm.tm_year+1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
string date=s;
snprintf(s, TEXTLEN, " %c%02ld%02ld",
(diff>=0)?'+':'-', (labs(diff)/3600)%24, labs(diff)%60);
date+=s;
return date;
}
syntax highlighted by Code2HTML, v. 0.9.1