Skip to content

Commit 0eece76

Browse files
committed
calendar: render event times in America/New_York
1 parent 9db629a commit 0eece76

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

templates/page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h1>{{ page.title }}</h1>
1919
{% endif -%}
2020

2121
{%- if page.extra.add_to_calendar and page.extra.start and page.extra.end %}
22-
<p><em>Event Time: {{ page.extra.start | date(format="%B %d, %Y at %H:%M UTC") }}</em></p>
22+
<p><em>Event Time: {{ page.extra.start | date(format="%B %d, %Y at %I:%M %p %Z", timezone="America/New_York") }}</em></p>
2323
{% endif -%}
2424

2525
{{ page.content | safe }}

templates/shortcodes/ics.html

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,37 @@
33
{%- set event_end = end -%}
44
{%- set event_location = location | default(value="") -%}
55
{%- set event_description = description | default(value="") -%}
6+
{%- set calendar_tz = "America/New_York" -%}
7+
{%- set event_slug = event_title | slugify -%}
68

7-
{%- set ics_start = event_start | date(format="%Y%m%dT%H%M%SZ") -%}
8-
{%- set ics_end = event_end | date(format="%Y%m%dT%H%M%SZ") -%}
9+
{%- set ics_start = event_start | date(format="%Y%m%dT%H%M%S", timezone=calendar_tz) -%}
10+
{%- set ics_end = event_end | date(format="%Y%m%dT%H%M%S", timezone=calendar_tz) -%}
911
{%- set ics_content = "BEGIN:VCALENDAR
1012
VERSION:2.0
1113
PRODID:-//Triangle BitDevs//Event//EN
14+
BEGIN:VTIMEZONE
15+
TZID:America/New_York
16+
X-LIC-LOCATION:America/New_York
17+
BEGIN:DAYLIGHT
18+
TZOFFSETFROM:-0500
19+
TZOFFSETTO:-0400
20+
TZNAME:EDT
21+
DTSTART:19700308T020000
22+
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
23+
END:DAYLIGHT
24+
BEGIN:STANDARD
25+
TZOFFSETFROM:-0400
26+
TZOFFSETTO:-0500
27+
TZNAME:EST
28+
DTSTART:19701101T020000
29+
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
30+
END:STANDARD
31+
END:VTIMEZONE
1232
BEGIN:VEVENT
13-
UID:" ~ event_start ~ "@trianglebitdevs.org
14-
DTSTAMP:" ~ ics_start ~ "
15-
DTSTART:" ~ ics_start ~ "
16-
DTEND:" ~ ics_end ~ "
33+
UID:" ~ ics_start ~ "-" ~ event_slug ~ "@trianglebitdevs.org
34+
DTSTAMP;TZID=America/New_York:" ~ ics_start ~ "
35+
DTSTART;TZID=America/New_York:" ~ ics_start ~ "
36+
DTEND;TZID=America/New_York:" ~ ics_end ~ "
1737
SUMMARY:" ~ event_title ~ "
1838
LOCATION:" ~ event_location ~ "
1939
DESCRIPTION:" ~ event_description ~ "
@@ -22,4 +42,4 @@
2242

2343
{%- set ics_data_uri = "data:text/calendar;charset=utf8," ~ ics_content | urlencode -%}
2444

25-
<a href="{{ ics_data_uri }}" download="{{ event_title | slugify }}.ics">Add to Calendar (.ics)</a>
45+
<a href="{{ ics_data_uri }}" download="{{ event_slug }}.ics">Add to Calendar (.ics)</a>

0 commit comments

Comments
 (0)