def METHOD_NAME(self, filename, stamp_format):
    year = ""
    month = ""
    day = ""
    hour = ""
    minute = ""
    second = ""
    msecond = ""
    usecond = ""
    index = ""
    epoch = ""
    for n, f in zip(filename, stamp_format):
        if f == "Y":
            year += n
        if f == "M":
            month += n
        if f == "D":
            day += n
        if f == "h":
            hour += n
        if f == "m":
            minute += n
        if f == "s":
            second += n
        if f == "f":
            msecond += n
        if f == "u":
            usecond += n
        if f == "i":
            index += n
        if f == "e":
            epoch += n
    if not index and epoch == "":
        assert len(year) == 4, "Year in filename should have a length of 4"
        assert (
            len(month) == 2
        ), "Month in filename should have a length of \
            2"
        assert len(day) == 2, "Day in filename should have a length of 2"
        assert len(hour) == 2, "Hour in filename should have a length of 2"
        assert (
            len(minute) <= 2
        ), "Minute in filename should have a length \
            of 2"
        assert (
            len(second) <= 2
        ), "Second in filename should have a length \
            of 2"
        if msecond:
            assert (
                len(msecond) <= 3
            ), "Milliseconds in filename should \
                have a maximum length of 3"
        else:
            msecond = "0"
        if usecond:
            assert (
                len(usecond) <= 3
            ), "Microseconds in filename should \
                have a length of 3"
        else:
            usecond = "0"
        microsecond = int(msecond) * 1000 + int(usecond)
        date = datetime(
            int(year),
            int(month),
            int(day),
            int(hour),
            int(minute),
            int(second),
            microsecond,
        )
        stamp = float(calendar.timegm(date.timetuple()))
        return stamp + microsecond * 1e-6
    elif epoch != "":
        stamp = float(epoch)
        return stamp
    else:
        if self.df is None:
            Console.error(
                "FilenameToDate specified using indexing, but no \
                timestamp file has been provided or read."
            )
            Console.quit("Invalid timestamp format")
        stamp = self.df["epoch_timestamp"][int(index)]
        return stamp