#NEWLINE# @ apply_wraps #NEWLINE# def apply( self , other ) : #NEWLINE# #INDENT# def _increment( date ) : #NEWLINE# #INDENT# if ( date . month == self . month ) : #NEWLINE# #INDENT# ( _ , days_in_month ) = tslib . monthrange ( date . year , self . month ) #NEWLINE# if ( date . day != days_in_month ) : #NEWLINE# #INDENT# year = date . year #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# year = ( date . year + 1 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( date . month < self . month ) : #NEWLINE# #INDENT# year = date . year #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# year = ( date . year + 1 ) #NEWLINE# #UNINDENT# #UNINDENT# ( _ , days_in_month ) = tslib . monthrange ( year , self . month ) #NEWLINE# return datetime ( year , self . month , days_in_month , date . hour , date . minute , date . second , date . microsecond ) #NEWLINE# #UNINDENT# def _decrement( date ) : #NEWLINE# #INDENT# year = ( date . year if ( date . month > self . month ) else ( date . year - 1 ) ) #NEWLINE# ( _ , days_in_month ) = tslib . monthrange ( year , self . month ) #NEWLINE# return datetime ( year , self . month , days_in_month , date . hour , date . minute , date . second , date . microsecond ) #NEWLINE# #UNINDENT# def _rollf( date ) : #NEWLINE# #INDENT# if ( ( date . month != self . month ) or ( date . day < tslib . monthrange ( date . year , date . month ) [ 1 ] ) ) : #NEWLINE# #INDENT# date = _increment ( date ) #NEWLINE# #UNINDENT# return date #NEWLINE# #UNINDENT# n = self . n #NEWLINE# result = other #NEWLINE# if ( n > 0 ) : #NEWLINE# #INDENT# while ( n > 0 ) : #NEWLINE# #INDENT# result = _increment ( result ) #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( n < 0 ) : #NEWLINE# #INDENT# while ( n < 0 ) : #NEWLINE# #INDENT# result = _decrement ( result ) #NEWLINE# n += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# result = _rollf ( result ) #NEWLINE# #UNINDENT# #UNINDENT# return result