code: def generate_daily(day_end_hour, use_dst,
                     calib_data, hourly_data, daily_data, process_from):
      
      start = daily_data.before(datetime.max)
      if start is None:
          start = datetime.min
      start = calib_data.after(start + SECOND)
      if process_from:
          if start:
              start = min(start, process_from)
          else:
              start = process_from
      if start is None:
          return start
      # round to start of this day, in local time
      start = timezone.local_replace(
          start, use_dst=use_dst, hour=day_end_hour, minute=0, second=0)
      del daily_data[start:]
      stop = calib_data.before(datetime.max)
      acc = DayAcc()
      def dailygen(inputdata):
          """Internal generator function"""
          day_start = start
          count = 0
          while day_start <= stop:
              count += 1
              if count % 30 == 0:
                  logger.info("daily: %s", day_start.isoformat(' '))
              else:
                  logger.debug("daily: %s", day_start.isoformat(' '))
              day_end = day_start + DAY
              if use_dst:
                  # day might be 23 or 25 hours long
                  day_end = timezone.local_replace(
                      day_end + HOURx3, use_dst=use_dst, hour=day_end_hour)
              acc.reset()
              for data in inputdata[day_start:day_end]:
                  acc.add_raw(data)
              for data in hourly_data[day_start:day_end]:
                  acc.add_hourly(data)
              new_data = acc.result()
              if new_data:
                  new_data['start'] = day_start
                  yield new_data
              day_start = day_end
      daily_data.update(dailygen(calib_data))
      return start
docs: Generate daily summaries from calibrated and hourly data.