for example; I have a meeting at 2 o'clock on December 8th, I'm trying to make a python voice assistant that will add the appropriate date in the calendar as an event when I give the voice command, but it creates an event at the current time and date by adding the command I gave as an event to the calendar title, how can I fix this?
def parse_command(command):
date=datetime.now()
summary = ""
parts = command.split(" ")
for i in range(len(parts)):
if parts[i] == "saat" and i+1 < len(parts):
time = parts[i+1]
elif parts[i] == "tarihinde" and i+1 < len(parts):
try:
date = datetime.strptime(parts[i], "%d/%m/%Y")
except ValueError:
print("Geçersiz tarih formatı. Lütfen gün/ay/yıl formatında girin.")
pass
elif parts[i] != "toplantı":
summary += parts[i] + " "
if date is None or time is None:
return "Tarih veya saat belirtilmedi", None, None
# Zamanı oluştururken, başlangıç ve bitiş zamanları aynı formatta ve tipinde olmalı
start_time = date.strftime("%Y-%m-%dT%H:%M:%S") + "+00:00"
end_time = (date + timedelta(hours=1)).strftime("%Y-%m-%dT%H:%M:%S") + "+00:00"
return summary.strip(), start_time, end_time