from datetime import datetime
from datetime import timedelta
n, s, t = list( map(int, input().split()) )
#print(s,t)
commandList = []
for _ in range(n):
commandList.append(input().split())
def month2Dig(month):
myList = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
if month.isdigit():
return int(month)
else:
for i in range(len(myList)):
if month.upper() == myList[i].upper():
return i+1
def monthList2Dig(monthList):
for i in range(len(monthList)):
monthList[i] = month2Dig(monthList[i])
return monthList
def week2Dig(week):
weekList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
if week.isdigit():
return int(week)
else:
for i in range(len(weekList)):
if week.upper() == weekList[i].upper():
return i
def weekList2Dig(weekList):
for i in range(len(weekList)):
weekList[i] = week2Dig(weekList[i])
return weekList
def unify(attr, j):
if attr == '*':
return [attr]
else:
tmpList = attr.split(',')
tmp = []
for i in range(len(tmpList)):
tmpList[i] = tmpList[i].split('-')
if j == 3:
tmpList[i] = monthList2Dig(tmpList[i])
elif j == 4:
tmpList[i] = weekList2Dig(tmpList[i])
if len(tmpList[i]) == 1:
tmp += [int(tmpList[i][0])]
else:
tmp += [_ for _ in range( int(tmpList[i][0]), int(tmpList[i][1])+1 ) ]
tmp.sort()
return tmp
for i in range(len(commandList)):
for j in range(5):
tmp = commandList[i][j]
commandList[i][j] = unify(commandList[i][j], j)
#print(commandList)
def check(_dateTime):
re = []
flag = False
minute = _dateTime.minute
hour = _dateTime.hour
dayOfMonth = _dateTime.day
month = _dateTime.month
dayOfWeek = _dateTime.isoweekday()
if dayOfWeek==7:
dayOfWeek = 0
for command in commandList:
flag = (minute in command[0] or command[0][0]=='*') and (hour in command[1] or command[1][0]=='*') and (dayOfMonth in command[2] or command[2][0]=='*') and (month in command[3] or command[3][0]=='*') and (dayOfWeek in command[4] or command[4][0]=='*')
if flag:
break
if flag:
re = [flag, command[5]]
#print(re, dayOfWeek)
else:
re = [flag]
return re
def generateTime(s, t):
dt1 = datetime.strptime(str(s), '%Y%m%d%H%M')
dt2 = datetime.strptime(str(t), '%Y%m%d%H%M')
d = timedelta(seconds=60)
while True:
if dt1 < dt2:
reList = check(dt1)
#print(reList)
if reList[0]:
print(dt1.strftime('%Y%m%d%H%M')+' '+reList[1])
dt1 += d
else:
break
generateTime(s, t)
网友评论