#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# first = _get_firstbday ( wkday ) #NEWLINE# years = n #NEWLINE# if ( n > 0 ) : #NEWLINE# #INDENT# if ( ( other . month < self . month ) or ( ( other . month == self . month ) and ( other . day < first ) ) ) : #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 > first ) ) ) : #NEWLINE# #INDENT# years += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# other = ( other + relativedelta ( years = years ) ) #NEWLINE# ( wkday , days_in_month ) = tslib . monthrange ( other . year , self . month ) #NEWLINE# first = _get_firstbday ( first ) #NEWLINE# return datetime ( other . year , self . month , first , other . hour , other . minute , other . second , other . microsecond )