本文整理汇总了Python中mx.DateTime.cmp方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.cmp方法的具体用法?Python DateTime.cmp怎么用?Python DateTime.cmp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mx.DateTime
的用法示例。
在下文中一共展示了DateTime.cmp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: equal
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import cmp [as 别名]
def equal(self, a, b):
# mx.DateTime has a precision of 10ms, so we need to account for
# rounding errors.
datetime_types = DateTime.DateTimeType, DateTime.DateTimeDeltaType
if isinstance(a, datetime_types) and isinstance(b, datetime_types):
return DateTime.cmp(a, b, 0.01) == 0
return a == b
示例2: _compute_tasks
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import cmp [as 别名]
def _compute_tasks(cr, uid, task_list, date_begin):
sequences = []
users = {}
tasks = {}
last_date = date_begin
for task in task_list:
# TODO: reorder ! with dependencies
if not task.planned_hours:
continue
if task.state in ('draft','open','progress') and task.user_id:
# Find the starting date of the task
if task.user_id.id in users:
date_start = users[task.user_id.id]
else:
date_start = date_begin
sequences.sort()
for (seq,dt) in sequences:
if seq<task.sequence:
date_start = max(dt,date_start)
else:
break
if task.date_start:
task_date_start = DateTime.strptime(task.date_start, '%Y-%m-%d %H:%M:%S')
if DateTime.cmp(date_start, task_date_start) < 0:
date_start = task_date_start
# Compute the closing date of the task
tasks[task.id] = []
res = pooler.get_pool(cr.dbname).get('hr.timesheet.group').interval_get(cr, uid, task.project_id.timesheet_id.id, date_start, task.remaining_hours)
for (d1,d2) in res:
tasks[task.id].append((d1, d2, task.name, task.user_id.login))
date_close = tasks[task.id] and tasks[task.id][-1][1] or False
# Store result
if date_close:
users[task.user_id.id] = date_close
sequences.append((task.sequence, date_close))
if date_close>last_date:
last_date=date_close
return tasks, last_date