예제 #1
0
    def get_satisfied_seconds(self, call: Call) -> int:
        second = (call.get_end() - call.get_start()).second

        if second <= self.start:
            return self.start
        elif second <= self.end:
            return second - self.start
        else:
            return second - self.end
예제 #2
0
    def get_satisfied_seconds(self, call: Call) -> int:
        second = 0

        call_start = call.get_start()
        call_end = call.get_end()

        call_start_date = call_start.date()
        call_end_date = call_end.date()

        while call_start_date < call_end_date:
            second += (
                min(datetime.combine(call_start_date, self.end), call_end) -
                max(datetime.combine(call_start_date, self.start),
                    call_start)).second
            call_start_date += timedelta(days=1)

        return second
예제 #3
0
    def get_satisfied_seconds(self, call: Call) -> int:
        second = 0

        call_start = call.get_start()
        call_end = call.get_end()

        call_start_date = call_start.date()
        call_end_date = call_end.date()

        while call_start_date < call_end_date:
            if call_start_date.weekday() in self.dayofweek:
                second += (min(
                    datetime.combine(call_start_date,
                                     time(hour=0, minute=0, second=0)),
                    call_end) - max(
                        datetime.combine(call_start_date,
                                         time(hour=23, minute=59, second=59)),
                        call_start)).second
            call_start_date += timedelta(days=1)

        return second
예제 #4
0
 def get_satisfied_seconds(self, call: Call) -> int:
     return (call.get_end() - call.get_start()).second