Skip to content

Commit

Permalink
Use local time zone's date
Browse files Browse the repository at this point in the history
  • Loading branch information
shushugah committed Mar 25, 2024
1 parent d690931 commit 1c596fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions _includes/event-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
class="event-card__info-column l-stack -vertical"
style="--stack-spacing: 0.25rem"
>
<time
datetime="{{ event.date }}"
><b>{{ event.date | all_time_zones: event.time_zones }}</b> {{ event.date | date: "%A, %d %b %Y"}}</time>
<time datetime="{{ event.date }}">
<b>{{ event.date | all_time_zones: event.time_zones }}</b>
</time>
{% if include.limit %}
<h3>
<a href="{{ event.url }}">{{ event.title }}</a>
Expand Down
3 changes: 1 addition & 2 deletions _layouts/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<h1 class="post-title">{{ page.title | escape }}</h1>
<div class="post-content">
<div class="event-time">
📆 <a target="_blank" href="{{ page.date | time_converter_url}}">{{ page.date | all_time_zones: page.time_zones }}</a>
{{ page.date | date: '%A, %d %B %Y ' }}
📆 <a target="_blank" href="{{ page.date | time_converter_url}}">{{ page.date | all_time_zones: page.time_zones }}</a>
</div>

{{ content }}
Expand Down
12 changes: 9 additions & 3 deletions _plugins/time_zones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ def first_time_zone(date, timezones)

def all_time_zones(date, timezones)
date = date.to_time
timezones ||= %w[Europe/Berlin]
timezones ||= %w[Europe/Berlin]

timezones.map { |tz|
date.getlocal(
TZInfo::Timezone.get(tz)
).strftime("%R %Z")
}.join(", ")
).strftime("%R %Z")
}.join(", ") + dmy(date, timezones)
end

private
def dmy(date, timezones)
date.getlocal(TZInfo::Timezone.get(timezones.first)).strftime(" %A, %d %B %Y")
end
end
end
Expand Down

0 comments on commit 1c596fa

Please sign in to comment.