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


Python DateTime.earliestTime方法代码示例

本文整理汇总了Python中DateTime.DateTime.DateTime.earliestTime方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.earliestTime方法的具体用法?Python DateTime.earliestTime怎么用?Python DateTime.earliestTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTime.DateTime.DateTime的用法示例。


在下文中一共展示了DateTime.earliestTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getCriteriaItems

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import earliestTime [as 别名]
    def getCriteriaItems( self ):
        """
            Return a sequence of items to be used to build the catalog query.
        """
        if self.value is not None:
            field = self.Field()
            value = self.value
            operation = self.operation

            # Negate the value for 'old' days
            if self.daterange == 'old' and value != 0:
                value = -value

                # Also reverse the operator to match what a user would expect.
                # Queries such as "More than 2 days ago" should match dates
                # *earlier* than "today minus 2", and "Less than 2 days ago"
                # would be expected to return dates *later* then "today minus
                # two".
                if operation == 'max':
                    operation = 'min'
                elif operation == 'min':
                    operation = 'max'

            date = DateTime() + value

            if operation == 'within_day':
                # When items within a day are requested, the range is between
                # the earliest and latest time of that particular day
                range = ( date.earliestTime(), date.latestTime() )
                return ( ( field, {'query': range, 'range': 'min:max'} ), )

            elif operation == 'min':
                if value != 0:
                    if self.daterange == 'old':
                        date_range = (date, DateTime())
                        return ( ( field, { 'query': date_range
                                          , 'range': 'min:max'
                                          } ), )
                    else:
                        return ( ( field, { 'query': date.earliestTime()
                                          , 'range': operation 
                                          } ), )
                else:
                    # Value 0 means "Now", so get everything from now on
                    return ( ( field, {'query': date,'range': operation } ), )

            elif operation == 'max':
                if value != 0:
                    if self.daterange == 'old':
                        return ((field, {'query': date, 'range': operation}),)
                    else:
                        date_range = (DateTime(), date.latestTime())
                        return ( ( field, { 'query': date_range
                                          , 'range': 'min:max'
                                          } ), )
                else:
                    # Value is 0, meaning "Now", get everything before "Now"
                    return ( ( field, {'query': date, 'range': operation} ), )
        else:
            return ()
开发者ID:goschtl,项目名称:zope,代码行数:62,代码来源:DateCriteria.py

示例2: test_Today

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import earliestTime [as 别名]
    def test_Today(self):
        friendly = self._makeOne("foo", "foofield")

        friendly.apply(self.today)
        self.assertEqual(friendly.daterange, "ahead")

        now = DateTime()

        result = friendly.getCriteriaItems()
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0][0], "foofield")
        self.assertEqual(result[0][1]["query"], (now.earliestTime(), now.latestTime()))
        self.assertEqual(result[0][1]["range"], "min:max")
开发者ID:wpjunior,项目名称:proled,代码行数:15,代码来源:test_DateC.py

示例3: test_Today

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import earliestTime [as 别名]
    def test_Today( self ):
        friendly = self._makeOne('foo', 'foofield')

        friendly.apply( self.today )
        self.assertEqual( friendly.daterange, 'ahead' )

        now = DateTime()

        result = friendly.getCriteriaItems()
        self.assertEqual( len(result), 1 )
        self.assertEqual( result[0][0], 'foofield' )
        self.assertEqual( result[0][1]['query'],
                          ( now.earliestTime(), now.latestTime() ) )
        self.assertEqual( result[0][1]['range'], 'min:max' )
开发者ID:goschtl,项目名称:zope,代码行数:16,代码来源:test_DateC.py

示例4: test_Today

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import earliestTime [as 别名]
    def test_Today( self ):

        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
        friendly = FriendlyDateCriterion( 'foo', 'foofield' )

        friendly.apply( self.today )
        self.assertEqual( friendly.daterange, 'ahead' )

        now = DateTime()

        result = friendly.getCriteriaItems()
        self.assertEqual( len( result ), 2 )
        self.assertEqual( result[0][0], 'foofield' )
        self.assertEqual( result[0][1], ( now.earliestTime()
                                        , now.latestTime() ) )
        self.assertEqual( result[1][0], 'foofield_usage' )
        self.assertEqual( result[1][1], 'range:min:max' )
开发者ID:goschtl,项目名称:zope,代码行数:19,代码来源:test_DateC.py

示例5: getCriteriaItems

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import earliestTime [as 别名]
    def getCriteriaItems( self ):
        """
            Return a sequence of items to be used to build the catalog query.
        """
        if self.value is not None:
            field = self.Field()
            value = self.value

            # Negate the value for 'old' days
            if self.daterange == 'old':
                value = -value

            date = DateTime() + value

            operation = self.operation
            if operation == 'within_day':
                range = ( date.earliestTime(), date.latestTime() )
                return ( ( field, {'query': range, 'range': 'min:max'} ), )
            else:
                return ( ( field, {'query': date, 'range': operation} ), )
        else:
            return ()
开发者ID:goschtl,项目名称:zope,代码行数:24,代码来源:DateCriteria.py

示例6: getCriteriaItems

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import earliestTime [as 别名]
    def getCriteriaItems( self ):
        """
            Return a sequence of items to be used to build the catalog query.
        """
        result = []

        if self.value is not None:

            field = self.Field()
            value = self.value

            # Negate the value for 'old' days
            if self.daterange == 'old':
                value = -value

            date = DateTime() + value

            operation = self.operation
            if operation == 'within_day':

                range = ( date.earliestTime(), date.latestTime() )
                result.append( ( field, range ) )


                result.append( ( '%s_usage' % field
                               , 'range:min:max'
                               ) )
            else:
                result.append( ( field, date ) )


                result.append( ( '%s_usage' % field
                            , 'range:%s' % self.operation
                            ) )

        return result
开发者ID:goschtl,项目名称:zope,代码行数:38,代码来源:DateCriteria.py


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