from datetime import datetime


def _get_date(fname):
    """Get date from a filename.
    Wrote and modified with Boka Luo

    Args:
        fname (str): the name of file.

    Returns:
        datetime.date: the date.
    """
    date = fname.split("_")[4]
    date = datetime.strptime("-".join([date[0:4], date[4:6], date[6:8]]), '%Y-%m-%d')
    return date