@@ -2760,17 +2760,23 @@ def array_strptime(ndarray[object] values, object fmt, bint exact=True, bint coe
2760
2760
# Cannot pre-calculate datetime_date() since can change in Julian
2761
2761
# calculation and thus could have different value for the day of the wk
2762
2762
# calculation.
2763
- if julian == - 1 :
2764
- # Need to add 1 to result since first day of the year is 1, not 0.
2765
- julian = datetime_date(year, month, day).toordinal() - \
2766
- datetime_date(year, 1 , 1 ).toordinal() + 1
2767
- else : # Assume that if they bothered to include Julian day it will
2768
- # be accurate.
2769
- datetime_result = datetime_date.fromordinal(
2770
- (julian - 1 ) + datetime_date(year, 1 , 1 ).toordinal())
2771
- year = datetime_result.year
2772
- month = datetime_result.month
2773
- day = datetime_result.day
2763
+ try :
2764
+ if julian == - 1 :
2765
+ # Need to add 1 to result since first day of the year is 1, not 0.
2766
+ julian = datetime_date(year, month, day).toordinal() - \
2767
+ datetime_date(year, 1 , 1 ).toordinal() + 1
2768
+ else : # Assume that if they bothered to include Julian day it will
2769
+ # be accurate.
2770
+ datetime_result = datetime_date.fromordinal(
2771
+ (julian - 1 ) + datetime_date(year, 1 , 1 ).toordinal())
2772
+ year = datetime_result.year
2773
+ month = datetime_result.month
2774
+ day = datetime_result.day
2775
+ except ValueError :
2776
+ if coerce :
2777
+ iresult[i] = iNaT
2778
+ continue
2779
+ raise
2774
2780
if weekday == - 1 :
2775
2781
weekday = datetime_date(year, month, day).weekday()
2776
2782
0 commit comments