本文整理汇总了Python中DateTime.DateTime.isCurrentDay方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.isCurrentDay方法的具体用法?Python DateTime.isCurrentDay怎么用?Python DateTime.isCurrentDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime.DateTime
的用法示例。
在下文中一共展示了DateTime.isCurrentDay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDownTime
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import isCurrentDay [as 别名]
def getDownTime(self, start, end=None):
"""calculate the down time in seconds using start and end DateTime
if no end is passed the current time is assumed"""
if not end: end = DateTime()
syear = start.year()
eyear = end.year()
dt = -1
if syear == eyear:
dt = self._getDownTime(syear, start, end)
else:
dt = self._getDownTime(syear, start=start)
for y in range(syear+1, eyear):
dt += self._getDownTime(y)
dt += self._getDownTime(eyear, end=end)
if end.isCurrentDay(): dt += self.todaydown
return dt
示例2: __call__
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import isCurrentDay [as 别名]
def __call__(self, formquery, criterion, registry): # noqa
if criterion.value is None:
logger.warn('Ignoring empty criterion %s.', criterion)
return
field = criterion.Field()
value = criterion.Value()
# Check if the index is known and enabled as criterion index.
if not self.is_index_known(registry, field):
return
self.is_index_enabled(registry, field)
# Negate the value for 'old' days
if criterion.getDateRange() == '-':
value = -value
date = DateTime() + value
# Get the possible operation methods.
key = '{0}.field.{1}.operations'.format(prefix, field)
operations = registry.get(key)
def add_row(operation, value=None):
if operation not in operations:
# TODO just ignore it?
raise ValueError(INVALID_OPERATION % (operation, criterion))
if not self.is_operation_valid(registry, operation):
# TODO just ignore it?
raise ValueError(INVALID_OPERATION % (operation, criterion))
# Add a row to the form query.
row = {'i': field,
'o': operation}
if value is not None:
row['v'] = value
formquery.append(row)
operation = criterion.getOperation()
if operation == 'within_day':
if date.isCurrentDay():
new_operation = '{0}.operation.date.today'.format(prefix)
add_row(new_operation)
return
date_range = (date.earliestTime(), date.latestTime())
new_operation = '{0}.operation.date.between'.format(prefix)
add_row(new_operation, date_range)
return
if operation == 'more':
if value != 0:
new_operation = ('{0}.operation.date.'
'largerThanRelativeDate'.format(prefix))
add_row(new_operation, value)
return
else:
new_operation = '{0}.operation.date.afterToday'.format(prefix)
add_row(new_operation)
return
if operation == 'less':
if value != 0:
new_operation = ('{0}.operation.date.'
'lessThanRelativeDate'.format(prefix))
add_row(new_operation, value)
return
else:
new_operation = '{0}.operation.date.beforeToday'.format(prefix)
add_row(new_operation)
return