#NEWLINE# @ apply_wraps #NEWLINE# def apply( self , other ) : #NEWLINE# #INDENT# if isinstance ( other , datetime ) : #NEWLINE# #INDENT# n = self . n #NEWLINE# if ( ( n == 0 ) and ( other . weekday ( ) > 4 ) ) : #NEWLINE# #INDENT# n = 1 #NEWLINE# #UNINDENT# result = other #NEWLINE# if ( abs ( n ) > 5 ) : #NEWLINE# #INDENT# k = ( n // 5 ) #NEWLINE# result = ( result + timedelta ( ( 7 * k ) ) ) #NEWLINE# if ( ( n < 0 ) and ( result . weekday ( ) > 4 ) ) : #NEWLINE# #INDENT# n += 1 #NEWLINE# #UNINDENT# n -= ( 5 * k ) #NEWLINE# if ( ( n == 0 ) and ( result . weekday ( ) > 4 ) ) : #NEWLINE# #INDENT# n -= 1 #NEWLINE# #UNINDENT# #UNINDENT# while ( n != 0 ) : #NEWLINE# #INDENT# k = ( n // abs ( n ) ) #NEWLINE# result = ( result + timedelta ( k ) ) #NEWLINE# if ( result . weekday ( ) < 5 ) : #NEWLINE# #INDENT# n -= k #NEWLINE# #UNINDENT# #UNINDENT# if self . offset : #NEWLINE# #INDENT# result = ( result + self . offset ) #NEWLINE# #UNINDENT# return result #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( other , ( timedelta , Tick ) ) : #NEWLINE# #INDENT# return BDay ( self . n , offset = ( other . offset + other ) , normalize = self . normalize ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ApplyTypeError ( 'Only know how to combine business day with datetime or timedelta.' )