def _subdivide_interval_by_hour(start, end):
    start_hour = start.replace(minute=0, second=0, microsecond=0)
    end_hour = end.replace(minute=0, second=0, microsecond=0)

    if start_hour == end_hour:
        hour_to_secs = {start_hour: _to_secs(end - start)}
    else:
        hour_to_secs = {}

        hour_to_secs[start_hour] = _to_secs(
            start_hour + timedelta(hours=1) - start)

        hour_to_secs[end_hour] = _to_secs(end - end_hour)

        # fill in dates in the middle
        cur_hour = start_hour + timedelta(hours=1)
        while cur_hour < end_hour:
            hour_to_secs[cur_hour] = _to_secs(timedelta(hours=1))
            cur_hour += timedelta(hours=1)

    # remove zeros
    hour_to_secs = dict(
        (h, secs) for h, secs in hour_to_secs.items() if secs)

    return hour_to_secs
Convert a time interval to a map from hours (represented as
dataset/ETHPy150Open Yelp/mrjob/mrjob/tools/emr/audit_usage.py/_subdivide_interval_by_hour