本文整理汇总了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)
示例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)