XZise added a comment.
Hmm, https://docs.python.org/2/library/calendar.html#calendar.monthrange should do the trick then.
``` import datetime import calendar
def month_delta(date, month_delta=1): if int(month_delta) != month_delta: raise ValueError('Month delta must be an integer') while month_delta > 0: date += datetime.timedelta(days=calendar.monthrange( date.year, date.month)[1]) month_delta -= 1 return date ```
Though this //just// supports non-negative deltas but without any external library or pywikibot specific code.
TASK DETAIL https://phabricator.wikimedia.org/T73124
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: XZise Cc: pywikipedia-bugs, Legoktm, jayvdb, XZise, Multichill, Xqt