'Render all events for a certain date and hour'

def render_for_datehour(self, date, hour):

    output = ''
    renderable_events = self.renderable_events(date, hour)
    css_class = 'calendar-event-hour'
    if renderable_events:
        width = (90.0 / len(renderable_events))
        current_margin = 0
        for event in renderable_events:
            if ((str(date) in event.margin_step) and (event.margin_step[str(date)] > current_margin)):
                current_margin = event.margin_step[str(date)]
        for event in renderable_events:
            if event.is_renderable(date, hour):
                margin = (width * current_margin)
                event.margin_step[str(date)] = current_margin = (current_margin + 1)
                if event.is_full_day(date):
                    height = ((((self.end_hour - self.start_hour) + 1) * 40) - 5)
                else:
                    duration = event.get_duration(date, self.start_hour, self.end_hour)
                    if ((hour + duration) > (self.end_hour + 1)):
                        if (event.start.date() == date):
                            duration = ((self.end_hour - hour) + 1)
                        else:
                            duration = (duration - hour)
                    height = ((duration * float(40)) - 5)
                style = ('width:    %.2f%%;    height:    %dpx;    margin-left:    %.2f%%' % (width, height, margin))
                output += event.render_for_datehour(date, hour, css_class, style)
    return output
