def inc(self, source, month=None, year=None):
yr = source.year<EOL>mth = source.month<EOL>dy = source.day<EOL>try:<EOL><INDENT>month = float(month)<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>month = <NUM_LIT:0><EOL><DEDENT>try:<EOL><INDENT>year = float(year)<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>year = <NUM_LIT:0><EOL><DEDENT>finally:<EOL><INDENT>month += year * <NUM_LIT:12><EOL>year = <NUM_LIT:0><EOL><DEDENT>subMi = <NUM_LIT:0.0><EOL>maxDay = <NUM_LIT:0><EOL>if month:<EOL><INDENT>mi = int(month)<EOL>subMi = month - mi<EOL>y = int(mi / <NUM_LIT>)<EOL>m = mi - y * <NUM_LIT:12><EOL>mth = mth + m<EOL>if mth < <NUM_LIT:1>:  <EOL><INDENT>y -= <NUM_LIT:1>  <EOL>mth += <NUM_LIT:12>  <EOL><DEDENT>elif mth > <NUM_LIT:12>:  <EOL><INDENT>y += <NUM_LIT:1>  <EOL>mth -= <NUM_LIT:12>  <EOL><DEDENT>yr += y<EOL>maxDay = self.ptc.daysInMonth(mth, yr)<EOL>if dy > maxDay:<EOL><INDENT>dy = maxDay<EOL><DEDENT><DEDENT>if yr > datetime.MAXYEAR or yr < datetime.MINYEAR:<EOL><INDENT>raise OverflowError('<STR_LIT>')<EOL><DEDENT>d = source.replace(year=yr, month=mth, day=dy)<EOL>if subMi:<EOL><INDENT>d += datetime.timedelta(days=subMi * maxDay)<EOL><DEDENT>return source + (d - source)<EOL>
Takes the given C{source} date, or current date if none is
passed, and increments it according to the values passed in
by month and/or year.

This routine is needed because Python's C{timedelta()} function
does not allow for month or year increments.

@type  source: struct_time
@param source: C{struct_time} value to increment
@type  month:  float or integer
@param month:  optional number of months to increment
@type  year:   float or integer
@param year:   optional number of years to increment

@rtype:  datetime
@return: C{source} incremented by the number of months and/or years