rfc822-date.c revision 0768959c7e9fc363a353ce45605e4dbd1f46f29e
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "utc-offset.h"
#include "utc-mktime.h"
#include "rfc822-date.h"
#include "rfc822-tokenize.h"
#include <ctype.h>
static const char *month_names[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
static const char *weekday_names[] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
{
int offset;
char chr;
/* numeric offset */
return FALSE;
}
if (len == 1) {
/* military zone - handle them the correct way, not as
RFC822 says. RFC2822 though suggests that they'd be
considered as unspecified.. */
if (chr < 'J')
if (chr == 'J')
return 0;
if (chr <= 'M')
if (chr < 'Z')
return 0;
}
/* UT - Universal Time */
return 0;
}
if (len == 3) {
/* GMT | [ECMP][DS]T */
return 0;
case 'E':
break;
case 'C':
break;
case 'M':
break;
case 'P':
break;
default:
/* GMT and others */
return 0;
}
return offset + 60;
return offset;
}
return 0;
}
{
if (token == 'A')
return token;
}
int *timezone_offset)
{
const char *value;
/* [weekday_name "," ] dd month_name [yy]yy hh:mi[:ss] timezone */
/* skip the optional weekday */
if (token != ',')
return FALSE;
}
/* dd */
return FALSE;
if (len == 2) {
return FALSE;
}
/* month name */
return FALSE;
for (i = 0; i < 12; i++) {
break;
}
}
if (i == 12)
return FALSE;
/* [yy]yy */
return FALSE;
for (i = 0; i < len; i++) {
return FALSE;
}
if (len == 2) {
/* two digit year, assume 1970+ */
} else {
return FALSE;
}
/* hh */
return FALSE;
/* :mm */
if (token != ':')
return FALSE;
return FALSE;
/* [:ss] */
if (token == ':') {
return FALSE;
}
/* timezone */
if (token != 'A')
return FALSE;
return FALSE;
*time -= *timezone_offset;
return TRUE;
}
{
int ret;
return FALSE;
return ret;
}
{
if (offset >= 0)
negative = 0;
else {
negative = 1;
}
return t_strdup_printf("%s, %02d %s %04d %02d:%02d:%02d %c%02d%02d",
}