Skip to content
This repository has been archived by the owner on Jul 21, 2019. It is now read-only.

Commit

Permalink
Merge pull request #642 from tgross/better_date_comparisons
Browse files Browse the repository at this point in the history
updates to use time comparisons for start/end dates
  • Loading branch information
bridgetkromhout authored Aug 27, 2018
2 parents 0109891 + b743c6f commit 3952c01
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions layouts/events/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2>Future</h2>
{{- $.Scratch.Set "close-tag" "false" -}}
{{- range sort $.Site.Data.events "startdate" -}}
{{- if .startdate -}}
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
{{- if ge (time .enddate) now -}}
{{- if ne ($.Scratch.Get "year") (dateFormat "2006" .startdate) -}}
{{- $.Scratch.Set "year" (dateFormat "2006" .startdate) -}}
{{- $.Scratch.Set "year-displayed" "false" -}}
Expand All @@ -31,7 +31,7 @@ <h4 class="events-page-months">{{ dateFormat "January" .startdate }}</h4>
{{- $.Scratch.Set "close-tag" "true" -}}
{{- end -}}
{{- if ne .startdate .enddate }}
{{- if eq (dateFormat "January" .startdate) (dateFormat "January" .enddate ) -}}
{{- if eq (time .startdate).Month (time .enddate).Month -}}
<a href = "{{ (printf "events/%s" .name) | absURL }}" class = "events-page-event">
{{ dateFormat "Jan 2" .startdate }} - {{ dateFormat "2" .enddate }}:
{{ .city }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="row">
{{- range sort $.Site.Data.events "startdate" -}}
{{- if .startdate -}}
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
{{- if ge (time .enddate) now -}}
{{- $.Scratch.Set "city" .city -}}
{{- $.Scratch.Set "year" .year -}}
{{- $.Scratch.Set "logo" "unset" -}}
Expand All @@ -24,7 +24,7 @@
{{- end -}}
<br/>
{{- if ne .startdate .enddate -}}
{{- if eq (dateFormat "January" .startdate) (dateFormat "January" .enddate ) -}}
{{- if eq (time .startdate).Month (time .enddate).Month -}}
<span class="homepage-grid-date">
{{ dateFormat "Jan 2" .startdate }} - {{ dateFormat "2, 2006" .enddate }}<br />
</span>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/events/cta.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{{- else -}}
{{- if $e.startdate -}}
{{- if $e.registration_date_start -}}
{{- if and (ge (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) (dateFormat "2006-01-02" $e.registration_date_start)) (le (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) (dateFormat "2006-01-02" $e.registration_date_end)) -}}
{{- if and (ge now (time $e.registration_date_start)) (le now (time $e.registration_date_end)) -}}
{{- if $e.registration_link -}}
{{- if eq $e.registration_link "" -}}
{{- $.Scratch.Set "registration_link" ((printf "/events/%s/registration" $e.name) | absURL ) -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/future.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- range sort $.Site.Data.events "startdate" -}}
{{- if .startdate -}}
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
{{- if ge (time .enddate) now -}}
{{- if ne ($.Scratch.Get "year") (dateFormat "2006" .startdate) -}}
{{- $.Scratch.Set "year" (dateFormat "2006" .startdate) -}}
{{- $.Scratch.Set "year-displayed" "false" -}}
Expand All @@ -19,7 +19,7 @@ <h4 class="left-nav-months">{{ dateFormat "January" .startdate }}</h4>
{{- $.Scratch.Set "month-displayed" "true" -}}
{{- end -}}
{{- if ne .startdate .enddate }}
{{- if eq (dateFormat "January" .startdate) (dateFormat "January" .enddate ) -}}
{{- if eq (time .startdate).Month (time .enddate).Month -}}
<a href = "{{ (printf "events/%s" .name ) | absURL }}" class = "left-nav-event">
{{ dateFormat "Jan 2" .startdate }} - {{ dateFormat "2" .enddate }}:
{{ .city }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
{{ if .startdate }}

// if the startdate is today or in the future
{{ if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) }}
{{ if ge (time .enddate) now }}

// if the startdate month and enddate month are different, show both months
{{ if ne (dateFormat "Jan" .startdate) (dateFormat "Jan" .enddate) }}
{{ if ne (time .startdate).Month (time .enddate).Month }}
['{{ .city}}', {{ .coordinates | safeJS }}, '{{ dateFormat "Jan 2" .startdate }}-{{ dateFormat "Jan 2" .enddate }}', '/events/{{ .name }}'],
{{ else }}

Expand Down
2 changes: 1 addition & 1 deletion layouts/section/events.rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<generator>Hugo -- gohugo.io</generator>
{{- range sort $.Site.Data.events "startdate" -}}
{{- if .startdate -}}
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
{{- if ge (time .enddate) now -}}
<item>
{{- if eq .startdate .enddate -}}
<title>devopsdays {{ .city }} {{ .year }} is coming! {{ dateFormat "Monday, January 2, 2006" .startdate }}</title>
Expand Down
4 changes: 2 additions & 2 deletions layouts/section/speaking.rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<generator>Hugo -- gohugo.io</generator>
{{- range sort $.Site.Data.events "startdate" -}}
{{- if .startdate -}}
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
{{- if ge (time .enddate) now -}}
{{ if .cfp_date_end }}
{{ if ge (dateFormat "2006-01-02" .cfp_date_end) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) }}
{{ if ge (time .cfp_date_end) now }}
<item>
<title>devopsdays {{ .city }} {{ .year }}</title>
<link>{{ (printf "events/%s" .name) | absURL }}</link>
Expand Down

0 comments on commit 3952c01

Please sign in to comment.