如何读取MM-DD-YY
格式的日期并验证为真实日期?你知道吗
I know it would be easier and more robust to handle it with the
datetime
module - but that's not what I want, so any solutions around using the the following code is appreciated:
dataType
=年月日actualResult
=12-31-13rIndex
:^{cd3>}的计数器变量rLen
:actualResult
的长度def compareDate (dataType, actualResult, rIndex, rLen):
dateString = ""
bhCount , result , count = 0 , 0 , 0
while (rIndex < rLen):
ch = actualResult[rIndex]
print ("Char %c" % ch)
dateString += str(ch)
if(ch >='0' and ch <= '9'):
count += 1
if(count == 2):
count = 0
bHyphen = False
elif(count > 2):
result = -1
break
elif(ch == "-"):
bhCount += 1
if((count == 0) and (bHyphen == False)):
bHyphen = True
else:
break
else:
break
rIndex += 1
#print dateString
return (result, rIndex)
我做错了什么?任何帮助都将不胜感激。你知道吗
相关问题 更多 >
编程相关推荐