本文整理汇总了Python中DateTime.DateTime.isPast方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.isPast方法的具体用法?Python DateTime.isPast怎么用?Python DateTime.isPast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime.DateTime
的用法示例。
在下文中一共展示了DateTime.isPast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isExpired
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import isPast [as 别名]
def isExpired(content):
""" Find out if the object is expired (copied from skin script) """
expiry = None
# NOTE: We also accept catalog brains as 'content' so that the
# catalog-based folder_contents will work. It's a little magic, but
# it works.
# ExpirationDate should have an ISO date string, which we need to
# convert to a DateTime
# Try DC accessor first
if base_hasattr(content, 'ExpirationDate'):
expiry = content.ExpirationDate
# Try the direct way
if not expiry and base_hasattr(content, 'expires'):
expiry = content.expires
# See if we have a callable
if safe_callable(expiry):
expiry = expiry()
# Convert to DateTime if necessary, ExpirationDate may return 'None'
if expiry and expiry != 'None' and isinstance(expiry, basestring):
expiry = DateTime(expiry)
if isinstance(expiry, DateTime) and expiry.isPast():
return 1
return 0
示例2: base_hasattr
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import isPast [as 别名]
if not content:
content = context
expiry = None
# NOTE: We also accept catalog brains as 'content' so that the catalog-based
# folder_contents will work. It's a little magic, but it works.
# ExpirationDate should have an ISO date string, which we need to
# convert to a DateTime
# Try DC accessor first
if base_hasattr(content, "ExpirationDate"):
expiry = content.ExpirationDate
# Try the direct way
if not expiry and base_hasattr(content, "expires"):
expiry = content.expires
# See if we have a callable
if safe_callable(expiry):
expiry = expiry()
# Convert to DateTime if necessary, ExpirationDate may return 'None'
if expiry and expiry != "None" and same_type(expiry, ""):
expiry = DateTime(expiry)
if same_type(expiry, DateTime()) and expiry.isPast():
return 1
return 0