from datetime import datetime


def cycletime_to_datetime(
    cycletime: str, cycletime_format: str = "%Y%m%dT%H%MZ"
) -> datetime:
    """Convert a string representating the cycletime of the
    format YYYYMMDDTHHMMZ into a datetime object.

    Args:
        cycletime:
            A cycletime that can be converted into a datetime using the
            cycletime_format supplied.
        cycletime_format:
            String containing the desired format for the cycletime.

    Returns:
        A correctly formatted datetime object.
    """
    return datetime.strptime(cycletime, cycletime_format)