本文整理汇总了Python中epsilon.extime.Time.fromStructTime方法的典型用法代码示例。如果您正苦于以下问题:Python Time.fromStructTime方法的具体用法?Python Time.fromStructTime怎么用?Python Time.fromStructTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类epsilon.extime.Time
的用法示例。
在下文中一共展示了Time.fromStructTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: guessSentTime
# 需要导入模块: from epsilon.extime import Time [as 别名]
# 或者: from epsilon.extime.Time import fromStructTime [as 别名]
def guessSentTime(self, default=None):
"""
Try to determine the time this message claims to have been sent by
analyzing various headers.
@return: a L{Time} instance, or C{None}, if we don't have a guess.
"""
try:
sentHeader = self.getHeader(u'date')
except equotient.NoSuchHeader:
sentHeader = None
else:
try:
return Time.fromRFC2822(sentHeader)
except ValueError:
pass
for received in list(self.getHeaders(u'received'))[::-1]:
lines = received.value.splitlines()
if lines:
lastLine = lines[-1]
parts = lastLine.split('; ')
if parts:
date = parts[-1]
try:
when = rfc822.parsedate(date)
if when is None:
continue
except ValueError:
pass
else:
return Time.fromStructTime(when)
return default