Skip to content

Commit 077aae2

Browse files
davidcollomtoshywoshyjjasghar
authored
Update Program to only show Timezoned dates if Event and User timezones are different (#15451)
Co-authored-by: Toshaan Bharvani <[email protected]> Co-authored-by: JJ Asghar <[email protected]>
1 parent fe4cc97 commit 077aae2

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

themes/devopsdays-theme/layouts/program/single.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h2>Program</h2>
1717
{{ if eq $p nil }}
1818
{{ $p = $e }}
1919
{{ end }}
20-
20+
2121
{{- if $e.startdate -}}
2222
{{/* {{- range where $.Site.Pages "Type" "talk" -}} */}}
2323
{{ if (where (readDir (printf "content/events/%s/" $e.name)) "Name" "program") }}
@@ -106,6 +106,7 @@ <h2>Program</h2>
106106
{{- end -}}
107107
{{- if $e.timezone -}}
108108
<script>
109+
var eventTimezone = "{{ $e.timezone }}";
109110
var eventTimeOffset = (Intl.DateTimeFormat(userLang,{ timeZone: "{{ $e.timezone }}", timeZoneName: 'longOffset' }).formatToParts().find(part => part.type==='timeZoneName').value).slice(3,99);
110111
var eventTimeAbbreviation = Intl.DateTimeFormat(userLang,{ timeZone: "{{ $e.timezone }}", timeZoneName: 'short' }).formatToParts().find(part => part.type==='timeZoneName').value;
111112
</script>
@@ -159,13 +160,15 @@ <h5 class="mb-0">
159160
</script>
160161
{{- end -}}
161162
<script>
162-
document.write("<strong>");
163-
document.write(String(localstarttime.getHours()).padStart(2,"0")+":"+String(localstarttime.getMinutes()).padStart(2,"0"));
164-
document.write("&nbsp;-&nbsp;");
165-
document.write(String(localendtime.getHours()).padStart(2,"0")+":"+String(localendtime.getMinutes()).padStart(2,"0"));
166-
document.write("&nbsp;");
167-
document.write(userTimeAbbreviation);
168-
document.write("</strong>");
163+
if (userTimeZone !=eventTimezone) {
164+
document.write("<abbr title='"+userTimeZone+"'>");
165+
document.write(String(localstarttime.getHours()).padStart(2,"0")+":"+String(localstarttime.getMinutes()).padStart(2,"0"));
166+
document.write("&nbsp;-&nbsp;");
167+
document.write(String(localendtime.getHours()).padStart(2,"0")+":"+String(localendtime.getMinutes()).padStart(2,"0"));
168+
document.write("&nbsp;");
169+
document.write(userTimeAbbreviation);
170+
document.write("</abbr>");
171+
}
169172
</script>
170173
{{- end -}}
171174
</div>
@@ -179,7 +182,7 @@ <h5 class="mb-0">
179182
{{- if .comments -}}
180183
<span class="program-page-desc">{{ .comments | markdownify }}<br/></span>
181184
{{- end -}}
182-
{{- else if or (eq .type "talk") (eq .type "workshop") -}}
185+
{{- else if or (eq .type "talk") (eq .type "workshop") -}}
183186
{{- if .custom_url -}}
184187
<a href="{{ .custom_url | safeURL }}">{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a><br/>
185188
{{- else -}}
@@ -188,12 +191,12 @@ <h5 class="mb-0">
188191
{{- if eq ($.Scratch.Get "icons") "TRUE" -}}
189192
{{- with ($.Scratch.Get (printf "%s-video_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-solid fa-video" aria-hidden="true"></i>&nbsp;Video</a>&nbsp;{{- end -}}
190193
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-regular fa-file-lines" aria-hidden="true"></i>&nbsp;Slides</a>&nbsp;</a>&nbsp;{{- end -}}
191-
{{- end -}}
192-
{{- if .comments -}}
193-
<span class="program-page-desc">{{ .comments | markdownify }}<br/></span>
194-
{{- end -}}
194+
{{- end -}}
195+
{{- if .comments -}}
196+
<span class="program-page-desc">{{ .comments | markdownify }}<br/></span>
197+
{{- end -}}
195198

196-
{{- else if eq .type "ignite" -}}
199+
{{- else if eq .type "ignite" -}}
197200
{{ .title }}
198201
<!-- new ignite code start -->
199202
<ul class = "list-unstyled">
@@ -205,10 +208,10 @@ <h5 class="mb-0">
205208
<a href="/events/{{ $e.name }}/program/{{ .title }}">{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a>
206209
{{- if eq ($.Scratch.Get "icons") "TRUE" -}}
207210
{{- with ($.Scratch.Get (printf "%s-video_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-solid fa-video" aria-hidden="true"></i>&nbsp;Video</a>&nbsp;{{- end -}}
208-
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-regular fa-file-lines" aria-hidden="true"></i>&nbsp;Slides</a>&nbsp;</a>&nbsp;{{- end -}}
209-
211+
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-regular fa-file-lines" aria-hidden="true"></i>&nbsp;Slides</a>&nbsp;</a>&nbsp;{{- end -}}
212+
210213
{{- end -}}
211-
214+
212215
</li>
213216
{{- end -}}
214217
{{- end -}}
@@ -219,9 +222,9 @@ <h5 class="mb-0">
219222
<a href="/events/{{ $e.name }}/program/{{ .title }}">{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a>
220223
{{- if eq ($.Scratch.Get "icons") "TRUE" -}}
221224
{{- with ($.Scratch.Get (printf "%s-video_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-solid fa-video" aria-hidden="true"></i>&nbsp;Video</a>&nbsp;{{- end -}}
222-
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-regular fa-file-lines" aria-hidden="true"></i>&nbsp;Slides</a>&nbsp;</a>&nbsp;{{- end -}}
225+
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa-regular fa-file-lines" aria-hidden="true"></i>&nbsp;Slides</a>&nbsp;</a>&nbsp;{{- end -}}
223226
{{- end -}}
224-
227+
225228
</li>
226229
{{- end -}}
227230
{{- end -}}

0 commit comments

Comments
 (0)