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


Python TimeAgent.timedelta2minutes方法代码示例

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


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

示例1: getBlackedOutSchedulableTime

# 需要导入模块: from nell.utilities import TimeAgent [as 别名]
# 或者: from nell.utilities.TimeAgent import timedelta2minutes [as 别名]
    def getBlackedOutSchedulableTime(self, start, end):
        """
        Of the hours in the given range that are schedulable,
        how many have been blacked out?
        Returns tuple of hours (scheduble but ignoring blackouts
                              , scheduable but blacked out)
        Returns tuple of (scheduable but ignoring blackouts total
                        , scheduable but blacked out total
                        , [2-tuple of scheduable-but-ignoring-blackouts range)]
                        , [[2-tuple of scheduable-but-blacked-out-range]])
        """
        nss1 = self.get_time_not_schedulable(start, end, blackouts=False)

        nss = self.trim_events(nss1, start, end)

        # now convert the non-schedulable time ranges to the
        # time that IS schedulable:
        schedulable = self.compliment_events(nss, start, end)

        # how much time is that?
        hrsSchedulable = sum([TimeAgent.timedelta2minutes(s[1] - s[0]) / 60.0 for s in schedulable])

        # now, for each chunk of schedulable time, how much is
        # blacked out?
        hrsBlackedOut = 0.0
        bss = []
        # print "schedulable loop:"
        for s in schedulable:
            bs = self.project.get_blackout_times(s[0], s[1])
            # but these blackout times might not match to the schedulable
            # end points, so we may need to truncate them
            bs = self.trim_events(bs, s[0], s[1])
            if len(bs) != 0:
                bss.append(bs)
            bsTime = sum([TimeAgent.timedelta2minutes(b[1] - b[0]) / 60.0 for b in bs])
            hrsBlackedOut += bsTime

        # return a summary of what we've found
        return (hrsSchedulable, hrsBlackedOut, schedulable, bss)
开发者ID:,项目名称:,代码行数:41,代码来源:


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