code: def date_totals(entries, by):
      
      date_dict = {}
      for date, date_entries in groupby(entries, lambda x: x['date']):
          if isinstance(date, datetime.datetime):
              date = date.date()
          d_entries = list(date_entries)
  
          if by == 'user':
              name = ' '.join((d_entries[0]['user__first_name'],
                               d_entries[0]['user__last_name']))
          elif by == 'project':
              name = d_entries[0]['project__name']
          else:
              name = d_entries[0][by]
  
          pk = d_entries[0][by]
          hours = get_hours_summary(d_entries)
          date_dict[date] = hours
      return name, pk, date_dict
docs: Yield a user's name and a dictionary of their hours