from datetime import datetime


def string_to_datetime(date_str, time_format):
    """Convert pre-checked string into datetime object."""

    datet_obj = datetime.strptime(date_str, time_format)

    return datet_obj