def fn2date(sitename, filename, irFlag=False):
    """
    Function to extract the date from a "standard" filename based on a
    sitename.  Here we assume the filename format is the standard:

          sitename_YYYY_MM_DD_HHNNSS.jpg

    So we just grab components from fixed positions.  If irFlag is
    True then the "standard" format is:

          sitename_IR_YYYY_MM_DD_HHNNSS.jpg

    """

    if irFlag:
        prefix = sitename + "_IR"
    else:
        prefix = sitename

    # set start of datetime part of name
    nstart = len(prefix) + 1

    # assume 3-letter extension e.g. ".jpg"
    dtstring = filename[nstart:-4]

    # extract date-time pieces
    year = int(dtstring[0:4])
    mon = int(dtstring[5:7])
    day = int(dtstring[8:10])
    hour = int(dtstring[11:13])
    mins = int(dtstring[13:15])
    sec = int(dtstring[15:17])

    # return list
    return [year, mon, day, hour, mins, sec]