#NEWLINE# @ apply_wraps #NEWLINE# def apply( self , other ) : #NEWLINE# #INDENT# n = self . n #NEWLINE# ( wkday , days_in_month ) = tslib . monthrange ( other . year , self . month ) #NEWLINE# lastBDay = ( days_in_month - max ( ( ( ( ( wkday + days_in_month ) - 1 ) % 7 ) - 4 ) , 0 ) ) #NEWLINE# years = n #NEWLINE# if ( n > 0 ) : #NEWLINE# #INDENT# if ( ( other . month < self . month ) or ( ( other . month == self . month ) and ( other . day < lastBDay ) ) ) : #NEWLINE# #INDENT# years -= 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( n <= 0 ) : #NEWLINE# #INDENT# if ( ( other . month > self . month ) or ( ( other . month == self . month ) and ( other . day > lastBDay ) ) ) : #NEWLINE# #INDENT# years += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# other = ( other + relativedelta ( years = years ) ) #NEWLINE# ( _ , days_in_month ) = tslib . monthrange ( other . year , self . month ) #NEWLINE# result = datetime ( other . year , self . month , days_in_month , other . hour , other . minute , other . second , other . microsecond ) #NEWLINE# if ( result . weekday ( ) > 4 ) : #NEWLINE# #INDENT# result = ( result - BDay ( ) ) #NEWLINE# #UNINDENT# return result