From 473768f37d133f52c1e8b6b4b4269c5aa01e0f6a Mon Sep 17 00:00:00 2001 From: Lorenz Schmid Date: Tue, 27 Aug 2024 13:31:37 +0200 Subject: [PATCH] Add timezone parameter and calculate all timestamps according to it --- Gemfile.lock | 2 +- README.md | 12 ++++++++++++ _config.example.yml | 3 +++ _includes/js/program.js | 19 +++++++++---------- _includes/partials/get_talk_time.html | 4 ++-- _includes/partials/get_talk_timestamp.html | 10 ++++++++-- _layouts/program.html | 2 +- jekyll-theme-conference.gemspec | 2 +- 8 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7c340b05..93739cd5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - jekyll-theme-conference (3.6.5) + jekyll-theme-conference (3.6.6) jekyll (~> 4.0) GEM diff --git a/README.md b/README.md index 3072a943..35c9eb9e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ The theme was originally created for the yearly Winterkongress conference of the * [Theme Verification](#theme-verification) * [Collection URLs](#collection-urls) * [Language](#language) + * [Timezone](#timezone) * [Navigation Bar](#navigation-bar) * [Open Graph Link Preview](#open-graph-link-preview) * [Main Landing Page](#main-landing-page) @@ -251,6 +252,17 @@ conference: lang: en ``` +### Timezone + +Multiple dynamic features such as showing the current day in the program or live indications require correct timing. Define the timezone in which the conference takes place with the `tz` property set to a valid [UTC timezone offset](https://en.wikipedia.org/wiki/List_of_UTC_offsets) in the format `"+/-HH:MM"`: + +Example: + +```yaml +conference: + tz: "+02:00" +``` + ### Navigation Bar The navigation bar is located at the top and visible on every site. On the right it show the title of the website (`site.title`) followed by the links listed under the `links` property of the `navigation` property. See the _Content_ > _Links_ section below for the available properties per link. diff --git a/_config.example.yml b/_config.example.yml index 5d0bcf07..cfbfaa0c 100644 --- a/_config.example.yml +++ b/_config.example.yml @@ -56,6 +56,9 @@ conference: # Language lang: en + # Timezone + tz: "+02:00" + # Show theme errors: show_errors: True diff --git a/_includes/js/program.js b/_includes/js/program.js index ea4f5904..a0799611 100644 --- a/_includes/js/program.js +++ b/_includes/js/program.js @@ -6,37 +6,36 @@ window.conference.program = (() => { }; const init = () => { - if ($('#day-list')) { + if ($("#day-list")) { // Switch to day if page load with hash const hash = window.location.hash; if (hash) { - $('#day-list a[href="' + hash + '"]').tab('show'); + $('#day-list a[href="' + hash + '"]').tab("show"); } // Switch to day if today else { - let today = new Date(); - today.setHours(0,0,0,0); + const now = new Date(); + const tsNow = Math.floor(now.getTime() / 1000); $('a[data-toggle="tab"]').each(function () { - let d = new Date($(this).data('date')); - d.setHours(0,0,0,0); + const tsMidnight = new Date($(this).data("ts") * 1000); - if (today.getTime() === d.getTime()) { - $(this).tab('show'); + if (tsMidnight <= tsNow < tsMidnight + 24 * 60 * 60) { + $(this).tab("show"); updateHash(this.hash); } }); } // Add current selected day as hash to URL while keeping current scrolling position - $('a[data-toggle="tab"]').on('shown.bs.tab', function () { + $('a[data-toggle="tab"]').on("shown.bs.tab", function () { updateHash(this.hash); }); } }; return { - init: init + init: init, }; })(); diff --git a/_includes/partials/get_talk_time.html b/_includes/partials/get_talk_time.html index 9c58c349..499aba46 100644 --- a/_includes/partials/get_talk_time.html +++ b/_includes/partials/get_talk_time.html @@ -1,5 +1,5 @@ -{%- assign talk_start = t.time_start -%} -{%- assign talk_end = t.time_end -%} +{%- assign talk_start = t.time_start | default: "00:00" -%} +{%- assign talk_end = t.time_end | default: "00:00" -%} {%- if talk_start contains ' +' -%} {%- assign talk_start_day = talk_start | split: ' +' | last | plus: 0 -%} diff --git a/_includes/partials/get_talk_timestamp.html b/_includes/partials/get_talk_timestamp.html index f258664a..b2699f33 100644 --- a/_includes/partials/get_talk_timestamp.html +++ b/_includes/partials/get_talk_timestamp.html @@ -1,9 +1,15 @@ {%- include partials/get_talk_time.html -%} -{%- assign datetime_start = d.date | append: " " | append: talk_start -%} +{%- assign datetime_start = d.date | append: "T" | append: talk_start | append: ":00" -%} +{%- if site.conference.tz -%} + {%- assign datetime_start = datetime_start | append: site.conference.tz -%} +{%- endif -%} {%- assign add_days_start = talk_start_day | times: 24 | times: 60 | times: 60 -%} {%- assign timestamp_start = datetime_start | date: "%s" | plus: add_days_start | date: "%s" -%} -{%- assign datetime_end = d.date | append: " " | append: talk_end -%} +{%- assign datetime_end = d.date | append: "T" | append: talk_end | append: ":00" -%} +{%- if site.conference.tz -%} + {%- assign datetime_end = datetime_end | append: site.conference.tz -%} +{%- endif -%} {%- assign add_days_end = talk_end_day | times: 24 | times: 60 | times: 60 -%} {%- assign timestamp_end = datetime_end | date: "%s" | plus: add_days_end | date: "%s" -%} diff --git a/_layouts/program.html b/_layouts/program.html index b55b145a..03882e47 100644 --- a/_layouts/program.html +++ b/_layouts/program.html @@ -16,7 +16,7 @@

- {{ day_name }} + {{ day_name }} {%- endfor %} diff --git a/jekyll-theme-conference.gemspec b/jekyll-theme-conference.gemspec index 023ee218..f6e92d46 100644 --- a/jekyll-theme-conference.gemspec +++ b/jekyll-theme-conference.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "jekyll-theme-conference" - spec.version = "3.6.5" + spec.version = "3.6.6" spec.authors = ["Lorenz Schmid"] spec.email = ["lorenzschmid@users.noreply.github.com"]