fix: properly parse time (HH:MM) after date
The parse_args function now: 1. Recognizes time format (HH:MM) after parsing a date 2. Combines date + time into a single timestamp 3. Only text comes before link or date flags Now /update 6 -date 2026-04-05 12:00 properly sets date+time
This commit is contained in:
@@ -75,6 +75,18 @@ def parse_args(
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_time(s: str) -> bool:
|
||||
if not s or ":" not in s:
|
||||
return False
|
||||
parts = s.split(":")
|
||||
if len(parts) != 2:
|
||||
return False
|
||||
try:
|
||||
h, m = int(parts[0]), int(parts[1])
|
||||
return 0 <= h <= 23 and 0 <= m <= 59
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
i = 0
|
||||
while i < len(args):
|
||||
arg = args[i]
|
||||
@@ -92,6 +104,12 @@ def parse_args(
|
||||
if parsed:
|
||||
due_date_ts = int(parsed.timestamp())
|
||||
i += 2
|
||||
if i < len(args) and is_time(args[i]):
|
||||
time_parts = args[i].split(":")
|
||||
due_date_ts += (
|
||||
int(time_parts[0]) * 3600 + int(time_parts[1]) * 60
|
||||
)
|
||||
i += 1
|
||||
else:
|
||||
clear_date = True
|
||||
i += 1
|
||||
@@ -106,6 +124,10 @@ def parse_args(
|
||||
if parsed:
|
||||
due_date_ts = int(parsed.timestamp())
|
||||
i += 1
|
||||
if i < len(args) and is_time(args[i]):
|
||||
time_parts = args[i].split(":")
|
||||
due_date_ts += int(time_parts[0]) * 3600 + int(time_parts[1]) * 60
|
||||
i += 1
|
||||
else:
|
||||
i += 1
|
||||
if text is None:
|
||||
|
||||
Reference in New Issue
Block a user