def created(self):
"""
Attempt to parse the human readable torrent creation datetime.
"""
timestamp, current = self._created
if timestamp.endswith('ago'):
quantity, kind, ago = timestamp.split()
quantity = int(quantity)
if 'sec' in kind:
current -= quantity
elif 'min' in kind:
current -= quantity * 60
elif 'hour' in kind:
current -= quantity * 60 * 60
return datetime.datetime.fromtimestamp(current)
current = datetime.datetime.fromtimestamp(current)
timestamp = timestamp.replace('Y-day', str(current.date() - datetime.timedelta(days=1)))
timestamp = timestamp.replace('Today', current.date().isoformat())
try:
return dateutil.parser.parse(timestamp)
except:
return current
评论列表
文章目录