Skip to content

Commit

Permalink
duration compiuted
Browse files Browse the repository at this point in the history
  • Loading branch information
zorzigio committed Aug 26, 2022
1 parent fa7a9c2 commit f5deec0
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 21 deletions.
2 changes: 1 addition & 1 deletion content
30 changes: 28 additions & 2 deletions layouts/education/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ <h1>
{{ $articles := sort $articles ".Params.End" "desc" }}
{{ range $articles }}

{{/* Calculate End Date */}}
{{- $end := now.UTC.Format "2006-01-02" }}
{{- if ne .Params.Ongoing true }}
{{- $end = .Params.End }}
{{- end }}
{{/* Calculate Number of Years */}}
{{- $years := sub (int ( $end | dateFormat "2006")) (int (.Params.Start | dateFormat "2006")) }}
{{/* Months */}}
{{- $months := sub (int ( $end | dateFormat "1")) (int (.Params.Start | dateFormat "1")) }}
{{- if lt $months 0 }}
{{- $months = add 13 $months }}
{{- $years = sub $years 1 }}
{{- else }}
{{- $months = add $months 1 }}
{{- end }}
{{/* Duration String */}}
{{- $duration := "" }}
{{- if and (gt $years 0) (gt $months 0) }}
{{- $duration = printf "%d yrs %d mos" $years $months }}
{{- else if gt $years 0 }}
{{- $duration = printf "%d yrs" $years }}
{{- else }}
{{- $duration = printf "%d mos" $months }}
{{- end}}


<div class="card">
<div class="card-back" icon-font="">
<div class="code">
Expand All @@ -72,7 +98,7 @@ <h1>
{{- if .Params.Ongoing }}
<span >Present </span >
{{- else }}
<span >{{ .Params.End | dateFormat "2006" }}</span >
<span >{{ $end | dateFormat "2006" }}</span >
{{- end }}
<br />
</div>
Expand All @@ -89,7 +115,7 @@ <h1>
{{- if .Params.Ongoing }}
<span >Present </span >
{{- else }}
<span >{{ .Params.End | dateFormat "2006" }}</span >
<span >{{ $end | dateFormat "2006" }}</span >
{{- end }}

</div>
Expand Down
63 changes: 46 additions & 17 deletions layouts/experience/list.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- define "main" }}

{{- if (and site.Params.profileMode.enabled .IsHome) }}
{{- partial "index_profile.html" . }}
{{- else }}
Expand Down Expand Up @@ -70,13 +71,35 @@ <h1>
{{- end }}
{{- end }}

{{/* {{ $articles := where (where .Site.RegularPages "Section" "experience") "Permalink" "!=" .Page.Permalink }}
{{ range sort $articles ".Params.End" "desc" }} */}}

{{ $articles := where (where .Site.RegularPages "Section" "experience") "Permalink" "!=" .Page.Permalink }}
{{ $articles := sort $articles ".Params.End" "desc" }}
{{ range $articles }}

{{/* Calculate End Date */}}
{{- $end := now.UTC.Format "2006-01-02" }}
{{- if ne .Params.Ongoing true }}
{{- $end = .Params.End }}
{{- end }}
{{/* Calculate Number of Years */}}
{{- $years := sub (int ( $end | dateFormat "2006")) (int (.Params.Start | dateFormat "2006")) }}
{{/* Months */}}
{{- $months := sub (int ( $end | dateFormat "1")) (int (.Params.Start | dateFormat "1")) }}
{{- if lt $months 0 }}
{{- $months = add 13 $months }}
{{- $years = sub $years 1 }}
{{- else }}
{{- $months = add $months 1 }}
{{- end }}
{{/* Duration String */}}
{{- $duration := "" }}
{{- if and (gt $years 0) (gt $months 0) }}
{{- $duration = printf "%d yrs %d mos" $years $months }}
{{- else if gt $years 0 }}
{{- $duration = printf "%d yrs" $years }}
{{- else }}
{{- $duration = printf "%d mos" $months }}
{{- end}}

