Skip to content
Permalink
a5256e7a02
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
77 lines (64 sloc) 2.13 KB
from datetime import datetime
listTime = ["?", "time", "day", "month", "year", "minute", "hour"]
day = ["day"]
time = ["time"]
both = ["both"]
neither = ["neither"]
def timeFunction(text):
now = datetime.now()
currentYear = now.year
currentMonth = now.month
currentDay = now.day
currentHour = now.hour
currentMin = now.minute
if currentMonth == 1:
currentMonth = "January"
elif currentMonth == 2:
currentMonth = "February"
elif currentMonth == 3:
currentMonth = "March"
elif currentMonth == 4:
currentMonth = "April"
elif currentMonth == 5:
currentMonth = "May"
elif currentMonth == 6:
currentMonth = "June"
elif currentMonth == 7:
currentMonth = "July"
elif currentMonth == 8:
currentMonth = "August"
elif currentMonth == 9:
currentMonth = "September"
elif currentMonth == 10:
currentMonth = "October"
elif currentMonth == 11:
currentMonth = "November"
elif currentMonth == 12:
currentMonth = "December"
if currentHour <= 12:
hour = " pm "
else:
currentHour = currentHour - 12
hour = " am "
if currentMin == 1:
min = " minute "
else:
min = " minutes "
try:
if gV.flagTimeQ == 1 and day[0] in text:
gV.flagTimeQ = 0
return "Today is " + currentMonth + " " + str(currentDay) + ", " + str(currentYear) + "."
elif gV.flagTimeQ == 1 and time[0] in text:
gV.flagTimeQ = 0
return "It's " + str(currentHour) + hour + "and " + str(currentMin) + min + "."
elif gV.flagTimeQ == 1 and both[0] in text:
gV.flagTimeQ = 0
return "Today is " + currentMonth + " " + str(currentDay) + ", " + str(currentYear) + " and it's " + \
str(currentHour) + hour + "and " + str(currentMin) + min + "."
elif gV.flagTimeQ == 1 and neither[0] in text:
gV.flagTimeQ = 0
return "What do you want to talk about then?"
else:
return "I can't understand you."
except:
return "Something went wrong."