diff --git a/_includes/pro/resume/work.html b/_includes/pro/resume/work.html index ffdbf68..36a55e3 100644 --- a/_includes/pro/resume/work.html +++ b/_includes/pro/resume/work.html @@ -15,51 +15,54 @@
- {% assign todayYear = 'now' | date: "%Y" %} - {% assign todayMonth = 'now' | date: "%m" %} {% assign startYear = work.startDate | date: "%Y" %} {% assign startMonth = work.startDate | date: "%m" %} + {% assign startDay = work.startDate | date: "%d" %} + {% assign todayYear = 'now' | date: "%Y" %} + {% assign todayMonth = 'now' | date: "%m" %} + {% assign todayDay = 'now' | date: "%d" %} {% assign endYear = work.endDate | date: "%Y" %} {% assign endMonth = work.endDate | date: "%m" %} + {% assign endDay = work.endDate | date: "%d" %} {% if work.endDate.size == 0 %} {% assign endYear = todayYear %} {% assign endMonth = todayMonth %} + {% assign endDay = todayDay %} {% endif %} - {% assign startDate = startYear | append: '-' | append: startMonth %} - {% assign todayDate = todayYear | append: '-' | append: todayMonth %} + {% assign startDate = startYear | append: '-' | append: startMonth | append: '-' | append: startDay %} + {% assign endDate = endYear | append: '-' | append: endMonth | append: '-' | append: endDay %} + {% assign todayDate = todayYear | append: '-' | append: todayMonth | append: '-' | append: todayDay %} {% if startDate > todayDate %} - Not started + not started {% else %} {% assign yearDiff = endYear | minus: startYear %} {% assign monthDiff = endMonth | minus: startMonth %} - {% assign totalMonths = yearDiff | times: 12 | plus: monthDiff %} + {% assign dayDiff = endDay | minus: startDay %} - {% if totalMonths < 0 %} - {% assign totalMonths = 0 %} + {% if monthDiff < 0 or (monthDiff == 0 and dayDiff < 0) %} + {% assign yearDiff = yearDiff | minus: 1 %} + {% assign monthDiff = monthDiff | plus: 12 %} {% endif %} - {% assign finalYears = totalMonths | divided_by: 12 %} - {% assign finalMonths = totalMonths | modulo: 12 %} - - {% if finalMonths == 0 and totalMonths > 0 %} - {% assign finalMonths = 12 %} - {% assign finalYears = finalYears | minus: 1 %} + {% if dayDiff < 0 %} + {% assign monthDiff = monthDiff | minus: 1 %} {% endif %} {% assign unitYear = "year" %} - {% if finalYears != 1 %} {% assign unitYear = "years" %} {% endif %} + {% if yearDiff != 1 %} {% assign unitYear = "years" %} {% endif %} {% assign unitMonth = "month" %} - {% if finalMonths != 1 %} {% assign unitMonth = "months" %} {% endif %} + {% if monthDiff != 1 %} {% assign unitMonth = "months" %} {% endif %} {% include components/from-to.html from=work.startDate to=work.endDate format=from_to_format %} - {{ finalYears }} {{ unitYear }}, {{ finalMonths }} {{ unitMonth }} + {{ yearDiff }} {{ unitYear }}, {{ monthDiff }} {{ unitMonth }} {% endif %}
{% endif %} +