def add_years(dt, years):
    """Add (or subtract) years, handling leap years.

    Args:
        dt (datetime): The datetime object.
        years (int): Positive or negative number of years to add.

    Returns:
        datetime: The same calendar date (month and day) in the
            destination year, if it exists, otherwise use the following day
            (thus changing February 29 to March 1).
    """
    try:
        dt = dt.replace(year=dt.year + years)
    except ValueError:
        dt = dt.replace(year=dt.year + years, day=dt.day + 1)
    return dt
