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


Python TimeAgent.dtDiffMins方法代码示例

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


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

示例1: test_getSchedulingRange

# 需要导入模块: from nell.utilities import TimeAgent [as 别名]
# 或者: from nell.utilities.TimeAgent import dtDiffMins [as 别名]
    def test_getSchedulingRange(self):

        # scheduling range is 0:00 of timezone of first day
        # to the last day at 8:00 EST

        # test it in winter time
        dt = datetime(2010, 1, 1)
        days = 2
        expStart = datetime(2010, 1, 1, 0)
        expEnd   = datetime(2010, 1, 3, 13)
        expDur = TimeAgent.dtDiffMins(expStart, expEnd)

        start, dur = ScheduleTools().getSchedulingRange(dt, 'UTC', days)
        self.assertEquals(expStart, start)
        self.assertEquals(expDur, dur)

        # make sure it works in ET too
        expStart = datetime(2010, 1, 1, 5)
        expEnd   = datetime(2010, 1, 3, 13)
        expDur = TimeAgent.dtDiffMins(expStart, expEnd)

        start, dur = ScheduleTools().getSchedulingRange(dt, 'ET', days)
        self.assertEquals(expStart, start)

        # test it in summer time
        dt = datetime(2010, 6, 10)
        days = 3
        expStart = datetime(2010, 6, 10, 0)
        expEnd   = datetime(2010, 6, 13, 12)
        expDur = TimeAgent.dtDiffMins(expStart, expEnd)

        start, dur = ScheduleTools().getSchedulingRange(dt, 'UTC', days)
        self.assertEquals(expStart, start)
        self.assertEquals(expDur, dur)

        # make sure it works in ET too
        expStart = datetime(2010, 6, 10, 4)
        expEnd   = datetime(2010, 6, 13, 12)
        expDur = TimeAgent.dtDiffMins(expStart, expEnd)

        start, dur = ScheduleTools().getSchedulingRange(dt, 'ET', days)
        self.assertEquals(expStart, start)
        self.assertEquals(expDur, dur)
开发者ID:mmccarty,项目名称:nell,代码行数:45,代码来源:TestScheduleTools.py

示例2: getSchedulingRange

# 需要导入模块: from nell.utilities import TimeAgent [as 别名]
# 或者: from nell.utilities.TimeAgent import dtDiffMins [as 别名]
    def getSchedulingRange(self, firstDay, timezone, days):
        """
        Converts given time range (start dt, days) to 'scheduling range' 
        (start dt, minutes)
        """

        startHour = 0 if timezone == 'UTC' else self.getUTCHour(firstDay, 0)
        start = datetime(firstDay.year
                       , firstDay.month
                       , firstDay.day
                       , startHour
                        )

        lastDay = firstDay + timedelta(days = days)

        end   = datetime(lastDay.year
                       , lastDay.month
                       , lastDay.day
                       , self.getUTCHour(lastDay, self.schedulingEnd)
                        )

        duration = TimeAgent.dtDiffMins(end, start)

        return (start, duration)
开发者ID:mmccarty,项目名称:nell,代码行数:26,代码来源:ScheduleTools.py


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