cools commited on
Commit
36b4b49
1 Parent(s): 878e08b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -40,11 +40,11 @@ def abs_date_parse(snip):
40
  if w in month_dict:
41
  month = month_dict[w]
42
  continue
43
- w = w.replace('st', '').replace('nd', '').replace('rd', '').replace('th', '')
44
- if w.isdigit() and int(w) > 31:
45
- year = int(w)
46
- if w.isdigit() and int(w) <= 31:
47
- date = int(w)
48
  if month is None:
49
  raise Exception("There should have been a month, but could not identify")
50
  if date is None:
@@ -113,6 +113,8 @@ def rel_date_parse(snip):
113
  return datetime.timedelta(days=dow-current_dow)
114
  if "tomorrow" in snip:
115
  return datetime.timedelta(days=1)
 
 
116
  if "now" in snip or "today" in snip or "tonight" in snip:
117
  return datetime.timedelta(days=0)
118
  if "day" in snip.split(' ') or "days" in snip.split(' '):
@@ -241,7 +243,6 @@ def abs_rel_date_resolver(inp, term_abs, term_rel, abs_dt, rel_td, adverbs, adv_
241
  return datetime.timedelta(days=0, hours=0, minutes=0)
242
  else:
243
  raise Exception("There is a conflict with the datetimes provided. '" + str(abs_dt).upper() + "' != '" + term_rel.upper() + "'")
244
-
245
 
246
  def time_parse(inp, debug=False):
247
  match_mdy_abs_1 = re.search(mdy_abs_1, inp)
 
40
  if w in month_dict:
41
  month = month_dict[w]
42
  continue
43
+ w = int("".join([c for c in w if c.isdigit()]))
44
+ if w > 31:
45
+ year = w
46
+ if w <= 31:
47
+ date = w
48
  if month is None:
49
  raise Exception("There should have been a month, but could not identify")
50
  if date is None:
 
113
  return datetime.timedelta(days=dow-current_dow)
114
  if "tomorrow" in snip:
115
  return datetime.timedelta(days=1)
116
+ if "week" in snip:
117
+ return datetime.timedelta(days=7)
118
  if "now" in snip or "today" in snip or "tonight" in snip:
119
  return datetime.timedelta(days=0)
120
  if "day" in snip.split(' ') or "days" in snip.split(' '):
 
243
  return datetime.timedelta(days=0, hours=0, minutes=0)
244
  else:
245
  raise Exception("There is a conflict with the datetimes provided. '" + str(abs_dt).upper() + "' != '" + term_rel.upper() + "'")
 
246
 
247
  def time_parse(inp, debug=False):
248
  match_mdy_abs_1 = re.search(mdy_abs_1, inp)