def get_genTime_as_datetime(self):
"""
parses the genTime string and returns a datetime object;
it also adjusts the time according to local timezone, so that it is
compatible with other parts of the library
"""
year = int(self.genTime[:4])
month = int(self.genTime[4:6])
day = int(self.genTime[6:8])
hour = int(self.genTime[8:10])
minute = int(self.genTime[10:12])
second = int(self.genTime[12:14])
rest = self.genTime[14:].strip("Z")
if rest:
micro = int(float(rest)*1e6)
else:
micro = 0
tz_delta = datetime.timedelta(seconds=time.daylight and time.altzone
or time.timezone)
return datetime.datetime(year, month, day, hour, minute, second, micro) - tz_delta
评论列表
文章目录