@@ -114,6 +114,7 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
114114 int format_len ,
115115 FormatRequirement format_requirement ,
116116 double threshold ) {
117+ printf ("Start %s\n" , str );
117118 if (len < 0 || format_len < 0 )
118119 goto parse_error ;
119120 int year_leap = 0 ;
@@ -189,7 +190,7 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
189190 goto finish ;
190191 }
191192 to_month = 1 ;
192- goto find_sep ;
193+ goto year_sep ;
193194 } else if (comparison == COMPLETED_PARTIAL_MATCH ) {
194195 valid_components ++ ;
195196 goto finish ;
@@ -216,7 +217,7 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
216217 substr += 3 ;
217218 sublen -= 3 ;
218219 to_month = 1 ;
219- goto find_sep ;
220+ goto year_sep ;
220221 }
221222 } else if (sublen == 3 && isdigit (substr [0 ]) && isdigit (substr [1 ]) &&
222223 isdigit (substr [2 ])) {
@@ -237,9 +238,9 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
237238 substr += 2 ;
238239 sublen -= 2 ;
239240 to_month = 1 ;
240- goto find_sep ;
241+ goto year_sep ;
241242 }
242- goto find_sep ;
243+ goto year_sep ;
243244 } else if (sublen == 2 && isdigit (substr [0 ]) && isdigit (substr [1 ])) {
244245 invalid_components ++ ;
245246 substr += 2 ;
@@ -257,7 +258,7 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
257258 substr += 1 ;
258259 sublen -= 1 ;
259260 to_month = 1 ;
260- goto find_sep ;
261+ goto year_sep ;
261262 }
262263 } else if (sublen == 1 && isdigit (substr [0 ])) {
263264 invalid_components ++ ;
@@ -274,7 +275,7 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
274275 if (valid_sep ) {
275276 invalid_components ++ ;
276277 to_month = 1 ;
277- goto find_sep ;
278+ goto year_sep ;
278279 }
279280 }
280281
@@ -301,34 +302,17 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
301302 goto finish ;
302303 }
303304 to_month = 1 ;
304- goto find_sep ;
305+ goto year_sep ;
305306 }
306307 if (!has_sep && sublen < 4 ) {
307308 invalid_components ++ ;
308309 substr += sublen ;
309310 sublen = 0 ;
310311 goto finish ;
311312 }
312- /*int still_more = 1;
313- for (i = 0; i < valid_ymd_sep_len; ++i) {
314- if (*substr == valid_ymd_sep[i]) {
315- still_more = 0;
316- break;
317- }
318- }
319- if (still_more) {
320- invalid_components++;
321- while (sublen > 0 && isdigit(substr[0])) {
322- substr++;
323- sublen--;
324- }
325- if (sublen == 0) {
326- goto finish;
327- }
328- to_month = 1;
329- goto find_sep;
330- }*/
331313
314+ year_sep :
315+ printf ("Now %s\n" , substr );
332316 /* Negate the year if necessary */
333317 if (str [0 ] == '-' ) {
334318 out -> year = - out -> year ;
@@ -342,7 +326,8 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
342326 * out_local = 0 ;
343327 }
344328 if (format_len ) {
345- invalid_components ++ ;
329+ if (invalid_components + valid_components < 1 )
330+ invalid_components ++ ;
346331 while (sublen > 1 && !isdigit (substr [1 ])) {
347332 substr ++ ;
348333 sublen -- ;
@@ -351,14 +336,13 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
351336 goto finish ;
352337 }
353338 to_month = 1 ;
354- goto find_sep ;
355339 }
356340 bestunit = NPY_FR_Y ;
357- valid_components ++ ;
341+ if (invalid_components + valid_components < 1 )
342+ valid_components ++ ;
358343 goto finish ;
359344 }
360345
361- find_sep :
362346 if (!isdigit (* substr )) {
363347 for (i = 0 ; i < valid_ymd_sep_len ; ++ i ) {
364348 if (* substr == valid_ymd_sep [i ]) {
@@ -479,7 +463,7 @@ int parse_iso_8601_datetime(const char *str, int len, int want_exc,
479463 goto finish ;
480464 }
481465 to_month = 1 ;
482- goto find_sep ;
466+ goto month_sep ;
483467 }
484468 if (!has_sep && sublen < 2 ) {
485469 invalid_components ++ ;
0 commit comments