+
+ def handle_shorthands(input):
+ """recognize string like +5d or +3w or +2m as
+ 2 days, 3 weeks or 2 months from now"""
+ if input.startswith('+'):
+ match = re.match(r"([0-9]+)([dwm])", input[1:])
+ if match:
+ how_many = int(match.group(1))
+ what = match.group(2)
+ if what == 'd':
+ d = datetime.timedelta(days=how_many)
+ elif what == 'w':
+ d = datetime.timedelta(weeks=how_many)
+ elif what == 'm':
+ d = datetime.timedelta(weeks=4 * how_many)
+ return datetime.datetime.utcnow() + d
+