import re


def get_sale_head(line):
    """Return the date of the livestock sale."""

    head_pattern = re.compile(r'receipts.*?\b(?P<date>[0-9]+)\s*hd', re.IGNORECASE)
    match = False
    while not match:
        this_line = line.pop(0)
        match = head_pattern.search(this_line)
    sale_head = match.group('date')

    return sale_head