Returns a term model created from the passed json data.
    param: term_data loaded json data

def _json_to_term_model(term_data):
    """
    Returns a term model created from the passed json data.
    param: term_data loaded json data
    """

    strptime = datetime.strptime
    day_format = "%Y-%m-%d"
    datetime_format = "%Y-%m-%dT%H:%M:%S"

    term = TermModel()
    term.year = term_data["Year"]
    term.quarter = term_data["Quarter"]

    term.last_day_add = parse_sws_date(term_data["LastAddDay"])

    term.first_day_quarter = parse_sws_date(term_data["FirstDay"])

    term.last_day_instruction = parse_sws_date(term_data["LastDayOfClasses"])

    term.last_day_drop = parse_sws_date(term_data["LastDropDay"])

    term.census_day = parse_sws_date(term_data["CensusDay"])

    if term_data["ATermLastDay"] is not None:
        term.aterm_last_date = parse_sws_date(term_data["ATermLastDay"])

    if term_data["BTermFirstDay"] is not None:
        term.bterm_first_date = parse_sws_date(term_data["BTermFirstDay"])

    if term_data["LastAddDayATerm"] is not None:
        term.aterm_last_day_add = parse_sws_date(term_data["LastAddDayATerm"])

    if term_data["LastAddDayBTerm"] is not None:
        term.bterm_last_day_add = parse_sws_date(term_data["LastAddDayBTerm"])

    term.last_final_exam_date = parse_sws_date(term_data["LastFinalExamDay"])

    try:
        term.grading_period_open = strptime(
            term_data["GradingPeriodOpen"], datetime_format)
    except (TypeError, ValueError):
        logger.warn('Malformed term_data["GradingPeriodOpen"]: {}'.format(
            term_data["GradingPeriodOpen"]))
        term.grading_period_open = strptime(
            '{}T08:00:00'.format(term_data['LastFinalExamDay']),
            datetime_format)

    if term_data["GradingPeriodOpenATerm"] is not None:
        term.aterm_grading_period_open = strptime(
            term_data["GradingPeriodOpenATerm"], datetime_format)

    try:
        term.grading_period_close = strptime(
            term_data["GradingPeriodClose"], datetime_format)
    except (TypeError, ValueError):
        logger.warn('Malformed term_data["GradingPeriodClose"]: {}'.format(
            term_data["GradingPeriodClose"]))
        term.grading_period_close = strptime(
            '{}T17:00:00'.format(term_data['LastFinalExamDay']),
            datetime_format)

    try:
        term.grade_submission_deadline = strptime(
            term_data["GradeSubmissionDeadline"], datetime_format)
    except (TypeError, ValueError):
        logger.warn(
            'Malformed term_data["GradeSubmissionDeadline"]: {}'.format(
                term_data["GradeSubmissionDeadline"]))
        term.grade_submission_deadline = strptime(
            '{}T17:00:00'.format(term_data['LastFinalExamDay']),
            datetime_format)

    if term_data["RegistrationServicesStart"] is not None:
        term.registration_services_start = parse_sws_date(
            term_data["RegistrationServicesStart"])

    if term_data["RegistrationPeriods"][0]["StartDate"] is not None:
        term.registration_period1_start = parse_sws_date(
            term_data["RegistrationPeriods"][0]["StartDate"])

    if term_data["RegistrationPeriods"][0]["EndDate"] is not None:
        term.registration_period1_end = parse_sws_date(
            term_data["RegistrationPeriods"][0]["EndDate"])

    if term_data["RegistrationPeriods"][1]["StartDate"] is not None:
        term.registration_period2_start = parse_sws_date(
            term_data["RegistrationPeriods"][1]["StartDate"])

    if term_data["RegistrationPeriods"][1]["EndDate"] is not None:
        term.registration_period2_end = parse_sws_date(
            term_data["RegistrationPeriods"][1]["EndDate"])

    if term_data["RegistrationPeriods"][2]["StartDate"] is not None:
        term.registration_period3_start = parse_sws_date(
            term_data["RegistrationPeriods"][2]["StartDate"])

    if term_data["RegistrationPeriods"][2]["EndDate"] is not None:
        term.registration_period3_end = parse_sws_date(
            term_data["RegistrationPeriods"][2]["EndDate"])

    term.time_schedule_construction = {}
    for campus in term_data["TimeScheduleConstruction"]:
        term.time_schedule_construction[campus.lower()] = True if (
            term_data["TimeScheduleConstruction"][campus]) else False

    term.time_schedule_published = {}
    for campus in term_data["TimeSchedulePublished"]:
        term.time_schedule_published[campus.lower()] = True if (
            term_data["TimeSchedulePublished"][campus]) else False

    term.clean_fields()
    return term