@@ -204,45 +204,38 @@ def array_strptime(
204
204
else :
205
205
val = str (val)
206
206
207
- if (iso_format and not (fmt == " %Y%m%d " and len (val) != 8 )):
208
- # There is a fast-path for ISO8601-formatted strings.
209
- # BUT for %Y%m%d, it only works if the string is 8-digits long.
207
+ if iso_format:
210
208
string_to_dts_failed = string_to_dts(
211
209
val, & dts, & out_bestunit, & out_local,
212
210
& out_tzoffset, False , fmt, exact
213
211
)
214
- if string_to_dts_failed:
215
- # An error at this point is a _parsing_ error
216
- # specifically _not_ OutOfBoundsDatetime
217
- if is_coerce:
218
- iresult[i] = NPY_NAT
219
- continue
220
- raise ValueError (
221
- f" time data \" {val}\" at position {i} doesn't "
222
- f" match format \" {fmt}\" "
223
- )
224
- # No error reported by string_to_dts, pick back up
225
- # where we left off
226
- value = npy_datetimestruct_to_datetime(NPY_FR_ns, & dts)
227
- if out_local == 1 :
228
- # Store the out_tzoffset in seconds
229
- # since we store the total_seconds of
230
- # dateutil.tz.tzoffset objects
231
- # out_tzoffset_vals.add(out_tzoffset * 60.)
232
- tz = timezone(timedelta(minutes = out_tzoffset))
233
- result_timezone[i] = tz
234
- # value = tz_localize_to_utc_single(value, tz)
235
- out_local = 0
236
- out_tzoffset = 0
237
- iresult[i] = value
238
- try :
239
- check_dts_bounds(& dts)
240
- except ValueError :
241
- if is_coerce:
242
- iresult[i] = NPY_NAT
243
- continue
244
- raise
245
- continue
212
+ if not string_to_dts_failed:
213
+ # No error reported by string_to_dts, pick back up
214
+ # where we left off
215
+ value = npy_datetimestruct_to_datetime(NPY_FR_ns, & dts)
216
+ if out_local == 1 :
217
+ # Store the out_tzoffset in seconds
218
+ # since we store the total_seconds of
219
+ # dateutil.tz.tzoffset objects
220
+ # out_tzoffset_vals.add(out_tzoffset * 60.)
221
+ tz = timezone(timedelta(minutes = out_tzoffset))
222
+ result_timezone[i] = tz
223
+ # value = tz_localize_to_utc_single(value, tz)
224
+ out_local = 0
225
+ out_tzoffset = 0
226
+ iresult[i] = value
227
+ try :
228
+ check_dts_bounds(& dts)
229
+ except ValueError :
230
+ if is_coerce:
231
+ iresult[i] = NPY_NAT
232
+ continue
233
+ raise
234
+ continue
235
+
236
+ # Some ISO formats can't be parsed by string_to_dts
237
+ # For example, 6-digit YYYYMD. So, if there's an error,
238
+ # try the string-matching code below.
246
239
247
240
# exact matching
248
241
if exact:
0 commit comments