Python lib of CIv4, strptime() exists, but doesn't work.

zx1111

Warlord
Joined
Oct 31, 2005
Messages
235
I tried to folowing Python code in Civ4 screen code, but it generates error.
Code:
import time
def parseTime(szTime):
	""" parse time string of form HH:MM ( like "1:23" ) 
		Returns (iHour, iMin) tuple and (0, 0) on error input. """ 
	szTime = szTime.strip()
	try:
		timeVal = time.strptime( szTime, " %H : % M ")
	except :
		try:
			timeVal = time.strptime( szTime, " %M ")
		except :
			return (0, 0 )

	return ( timeVal[3], timeVal[4] )

It complains that something like
"Error in strptime: __calc_weekday(): line 9X....
calandar has no attribute : calendar.day_abbr..."

Seems to be version mismatch with strptime.pyc and calendar.pyc...

And overrall feeling is that Python version of Civ4 is some what old, but some module is not so old. It causes some versio mis-match among modules.

This is related Python library sorce code. ( in "Python24/Lib/strptime.py" )
Code:
def __calc_weekday(self):
092         # Set self.a_weekday and self.f_weekday using the calendar
093         # module.
094         a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
095         f_weekday = [calendar.day_name[i].lower() for i in range(7)]
096         self.a_weekday = a_weekday
097         self.f_weekday = f_weekday
...
 
Back
Top Bottom