@@ -1343,7 +1343,7 @@ cdef class BusinessDay(BusinessMixin):
1343
1343
off_str += str (td.microseconds) + " us"
1344
1344
return off_str
1345
1345
1346
- if isinstance (self .offset, timedelta ):
1346
+ if PyDelta_Check (self .offset):
1347
1347
zero = timedelta(0 , 0 , 0 )
1348
1348
if self .offset >= zero:
1349
1349
off_str = " +" + get_str(self .offset)
@@ -1355,7 +1355,7 @@ cdef class BusinessDay(BusinessMixin):
1355
1355
1356
1356
@apply_wraps
1357
1357
def apply (self , other ):
1358
- if isinstance (other, datetime ):
1358
+ if PyDateTime_Check (other):
1359
1359
n = self .n
1360
1360
wday = other.weekday()
1361
1361
@@ -1386,7 +1386,7 @@ cdef class BusinessDay(BusinessMixin):
1386
1386
result = result + self .offset
1387
1387
return result
1388
1388
1389
- elif isinstance (other, (timedelta , Tick) ):
1389
+ elif PyDelta_Check (other) or isinstance (other , Tick):
1390
1390
return BusinessDay(
1391
1391
self .n, offset = self .offset + other, normalize = self .normalize
1392
1392
)
@@ -1667,7 +1667,7 @@ cdef class BusinessHour(BusinessMixin):
1667
1667
1668
1668
@apply_wraps
1669
1669
def apply (self , other ):
1670
- if isinstance (other, datetime ):
1670
+ if PyDateTime_Check (other):
1671
1671
# used for detecting edge condition
1672
1672
nanosecond = getattr (other, " nanosecond" , 0 )
1673
1673
# reset timezone and nanosecond
@@ -2510,7 +2510,7 @@ cdef class Week(SingleConstructorOffset):
2510
2510
if self .weekday is None :
2511
2511
return other + self .n * self ._inc
2512
2512
2513
- if not isinstance (other, datetime ):
2513
+ if not PyDateTime_Check (other):
2514
2514
raise TypeError (
2515
2515
f" Cannot add {type(other).__name__} to {type(self).__name__}"
2516
2516
)
@@ -3304,7 +3304,7 @@ cdef class CustomBusinessDay(BusinessDay):
3304
3304
else :
3305
3305
roll = " backward"
3306
3306
3307
- if isinstance (other, datetime ):
3307
+ if PyDateTime_Check (other):
3308
3308
date_in = other
3309
3309
np_dt = np.datetime64(date_in.date())
3310
3310
@@ -3319,7 +3319,7 @@ cdef class CustomBusinessDay(BusinessDay):
3319
3319
result = result + self .offset
3320
3320
return result
3321
3321
3322
- elif isinstance (other, (timedelta , Tick) ):
3322
+ elif PyDelta_Check (other) or isinstance (other , Tick):
3323
3323
return BDay(self .n, offset = self .offset + other, normalize = self .normalize)
3324
3324
else :
3325
3325
raise ApplyTypeError(
0 commit comments