def format_span(fmt, yearfrom, yearto, fromnchars, tonchars):
    """Return a span string representation.
    """
    args = str(yearfrom)[-fromnchars:]
    if tonchars:
        args = str(yearfrom)[-fromnchars:], str(yearto)[-tonchars:]
    return fmt % args
