У меня есть следующий в функции:Как рассчитать комбинированный опыт
edu = sorted(context.education, key=lambda studied: studied["studied_to"], reverse=True)
#print edu[0].studied_to
job_history = []
for job in context.job_history:
if edu[0].fields_of_study in job.industries:
from_ = job.from_
to_ = job.to_
industries = job.industries
rd = rdelta.relativedelta(to_, from_) # get date difference
# I suspect that combined exp calculation would be done here.
experience = "{0.years} Years {0.months} Months".format(rd) #get Year - Month format
#print experience
job_history.append({"job_title": job_title,
"company_name": company_name,
"from_": from_,
"to_": to_,
"industries": industries,
"experience": experience})
j = sorted(job_history, key=lambda s: s["to_"])
#print j[0]["job_title"]
return {"relocate_list": provinces,
"disabilities_dict": disabilities,
"industries_list": industry_dict,
"job_history_sorted": j,
"education_sorted": edu}
я могу получить опыт от каждой работы с вышеприведенным кодом. Есть ли способ рассчитать общий опыт.
В настоящее время, говорят, что у пользователя было несколько рабочих мест в ИТ-индустрии для аргументов, приведенный выше код даст мне, например. 1 Years 0 Months
и 1 Years 4 Months
.
Как рассчитать комбинированный опыт, поэтому приведенный выше пример будет 2 Years 4 Months
?
Я попытался:
rd += rd
Но это добавляет ту же дату, т.е.
1 Years 4 Months + 1 Years 4 Months
бы выход:
2 Years 8 Months
Я хочу взять два значения «год-месяц» и добавить их вместе. т. е. как в моем вопросе выше: у пользователя есть 2 права: «1 год 4 месяца» и «1 год 0 месяцев». Это вычисляется с помощью: 'rd = rdelta.relativedelta (to_, from_) experience =" {0.years} Years {0.months} Months ".format (rd)' – Renier