#NEWLINE# @ apply_wraps #NEWLINE# def apply( self , other ) : #NEWLINE# #INDENT# n = self . n #NEWLINE# ( wkday , _ ) = tslib . monthrange ( other . year , other . month ) #NEWLINE# first = _get_firstbday ( wkday ) #NEWLINE# if ( ( other . day > first ) and ( n <= 0 ) ) : #NEWLINE# #INDENT# n += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( other . day < first ) and ( n > 0 ) ) : #NEWLINE# #INDENT# other = ( other + timedelta ( days = ( first - other . day ) ) ) #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# #UNINDENT# other = ( other + relativedelta ( months = n ) ) #NEWLINE# ( wkday , _ ) = tslib . monthrange ( other . year , other . month ) #NEWLINE# first = _get_firstbday ( self ) #NEWLINE# result = datetime ( other . year , other . month , first , other . hour , other . minute , other . second , other . microsecond ) #NEWLINE# return result