Skip to content

Commit

Permalink
change: /_includes/pro/resume/work.html calculation iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobgabriel committed Dec 26, 2023
1 parent 3c887ad commit d364c06
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions _includes/pro/resume/work.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,54 @@ <h2 id="work" class="h3 hr-bottom">

{% if work.startDate.size > 0 %}
<p class="faded">
{% 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 %}
<i class="faded">Not started</i>
<i class="faded">not started</i>
{% 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 %}
<i class="faded"><span class="icon-history"></span> {{ finalYears }} {{ unitYear }}, {{ finalMonths }} {{ unitMonth }}</i>
<i class="faded"><span class="icon-history"></span> {{ yearDiff }} {{ unitYear }}, {{ monthDiff }} {{ unitMonth }}</i>
{% endif %}
</p>
{% endif %}


<!-- {% if work.startDate.size > 0 %}
<p class="faded">
{% assign todayYear = 'now' | date: "%Y" %} {% assign startYear =
Expand Down

0 comments on commit d364c06

Please sign in to comment.