def parse_date_time(dt_str, dt_format, dt_type, allows_microseconds):
    micros = None
    if(allows_microseconds):
        dt_parts = dt_str.rsplit(".", 1)
        dt_str = dt_parts.pop(0)
        if(len(dt_parts) > 0):
            micros = int(dt_parts[0].ljust(6, "0")[:6])
    dtime = datetime.strptime(dt_str, dt_format)
    if(micros):
        dtime = dtime.replace(microsecond=micros)
    if(dt_type is datetime.date):
        dtime = dtime.date()
    elif(dt_type is datetime.time):
        dtime = dtime.time()
    return dtime
Returns a datetime/date/time instance parsed from the given string
dataset/ETHPy150Open jahlborn/appengine-rest-server/src/main/python/rest/__init__.py/parse_date_time