def __renderTimeSpentOnDay(self, anEffort, dayOffset): ''' Return a rendered version of the duration of the effort on a specific day. ''' duration = anEffort.durationDay(dayOffset) \ if self.aggregation == 'week' else date.TimeDelta() return render.timeSpent(self.__round_duration(duration), showSeconds=self.__show_seconds())
def __renderTotalTimeSpent(self, anEffort): ''' Return a rendered version of the effort total duration (of composite efforts). ''' # No need to check for aggregation because this method is only used # in aggregated mode total_duration = anEffort.duration(recursive=True) return render.timeSpent(self.__round_duration(total_duration), showSeconds=self.__show_seconds())
def __renderTotalTimeSpent(self, anEffort): ''' Return a rendered version of the effort total duration (of composite efforts). ''' # No need to check for aggregation because this method is only used # in aggregated mode total_duration = anEffort.duration(recursive=True, rounding=self.__round_precision(), roundUp=self.__always_round_up()) return render.timeSpent(total_duration, showSeconds=self.__show_seconds())
def __renderTimeSpent(self, anEffort): ''' Return a rendered version of the effort duration. ''' duration = anEffort.duration() # Check for aggregation because we never round in details mode if self.isShowingAggregatedEffort(): duration = self.__round_duration(duration) showSeconds = self.__show_seconds() else: showSeconds = True return render.timeSpent(duration, showSeconds=showSeconds)
def __renderTimeSpentOnDay(self, anEffort, dayOffset): ''' Return a rendered version of the duration of the effort on a specific day. ''' kwargs = dict() if isinstance(anEffort, effort.BaseCompositeEffort): kwargs['rounding'] = self.__round_precision() kwargs['roundUp'] = self.__always_round_up() duration = anEffort.durationDay(dayOffset, **kwargs) \ if self.aggregation == 'week' else date.TimeDelta() return render.timeSpent(self.__round_duration(duration), showSeconds=self.__show_seconds())
def __sumTimeSpent(self, efforts): td = date.TimeDelta() for effort in efforts: td = td + effort.duration() sumTimeSpent = render.timeSpent(td, showSeconds=self.__show_seconds()) if sumTimeSpent == '': if self.__show_seconds(): sumTimeSpent = '0:00:00' else: sumTimeSpent = '0:00' return sumTimeSpent
def __renderTimeSpentOnDay(self, anEffort, dayOffset): """ Return a rendered version of the duration of the effort on a specific day. """ kwargs = dict() if isinstance(anEffort, effort.BaseCompositeEffort): kwargs["rounding"] = self.__round_precision() kwargs["roundUp"] = self.__always_round_up() duration = anEffort.durationDay(dayOffset, **kwargs) if self.aggregation == "week" else date.TimeDelta() return render.timeSpent( self.__round_duration(duration), showSeconds=self.__show_seconds(), decimal=self.settings.getboolean("feature", "decimaltime"), )
def __renderTotalTimeSpent(self, anEffort): """ Return a rendered version of the effort total duration (of composite efforts). """ # No need to check for aggregation because this method is only used # in aggregated mode total_duration = anEffort.duration( recursive=True, rounding=self.__round_precision(), roundUp=self.__always_round_up() ) return render.timeSpent( total_duration, showSeconds=self.__show_seconds(), decimal=self.settings.getboolean("feature", "decimaltime"), )
def __renderTimeSpent(self, anEffort): ''' Return a rendered version of the effort duration. ''' kwargs = dict() if isinstance(anEffort, effort.BaseCompositeEffort): kwargs['rounding'] = self.__round_precision() kwargs['roundUp'] = self.__always_round_up() duration = anEffort.duration(**kwargs) # Check for aggregation because we never round in details mode if self.isShowingAggregatedEffort(): duration = self.__round_duration(duration) showSeconds = self.__show_seconds() else: showSeconds = True return render.timeSpent(duration, showSeconds=showSeconds)
def __renderTimeSpent(self, anEffort): """ Return a rendered version of the effort duration. """ kwargs = dict() if isinstance(anEffort, effort.BaseCompositeEffort): kwargs["rounding"] = self.__round_precision() kwargs["roundUp"] = self.__always_round_up() duration = anEffort.duration(**kwargs) # Check for aggregation because we never round in details mode if self.isShowingAggregatedEffort(): duration = self.__round_duration(duration) showSeconds = self.__show_seconds() else: showSeconds = True return render.timeSpent( duration, showSeconds=showSeconds, decimal=self.settings.getboolean("feature", "decimaltime") )
def __sumTimeSpent(self, efforts): td = date.TimeDelta() for effort in efforts: td = td + effort.duration() sumTimeSpent = render.timeSpent( td, showSeconds=self.__show_seconds(), decimal=self.settings.getboolean("feature", "decimaltime") ) if sumTimeSpent == "": if self.settings.getboolean("feature", "decimaltime"): sumTimeSpent = "0.0" elif self.__show_seconds(): sumTimeSpent = "0:00:00" else: sumTimeSpent = "0:00" return sumTimeSpent
def __sumTimeSpent(self, efforts): td = date.TimeDelta() for effort in efforts: td = td + effort.duration() sumTimeSpent = render.timeSpent(td, showSeconds=self.__show_seconds(), decimal=self.settings.getboolean( 'feature', 'decimaltime')) if sumTimeSpent == '': if self.settings.getboolean('feature', 'decimaltime'): sumTimeSpent = '0.0' elif self.__show_seconds(): sumTimeSpent = '0:00:00' else: sumTimeSpent = '0:00' return sumTimeSpent
def testOneSecond(self): self.assertEqual('0:00:01', render.timeSpent(date.ONE_SECOND))
def testZeroTime(self): self.assertEqual('', render.timeSpent(date.TimeDelta()))
def testDecimal(self): self.assertEqual('0.50', render.timeSpent(date.TimeDelta(minutes=30), decimal=True))
def testDecimalNul(self): self.assertEqual('', render.timeSpent(date.TimeDelta(hours=0), decimal=True))
def testDecimalNegative(self): self.assertEqual('-1.25', render.timeSpent(date.TimeDelta(hours=-1, minutes=-15), decimal=True))
def testNegativeSeconds(self): self.assertEqual('-0:00:01', render.timeSpent(date.TimeDelta(seconds=-1)))
def testNegativeHours(self): self.assertEqual('-1:00:00', render.timeSpent(date.TimeDelta(hours=-1)))
def testTenHours(self): self.assertEqual('10:00:00', render.timeSpent(date.TimeDelta(hours=10)))
def testDecimalNul(self): self.assertEqual( '', render.timeSpent(date.TimeDelta(hours=0), decimal=True))
def testDecimalNegative(self): self.assertEqual( '-1.25', render.timeSpent(date.TimeDelta(hours=-1, minutes=-15), decimal=True))
def testDecimal(self): self.assertEqual( '0.50', render.timeSpent(date.TimeDelta(minutes=30), decimal=True))