Skip to content

Commit

Permalink
Fix check of inconsistent times in program (#49)
Browse files Browse the repository at this point in the history
Fix the logic for checking inconsistencies on time schedule in the
program. Compare numerical values by converting timestamps to UNIX
timestamps.
  • Loading branch information
santisoler authored Nov 10, 2023
1 parent 75d0203 commit 935d604
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions templates/program.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1>{{ page.title }}</h1>
<div class="row gy-5">
{% for day, events in page.extra.events | group_by(attribute="day") %}
{% set_global i = 0 %}
{% set_global previous_end = "" %}
{% set_global previous_end = 0 %}

<div class="col-lg-6 col-md-12">
<h2 id={{ day | date(format="%Y-%m-%d") }} class="timeline-day">{{ day | date(format="%A %e") }}</h2>
Expand All @@ -37,15 +37,17 @@ <h2 id={{ day | date(format="%Y-%m-%d") }} class="timeline-day">{{ day | date(fo
<ul>
{% for event in events | sort(attribute="from") %}

{# Transform from and to as timestamps #}
{% set from = macros::timestamp(day=event.day, hhmm=event.from) %}
{% set to = macros::timestamp(day=event.day, hhmm=event.to) %}

{# Check consistency of start and end times #}
{% if i != 0 and previous_end != event.from %}
{% set from_unix = from | date(format="%s") | int %}
{% if previous_end > from_unix %}
{{ throw(message="Inconsistent start time for " ~ "'" ~ event.title ~ "'" ) }}
{% endif %}
{% set_global previous_end = event.to %}
{% set_global previous_end = to | date(format="%s") | int %}

{# Transform from and to as timestamps #}
{% set from = macros::timestamp(day=event.day, hhmm=event.from) %}
{% set to = macros::timestamp(day=event.day, hhmm=event.to) %}

<li>
<span class="timeline-date">
Expand Down

0 comments on commit 935d604

Please sign in to comment.