def total_time_for_period(period, user=None):
    """
    Determines how much time has been logged for the current period.
    """

    # find all entries in the period
    entries = Entry.objects.in_period(period, user)

    seconds = seconds_for_entries(entries)
    return utils.get_total_time(seconds)
    def render(self, context):
        # pull the object back from the context
        obj = self.obj.resolve(context)

        # determine the period specified
        period = self.period.resolve(context)

        # find all entries in that period
        entries = obj.entries.in_period(period, context['user'])

        if self.time:
            seconds = seconds_for_entries(entries)
            return utils.get_total_time(seconds)
        else:
            hours = [e.total_hours for e in entries]
            return float(sum(hours))
    def render(self, context):
        date_obj = self.date_obj.resolve(context)
        entries = Entry.objects.filter(start_time__year=date_obj.year,
                                       start_time__month=date_obj.month,
                                       start_time__day=date_obj.day,
                                       user=context['user'])

        # If there is only one (or 0) entry for a particular day, there's no
        # need to go any further
        if len(entries) <= 1: return ''

        hours = [e.total_hours for e in entries]
        total = sum(hours)

        context['day_total'] = total
        context['day_time'] = utils.get_total_time(seconds_for_entries(entries))
        context['day'] = date_obj

        t = template.loader.get_template('pendulum/_day_totals.html')
        return t.render(context)
    def render(self, context):
        date_obj = self.date_obj.resolve(context)

        date_range = week_bounds(date_obj.year, int(date_obj.strftime('%U')))
        entries = Entry.objects.filter(start_time__range=date_range,
                                       user=context['user'])

        # If there is only one (or 0) entry for a particular week, there's no
        # need to go any further
        if len(entries) <= 1: return ''

        hours = [e.total_hours for e in entries]
        total = sum(hours)

        context['week_total'] = total
        context['week_time'] = utils.get_total_time(seconds_for_entries(entries))
        context['week_range'] = {'start': date_range[0],
                                 'end': date_range[1]}

        t = template.loader.get_template('pendulum/_week_totals.html')
        return t.render(context)
Example #5
0
 def __paused_time(self):
     """
     Returns the total time paused for this entry in HH:MM:SS format
     """
     return utils.get_total_time(self.seconds_paused)
Example #6
0
 def __total_time(self):
     """
     Determines the amount of time spent and return it as a string formatted
     as HH:MM:SS
     """
     return utils.get_total_time(self.get_seconds())