7 static int fb_hIsMonth(
const char *text,
size_t text_len,
const char **end_text,
int short_name,
int localized )
9 const char *txt_end = text;
11 for( month=1; month!=13; ++month ) {
16 size_t len = ((text_len < month_len) ? text_len : month_len );
20 if( text_len > len ) {
48 static int fb_hFindMonth(
const char *text,
size_t text_len,
const char **end_text )
51 for( short_name=0; short_name!=2; ++short_name ) {
53 while( localized-- ) {
54 int month =
fb_hIsMonth( text, text_len, end_text, short_name, localized );
64 static int fb_hDateOrder(
int *pOrderDay,
int *pOrderMonth,
int *pOrderYear )
66 int order_month = 0, order_day = 1, order_year = 2, order_index = 0;
68 char short_format[90];
76 for( tmp=0; short_format[tmp]; ++tmp ) {
82 order_day = order_index;
86 order_month = order_index;
90 order_year = order_index;
102 if( order_day==order_month || order_day==order_year || order_month==order_year )
104 if( order_day > 2 || order_month > 2 || order_year > 2 )
108 *pOrderDay = order_day;
110 *pOrderMonth = order_month;
112 *pOrderYear = order_year;
132 int *pDay,
int *pMonth,
int *pYear,
135 size_t length = 0, len = text_len;
136 const char *text_start = text;
138 int year = 1899, month = 12, day = 30;
139 int order_year, order_month, order_day;
140 const char *end_month;
142 if( !
fb_hDateOrder( &order_day, &order_month, &order_year ) ) {
150 while ( isspace( *text ) )
152 len = text_len - (text - text_start);
159 day = strtol( text, &endptr, 10 );
164 while ( isspace( *text ) )
169 year = strtol( ++text, &endptr, 10 );
170 year_size = endptr - text;
171 if( year_size > 0 ) {
193 day = strtol( text, &endptr, 10 );
194 day_size = endptr - text;
196 size_t month_size = 0;
202 while ( isspace( *text ) )
207 valid_divider = chDivider==
'-' || chDivider==
'/' || chDivider==
'.';
208 if( chDivider==
'.' ) {
211 while ( isspace( *text ) )
213 len = text_len - (text - text_start);
217 is_short_form = month==0;
218 }
else if( valid_divider ) {
220 is_short_form =
TRUE;
222 is_short_form =
FALSE;
224 if( is_short_form ) {
227 while ( isspace( *text ) )
229 month = strtol( text, &endptr, 10 );
230 month_size = endptr - text;
234 while ( isspace( *text ) )
236 if( *text==chDivider ) {
243 len = text_len - (text - text_start);
248 while ( isspace( *text ) )
261 while ( isspace( *text ) )
263 year = strtol( text, &endptr, 10 );
264 year_size = endptr - text;
265 if( year_size > 0 ) {
267 if( is_short_form ) {
268 int tmp_day =
InlineSelect( order_day, day, month, year );
269 int tmp_month =
InlineSelect( order_month, day, month, year );
270 int tmp_year =
InlineSelect( order_year, day, month, year );
271 year_size =
InlineSelect( order_year, day_size, month_size, year_size );
275 if( day < 1 || month < 1 || month > 12 )
294 length = text - text_start;