#NEWLINE# @ apply_wraps #NEWLINE# def apply( self , other ) : #NEWLINE# #INDENT# daytime = self . _get_daytime_flag ( ) #NEWLINE# businesshours = self . _get_business_hours_by_sec ( ) #NEWLINE# bhdelta = timedelta ( seconds = businesshours ) #NEWLINE# if isinstance ( other , datetime ) : #NEWLINE# #INDENT# nanosecond = getattr ( other , 'nanosecond' , 0 ) #NEWLINE# other = datetime ( other . year , other . month , other . day , other . hour , other . minute , other . second , other . microsecond ) #NEWLINE# n = self . n #NEWLINE# if ( n >= 0 ) : #NEWLINE# #INDENT# if ( ( other . time ( ) == self . end ) or ( not self . _onOffset ( other , businesshours ) ) ) : #NEWLINE# #INDENT# other = self . _next_opening_time ( other ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( other . time ( ) == self . start ) : #NEWLINE# #INDENT# other = ( other - timedelta ( seconds = 1 ) ) #NEWLINE# #UNINDENT# if ( not self . _onOffset ( other , businesshours ) ) : #NEWLINE# #INDENT# other = self . _next_opening_time ( other ) #NEWLINE# other = ( other + bhdelta ) #NEWLINE# #UNINDENT# #UNINDENT# ( bd , r ) = divmod ( abs ( ( n * 60 ) ) , ( businesshours // 60 ) ) #NEWLINE# if ( n < 0 ) : #NEWLINE# #INDENT# ( bd , r ) = ( ( - bd ) , ( - r ) ) #NEWLINE# #UNINDENT# if ( bd != 0 ) : #NEWLINE# #INDENT# skip_bd = BusinessDay ( n = bd ) #NEWLINE# if ( not self . next_bday . onOffset ( other ) ) : #NEWLINE# #INDENT# remain = ( other - self . _prev_opening_time ( other ) ) #NEWLINE# other = ( self . _next_opening_time ( ( other + skip_bd ) ) + remain ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# other = ( other + skip_bd ) #NEWLINE# #UNINDENT# #UNINDENT# ( hours , minutes ) = divmod ( r , 60 ) #NEWLINE# result = ( other + timedelta ( hours = hours , minutes = minutes ) ) #NEWLINE# if ( ( daytime and ( ( result . time ( ) < self . start ) or ( self . end < result . time ( ) ) ) ) or ( ( not daytime ) and ( self . end < result . time ( ) < self . start ) ) ) : #NEWLINE# #INDENT# if ( n >= 0 ) : #NEWLINE# #INDENT# bday_edge = self . _prev_opening_time ( other ) #NEWLINE# bday_edge = ( bday_edge + bhdelta ) #NEWLINE# bday_remain = ( result - bday_edge ) #NEWLINE# result = self . _next_opening_time ( other ) #NEWLINE# result += bday_remain #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# bday_edge = self . _next_opening_time ( other ) #NEWLINE# bday_remain = ( result - bday_edge ) #NEWLINE# result = ( self . _next_opening_time ( result ) + bhdelta ) #NEWLINE# result += bday_remain #NEWLINE# #UNINDENT# #UNINDENT# if ( n >= 0 ) : #NEWLINE# #INDENT# if ( result . time ( ) == self . end ) : #NEWLINE# #INDENT# result = self . _next_opening_time ( result ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( result . time ( ) == self . start ) and ( nanosecond == 0 ) ) : #NEWLINE# #INDENT# result = ( self . _next_opening_time ( ( result - timedelta ( seconds = 1 ) ) ) + bhdelta ) #NEWLINE# #UNINDENT# #UNINDENT# return result #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ApplyTypeError ( 'Only know how to combine business hour with ' )