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


Python DateTime.cmp方法代码示例

本文整理汇总了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
开发者ID:Abhayakara,项目名称:ocpgdb,代码行数:9,代码来源:tests.py

示例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
开发者ID:MarkNorgate,项目名称:addons-EAD,代码行数:45,代码来源:_date_compute.py


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