I wonder if you could make use of or extend the existing template tag, `get_max_hours`.