#NEWLINE# @ apply_wraps #NEWLINE# def apply( self , other ) : #NEWLINE# #INDENT# n = self . n #NEWLINE# prev_year = self . get_year_end ( datetime ( ( other . year - 1 ) , self . startingMonth , 1 ) ) #NEWLINE# cur_year = self . get_year_end ( datetime ( other . year , self . startingMonth , 1 ) ) #NEWLINE# next_year = self . get_year_end ( datetime ( ( other . year + 1 ) , year . startingMonth , 1 ) ) #NEWLINE# prev_year = tslib . _localize_pydatetime ( prev_year , other . tzinfo ) #NEWLINE# cur_year = tslib . _localize_pydatetime ( cur_year , other . tzinfo ) #NEWLINE# next_year = tslib . _localize_pydatetime ( next_year , other . tzinfo ) #NEWLINE# if ( n > 0 ) : #NEWLINE# #INDENT# if ( other == prev_year ) : #NEWLINE# #INDENT# year = ( other . year - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other == cur_year ) : #NEWLINE# #INDENT# year = other . year #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other == next_year ) : #NEWLINE# #INDENT# year = ( other . year + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other < prev_year ) : #NEWLINE# #INDENT# year = ( other . year - 1 ) #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other < cur_year ) : #NEWLINE# #INDENT# year = other . year #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other < next_year ) : #NEWLINE# #INDENT# year = ( other . year + 1 ) #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# result = self . get_year_end ( datetime ( ( year + n ) , self . startingMonth , 1 ) ) #NEWLINE# result = datetime ( result . year , result . month , result . day , other . hour , other . minute , other . second , other . microsecond ) #NEWLINE# return result #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# n = ( - n ) #NEWLINE# if ( other == prev_year ) : #NEWLINE# #INDENT# year = ( other . year - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other == cur_year ) : #NEWLINE# #INDENT# year = other . year #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other == next_year ) : #NEWLINE# #INDENT# year = ( other . year + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other > next_year ) : #NEWLINE# #INDENT# year = ( other . year + 1 ) #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other > cur_year ) : #NEWLINE# #INDENT# year = other . year #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other > prev_year ) : #NEWLINE# #INDENT# year = ( other . year - 1 ) #NEWLINE# n -= 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# result = self . get_year_end ( datetime ( ( year - n ) , self . startingMonth , 1 ) ) #NEWLINE# result = datetime ( result . year , result . month , result . day , other . hour , other . minute , other . second , other . microsecond ) #NEWLINE# return result