import time
from datetime import datetime

def convert_from_seconds(seconds):
    return time.strftime("%H:%M:%S", time.gmtime(seconds))

def set_generic_date_time(datestamp='1900:01:01',
                          timestamp='00:00:00',
                          f='%Y:%m:%d %H:%M:%S'):
    t = datetime.strptime(str(f'{datestamp} {timestamp}'), f)
    return t

def process_img_date_tag(tag, image_tags, date_time_format):
    try:
        t = datetime.strptime(str(image_tags[tag]), date_time_format)
    except:
        t = None
    return t

def get_img_date(image_tags):
    t = None

    for tag in image_tags:
        if 'DateTime' in tag:
            t = tag
            break

    for f in ['%Y:%m:%d %H:%M:%S',
              '%Y/%m/%d %H:%M:%S',
              '%Y-%m-%d-%H-%M-%S']:
        dt_tag = process_img_date_tag(t,image_tags,f)

        if dt_tag is not None:
            break

    if dt_tag is None:
        dt_tag = set_generic_date_time()

    return dt_tag