Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -352,6 +352,8 @@ def time_parse(inp, debug=False):
|
|
| 352 |
if len(abs_times) == 0 and len(rel_time_deltas) == 0:
|
| 353 |
raise Exception("Could not identify a time. Be sure to use 'AM/PM' if you specify an absolute time")
|
| 354 |
|
|
|
|
|
|
|
| 355 |
# Relative Time Deltas Resolved Everythign Else
|
| 356 |
if len(rel_time_deltas) == 1 and abs_date is None and len(rel_date_deltas) == 0 and len(abs_times) == 0: # Straight up "in X hours"
|
| 357 |
datetime_request = d + rel_time_deltas[0]
|
|
@@ -372,6 +374,10 @@ def time_parse(inp, debug=False):
|
|
| 372 |
if len(rel_date_deltas) == 3 or (len(rel_date_deltas) == 2 and abs_date is not None):
|
| 373 |
raise Exception("Have not yet implemented Resolver for 3 rel-rel dates or 2 rel-rel dates + 1 abs date")
|
| 374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
if len(abs_times) == 1 and len(rel_time_deltas) == 0:
|
| 376 |
datetime_request = datetime_request.replace(hour=abs_times[0].hour, minute=abs_times[0].minute)
|
| 377 |
|
|
@@ -379,6 +385,8 @@ def time_parse(inp, debug=False):
|
|
| 379 |
return datetime_request
|
| 380 |
|
| 381 |
|
|
|
|
|
|
|
| 382 |
x = st.text_input("Request", value="")
|
| 383 |
st.write(x)
|
| 384 |
d = time_parse(x, debug=True)
|
|
|
|
| 352 |
if len(abs_times) == 0 and len(rel_time_deltas) == 0:
|
| 353 |
raise Exception("Could not identify a time. Be sure to use 'AM/PM' if you specify an absolute time")
|
| 354 |
|
| 355 |
+
datetime_request = None
|
| 356 |
+
|
| 357 |
# Relative Time Deltas Resolved Everythign Else
|
| 358 |
if len(rel_time_deltas) == 1 and abs_date is None and len(rel_date_deltas) == 0 and len(abs_times) == 0: # Straight up "in X hours"
|
| 359 |
datetime_request = d + rel_time_deltas[0]
|
|
|
|
| 374 |
if len(rel_date_deltas) == 3 or (len(rel_date_deltas) == 2 and abs_date is not None):
|
| 375 |
raise Exception("Have not yet implemented Resolver for 3 rel-rel dates or 2 rel-rel dates + 1 abs date")
|
| 376 |
|
| 377 |
+
# If no date, then assume today
|
| 378 |
+
if datetime_request is None:
|
| 379 |
+
datetime_request = datetime.datetime.now()
|
| 380 |
+
|
| 381 |
if len(abs_times) == 1 and len(rel_time_deltas) == 0:
|
| 382 |
datetime_request = datetime_request.replace(hour=abs_times[0].hour, minute=abs_times[0].minute)
|
| 383 |
|
|
|
|
| 385 |
return datetime_request
|
| 386 |
|
| 387 |
|
| 388 |
+
|
| 389 |
+
|
| 390 |
x = st.text_input("Request", value="")
|
| 391 |
st.write(x)
|
| 392 |
d = time_parse(x, debug=True)
|