def hour2Date(self, hour, alternate = False):
numOfDays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]
numOfHours = [24 * numOfDay for numOfDay in numOfDays]
#print hour/24
if hour%8760==0 and not alternate: return `31`+ ' ' + 'DEC' + ' 24:00'
elif hour%8760==0: return 31, 11, 24
for h in range(len(numOfHours)-1):
if hour <= numOfHours[h+1]: month = self.monthList[h]; break
try: month
except: month = self.monthList[h] # for the last hour of the year
if (hour)%24 == 0:
day = int((hour - numOfHours[h]) / 24)
time = `24` + ':00'
hour = 24
else:
day = int((hour - numOfHours[h]) / 24) + 1
minutes = `int(round((hour - math.floor(hour)) * 60))`
if len(minutes) == 1: minutes = '0' + minutes
time = `int(hour%24)` + ':' + minutes
if alternate:
time = hour%24
if time == 0: time = 24
month = self.monthList.index(month)
return day, month, time
return (`day` + ' ' + month + ' ' + time)
评论列表
文章目录