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


Python DateTime.localtime方法代码示例

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


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

示例1: create

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import localtime [as 别名]
    def create(self, cr, uid, ids, datas, context={}):
        io = StringIO.StringIO()

        if 'date_start' not in datas:
            cr.execute('select min(date_start) from project_task where id in %s', (tuple(ids),))
            dt = cr.fetchone()[0]
            if dt:
                datas['date_start'] = dt[:10]
            else:
                datas['date_start'] = time.strftime('%Y-%m-%d')
        if 'date_stop' not in datas:
            cr.execute('select max(date_start),max(date_close) from project_task where id in %s', (tuple(ids),))
            res = cr.fetchone()
            datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d')
            if res[1] and datas['date_stop']<res[1]:
                datas['date_stop'] = res[1][:10]

        date_to_int = lambda x: int(x.ticks())
        int_to_date = lambda x: '/a60{}'+DateTime.localtime(x).strftime('%d/%m/%Y')

        datas = _burndown.compute_burndown(cr, uid, ids, datas['date_start'], datas['date_stop'])

        canv = canvas.init(fname=io, format='pdf')
        canv.set_author("Open ERP")

        max_hour = reduce(lambda x,y: max(y[1],x), datas, 0)

        date_to_int = lambda x: int(x.ticks())
        int_to_date = lambda x: '/a60{}'+DateTime.localtime(x).strftime('%d %m %Y')

        def _interval_get(*args):
            result = set()
            for i in range(20):
                d = DateTime.localtime(datas[0][0] + (((datas[-1][0]-datas[0][0])/20)*(i+1)))
                res = DateTime.DateTime(d.year, d.month, d.day).ticks()
                result.add(res)

            return list(result)

        if datas[-1][0] == datas[0][0]:
            x_range = (datas[0][0],datas[-1][0]+1)
        else:
            x_range = (datas[0][0],datas[-1][0])

        ar = area.T(x_grid_style=line_style.gray50_dash1,
            x_axis=axis.X(label="Date", format=int_to_date),
            y_axis=axis.Y(label="Burndown Chart - Planned Hours"),
            x_grid_interval=_interval_get,
            x_range = x_range,
            y_range = (0,max_hour),
            legend = None,
            size = (680,450))
        ar.add_plot(line_plot.T(data=datas))
        ar.draw(canv)
        canv.close()

        self.obj = external_pdf(io.getvalue())
        self.obj.render()
        return (self.obj.pdf,'pdf')
开发者ID:MarkNorgate,项目名称:addons-EAD,代码行数:61,代码来源:task_burndown.py

示例2: _interval_get

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import localtime [as 别名]
 def _interval_get(*args):
     result = []
     for i in range(20):
         d = DateTime.localtime(datas[0][0] + (((datas[-1][0]-datas[0][0])/20)*(i+1)))
         res = DateTime.DateTime(d.year, d.month, d.day).ticks()
         if (not result) or result[-1]<>res:
             result.append(res)
     return result
开发者ID:MarkNorgate,项目名称:addons-EAD,代码行数:10,代码来源:sprint_burndown.py

示例3: _interval_get

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import localtime [as 别名]
        def _interval_get(*args):
            result = set()
            for i in range(20):
                d = DateTime.localtime(datas[0][0] + (((datas[-1][0]-datas[0][0])/20)*(i+1)))
                res = DateTime.DateTime(d.year, d.month, d.day).ticks()
                result.add(res)

            return list(result)
开发者ID:MarkNorgate,项目名称:addons-EAD,代码行数:10,代码来源:task_burndown.py

示例4: create

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import localtime [as 别名]
    def create(self, cr, uid, ids, datas, context={}):
        io = StringIO.StringIO()

        canv = canvas.init(fname=io, format='pdf')
        canv.set_author("Open ERP")

        cr.execute('select id,date_start,date_stop from scrum_sprint where id=%s', (datas['id'],))
        for (id,date_start,date_stop) in cr.fetchall():
            date_to_int = lambda x: int(x.ticks())
            int_to_date = lambda x: '/a60{}'+DateTime.localtime(x).strftime('%d/%m/%Y')

            cr.execute('select id from project_task where product_backlog_id in(select id from scrum_product_backlog where sprint_id=%s)', (id,))

            ids = map(lambda x: x[0], cr.fetchall())
            datas = _burndown.compute_burndown(cr, uid, ids, date_start, date_stop)

            max_hour = reduce(lambda x,y: max(y[1],x), datas, 0)

            date_to_int = lambda x: int(x.ticks())
            int_to_date = lambda x: '/a60{}'+DateTime.localtime(x).strftime('%d %m %Y')

            def _interval_get(*args):
                result = []
                for i in range(20):
                    d = DateTime.localtime(datas[0][0] + (((datas[-1][0]-datas[0][0])/20)*(i+1)))
                    res = DateTime.DateTime(d.year, d.month, d.day).ticks()
                    if (not result) or result[-1]<>res:
                        result.append(res)
                return result

            ar = area.T(x_grid_style=line_style.gray50_dash1,
                x_axis=axis.X(label="Date", format=int_to_date),
                y_axis=axis.Y(label="Burndown Chart - Planned Hours"),
                x_grid_interval=_interval_get,
                x_range = (datas[0][0],datas[-1][0]),
                y_range = (0,max_hour),
                legend = None,
                size = (680,450))
            ar.add_plot(line_plot.T(data=datas))
            ar.draw(canv)
        canv.close()

        self.obj = external_pdf(io.getvalue())
        self.obj.render()
        return (self.obj.pdf, 'pdf')
开发者ID:MarkNorgate,项目名称:addons-EAD,代码行数:47,代码来源:sprint_burndown.py

示例5: filedate

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import localtime [as 别名]
def filedate(path, stat=os.stat):

    """ Return the modification date/time as DateTime instance.

        Needs mxDateTime to be installed.

    """
    from mx import DateTime

    return DateTime.localtime(stat(path)[8])
开发者ID:cumtjie,项目名称:commcarehq-venv,代码行数:12,代码来源:Tools.py

示例6: now

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import localtime [as 别名]
def now():
    return DateTime.localtime()
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:4,代码来源:datetime.py


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