69 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat" 73 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
74 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" 80 0, 31, 59, 90, 120, 151,
81 181, 212, 243, 273, 304, 334
86 #define HOUR (60 * MINUTE) 87 #define DAY (24 * HOUR) 99 if (tm.tm_wday < 0 || tm.tm_wday > 6 ||
100 tm.tm_mday < 0 || tm.tm_mday > 31 ||
101 tm.tm_mon < 0 || tm.tm_mon > 11 ||
103 tm.tm_hour < 0 || tm.tm_hour > 23 ||
104 tm.tm_min < 0 || tm.tm_min > 59 ||
105 tm.tm_sec < 0 || tm.tm_sec > 61) {
106 warning(0,
"Bad date for timestamp %lu, cannot format.",
111 sprintf(buffer,
"%s, %02d %s %04d %02d:%02d:%02d GMT",
113 tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
135 leapyears = (year / 4) - (year / 100) + (year / 400) - 477;
163 if (
octstr_len(
date) - pos < (
long)strlen(
"06 Nov 1994 08:49:37 GMT"))
179 if (
octstr_len(
date) - pos < (
long)strlen(
"06-Nov-94 08:49:37 GMT"))
245 if (sscanf(p,
"%4ld%n", &ut->
year, &n) < 1)
251 else if (ut->
year < 100)
256 if (sscanf(p,
"%2ld%n", &ut->
month, &n) < 1)
266 if (sscanf(p,
"%2ld%n", &ut->
day, &n) < 1)
277 if (sscanf(p,
"%2ld%n", &ut->
hour, &n) < 1)
283 if (sscanf(p,
"%2ld%n", &ut->
minute, &n) < 1)
289 if (sscanf(p,
"%2ld%n", &ut->
second, &n) < 1)
297 if (sscanf(p,
"%ld%n", &fract, &n) < 1)
311 if (sscanf(p,
"%2ld%n", &hh, &n) < 1)
317 if (sscanf(p,
"%2ld%n", &mi, &n) > 1)
335 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
342 return (
long) time(NULL);
void error(int err, const char *fmt,...)
long date_parse_http(Octstr *date)
struct tm gw_gmtime(time_t t)
Octstr * date_create_iso(time_t unixtime)
static char const * wkday[7]
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
long octstr_search_char(const Octstr *ostr, int ch, long pos)
void warning(int err, const char *fmt,...)
Octstr * octstr_format(const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
int date_parse_iso(struct universaltime *ut, Octstr *os)
long date_universal_now(void)
long octstr_len(const Octstr *ostr)
int octstr_str_compare(const Octstr *ostr, const char *str)
long octstr_parse_long(long *nump, Octstr *ostr, long pos, int base)
Octstr * date_format_http(unsigned long unixtime)
static char const * monthname[12]
long date_convert_universal(struct universaltime *t)
int octstr_get_char(const Octstr *ostr, long pos)
static int monthstart[12]