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

Commit 3952c01

Browse files
Merge pull request #642 from tgross/better_date_comparisons
updates to use time comparisons for start/end dates
2 parents 0109891 + b743c6f commit 3952c01

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

layouts/events/single.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Future</h2>
1212
{{- $.Scratch.Set "close-tag" "false" -}}
1313
{{- range sort $.Site.Data.events "startdate" -}}
1414
{{- if .startdate -}}
15-
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
15+
{{- if ge (time .enddate) now -}}
1616
{{- if ne ($.Scratch.Get "year") (dateFormat "2006" .startdate) -}}
1717
{{- $.Scratch.Set "year" (dateFormat "2006" .startdate) -}}
1818
{{- $.Scratch.Set "year-displayed" "false" -}}
@@ -31,7 +31,7 @@ <h4 class="events-page-months">{{ dateFormat "January" .startdate }}</h4>
3131
{{- $.Scratch.Set "close-tag" "true" -}}
3232
{{- end -}}
3333
{{- if ne .startdate .enddate }}
34-
{{- if eq (dateFormat "January" .startdate) (dateFormat "January" .enddate ) -}}
34+
{{- if eq (time .startdate).Month (time .enddate).Month -}}
3535
<a href = "{{ (printf "events/%s" .name) | absURL }}" class = "events-page-event">
3636
{{ dateFormat "Jan 2" .startdate }} - {{ dateFormat "2" .enddate }}:
3737
{{ .city }}

layouts/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="row">
77
{{- range sort $.Site.Data.events "startdate" -}}
88
{{- if .startdate -}}
9-
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
9+
{{- if ge (time .enddate) now -}}
1010
{{- $.Scratch.Set "city" .city -}}
1111
{{- $.Scratch.Set "year" .year -}}
1212
{{- $.Scratch.Set "logo" "unset" -}}
@@ -24,7 +24,7 @@
2424
{{- end -}}
2525
<br/>
2626
{{- if ne .startdate .enddate -}}
27-
{{- if eq (dateFormat "January" .startdate) (dateFormat "January" .enddate ) -}}
27+
{{- if eq (time .startdate).Month (time .enddate).Month -}}
2828
<span class="homepage-grid-date">
2929
{{ dateFormat "Jan 2" .startdate }} - {{ dateFormat "2, 2006" .enddate }}<br />
3030
</span>

layouts/partials/events/cta.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
{{- else -}}
2222
{{- if $e.startdate -}}
2323
{{- if $e.registration_date_start -}}
24-
{{- 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)) -}}
24+
{{- if and (ge now (time $e.registration_date_start)) (le now (time $e.registration_date_end)) -}}
2525
{{- if $e.registration_link -}}
2626
{{- if eq $e.registration_link "" -}}
2727
{{- $.Scratch.Set "registration_link" ((printf "/events/%s/registration" $e.name) | absURL ) -}}

layouts/partials/future.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- range sort $.Site.Data.events "startdate" -}}
22
{{- if .startdate -}}
3-
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
3+
{{- if ge (time .enddate) now -}}
44
{{- if ne ($.Scratch.Get "year") (dateFormat "2006" .startdate) -}}
55
{{- $.Scratch.Set "year" (dateFormat "2006" .startdate) -}}
66
{{- $.Scratch.Set "year-displayed" "false" -}}
@@ -19,7 +19,7 @@ <h4 class="left-nav-months">{{ dateFormat "January" .startdate }}</h4>
1919
{{- $.Scratch.Set "month-displayed" "true" -}}
2020
{{- end -}}
2121
{{- if ne .startdate .enddate }}
22-
{{- if eq (dateFormat "January" .startdate) (dateFormat "January" .enddate ) -}}
22+
{{- if eq (time .startdate).Month (time .enddate).Month -}}
2323
<a href = "{{ (printf "events/%s" .name ) | absURL }}" class = "left-nav-event">
2424
{{ dateFormat "Jan 2" .startdate }} - {{ dateFormat "2" .enddate }}:
2525
{{ .city }}

layouts/partials/map.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
{{ if .startdate }}
2222

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

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

layouts/section/events.rss.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<generator>Hugo -- gohugo.io</generator>
2121
{{- range sort $.Site.Data.events "startdate" -}}
2222
{{- if .startdate -}}
23-
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
23+
{{- if ge (time .enddate) now -}}
2424
<item>
2525
{{- if eq .startdate .enddate -}}
2626
<title>devopsdays {{ .city }} {{ .year }} is coming! {{ dateFormat "Monday, January 2, 2006" .startdate }}</title>

layouts/section/speaking.rss.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
<generator>Hugo -- gohugo.io</generator>
2121
{{- range sort $.Site.Data.events "startdate" -}}
2222
{{- if .startdate -}}
23-
{{- if ge (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) -}}
23+
{{- if ge (time .enddate) now -}}
2424
{{ if .cfp_date_end }}
25-
{{ if ge (dateFormat "2006-01-02" .cfp_date_end) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now)) }}
25+
{{ if ge (time .cfp_date_end) now }}
2626
<item>
2727
<title>devopsdays {{ .city }} {{ .year }}</title>
2828
<link>{{ (printf "events/%s" .name) | absURL }}</link>

0 commit comments

Comments
 (0)