<div class="card">
<div class="card-back" icon-font="">
<div class="code">
Expand All @@ -87,18 +110,23 @@ <h1>
{{- if .Params.Ongoing }}
<span >Present </span >
{{- else }}
<span >{{ .Params.End | dateFormat "Jan 2006" }}</span >
<span >{{ $end | dateFormat "Jan 2006" }}</span >
{{- end }}
<br />
<div class="card-content">
<span class="function">Description:</span>
<span >
{{ .Summary | plainify | htmlUnescape }}
{{ if .Truncated }}
...
{{ end }}
</span >
</div>
<span class="function">Duration: </span>
<span>{{ $duration }}</span>
<br />
{{- if .Summary }}
<div class="card-content">
<span class="function">Description:</span>
<span >
{{ .Summary | plainify | htmlUnescape }}
{{ if .Truncated }}
...
{{ end }}
</span >
</div>
{{- end }}
</div>
</div>
<div class="card-front" icon-font="">
Expand All @@ -109,14 +137,15 @@ <h1>
<div class="boolean">
{{ .Params.Company }}
</div>
<br />
<span >{{ .Params.Start | dateFormat "Jan 2006" }} <- </span >
<span>({{ .Params.Duration }}) -></span>
<span >{{ .Params.Start | dateFormat "Jan 2006" }} - </span >
{{/* <span>({{ $duration }}) {{ .Params.Duration }} -></span> */}}
{{- if .Params.Ongoing }}
<span >Present </span >
{{- else }}
<span >{{ .Params.End | dateFormat "Jan 2006" }}</span >
<span >{{ $end | dateFormat "Jan 2006" }}</span >
{{- end }}
<br />
<span>( {{ $duration }} )</span>

</div>
</div>
Expand Down
33 changes: 32 additions & 1 deletion layouts/experience/single.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
{{- define "main" }}


{{/* Calculate End Date */}}
{{- $end := now.UTC.Format "2006-01-02" }}
{{- if ne .Params.Ongoing true }}
{{- $end = .Params.End }}
{{- end }}
{{/* Calculate Number of Years */}}
{{- $years := sub (int ( $end | dateFormat "2006")) (int (.Params.Start | dateFormat "2006")) }}
{{/* Months */}}
{{- $months := sub (int ( $end | dateFormat "1")) (int (.Params.Start | dateFormat "1")) }}
{{- if lt $months 0 }}
{{- $months = add 13 $months }}
{{- $years = sub $years 1 }}
{{- else }}
{{- $months = add $months 1 }}
{{- end }}
{{/* Duration String */}}
{{- $duration := "" }}
{{- if and (gt $years 0) (gt $months 0) }}
{{- $duration = printf "%d yrs %d mos" $years $months }}
{{- else if gt $years 0 }}
{{- $duration = printf "%d yrs" $years }}
{{- else }}
{{- $duration = printf "%d mos" $months }}
{{- end}}


<article class="post-single">
<header class="post-header">
{{ partial "breadcrumbs.html" . }}
Expand All @@ -10,7 +37,11 @@ <h1 class="post-title exp-single-title">
{{ .Params.Company }} - {{ .Params.Jobtype }}
</div>
<div class="post-meta">
{{ .Params.Start | dateFormat "Jan 2006" }} - {{ .Params.End | dateFormat "Jan 2006" }} ({{ .Params.Duration }})
{{- if ne .Params.Ongoing true }}
{{ .Params.Start | dateFormat "Jan 2006" }} - {{ $end | dateFormat "Jan 2006" }} ({{ $duration }})
{{- else }}
{{ .Params.Start | dateFormat "Jan 2006" }} - Present ({{ $duration }})
{{- end }}
</div>
</header>
{{- $isHidden := .Params.cover.hidden | default site.Params.cover.hiddenInSingle | default site.Params.cover.hidden }}
Expand Down

0 comments on commit f5deec0

Please sign in to comment.