当前位置: 首页>>代码示例>>Python>>正文


Python DateTime.isPast方法代码示例

本文整理汇总了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
开发者ID:ferewuz,项目名称:Products.CMFPlone,代码行数:33,代码来源:utils.py

示例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
开发者ID:dtgit,项目名称:dtedu,代码行数:31,代码来源:isExpired.py


注:本文中的DateTime.DateTime.isPast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。