def METHOD_NAME(self, dt, day_end_hour, use_dst=True):
    """Return UTC time before dt whose local time is day_end_hour.
    If use_dst is False then DST is ignored, so a day ending at 9am
    (local time) in winter would end at 10am in summer."""
    # get UTC and local equivalent
    dt = dt.replace(tzinfo=self.utc)
    local = dt.astimezone(self.local)
    if not use_dst:
        local = local.replace(tzinfo=None) - local.dst()
    # truncate to the hour
    diff = local - local.replace(minute=0, second=0)
    dt -= diff
    local -= diff
    # decrement UTC until equivalent local time has correct hour
    for h in range(4):
        hours = local.hour - day_end_hour
        if hours == 0:
            break
        elif hours > 1:
            hours -= 1
        elif hours < 0:
            hours += 23
        dt -= HOUR * hours
        local = dt.astimezone(self.local)
        if not use_dst:
            local = local.replace(tzinfo=None) - local.dst()
    return dt.replace(tzinfo=None)