本文整理汇总了Python中DateTime.DateTime.DateTime.latestTime方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.latestTime方法的具体用法?Python DateTime.latestTime怎么用?Python DateTime.latestTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime.DateTime.DateTime
的用法示例。
在下文中一共展示了DateTime.latestTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCriteriaItems
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import latestTime [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 ()
示例2: test_Today
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import latestTime [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")
示例3: test_Today
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import latestTime [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' )
示例4: test_Today
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import latestTime [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' )
示例5: getCriteriaItems
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import latestTime [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 ()
示例6: getCriteriaItems
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import latestTime [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