Various improvements
This commit is contained in:
parent
5f6cb57c2a
commit
bc7a2e89d0
4 changed files with 160 additions and 75 deletions
|
|
@ -7,11 +7,13 @@
|
|||
{% set row = {"flight": flight_row, "train": train_row, "ferry": ferry_row, "coach": coach_row, "bus": bus_row} %}
|
||||
|
||||
{% macro trip_duration(depart, arrive) -%}
|
||||
{%- set mins = ((arrive - depart).total_seconds() // 60) | int -%}
|
||||
{%- set h = mins // 60 -%}
|
||||
{%- set m = mins % 60 -%}
|
||||
{%- if h %}{{ h }}h {% endif -%}
|
||||
{%- if m %}{{ m }}m{% elif h %}0m{% endif -%}
|
||||
{%- if depart.hour is defined and arrive.hour is defined -%}
|
||||
{%- set mins = ((arrive - depart).total_seconds() // 60) | int -%}
|
||||
{%- set h = mins // 60 -%}
|
||||
{%- set m = mins % 60 -%}
|
||||
{%- if h %}{{ h }}h {% endif -%}
|
||||
{%- if m %}{{ m }}m{% elif h %}0m{% endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro next_and_previous() %}
|
||||
|
|
@ -329,9 +331,10 @@
|
|||
|
||||
{% elif e.element_type == "train" %}
|
||||
{% set item = e.detail %}
|
||||
{% set depart_date = item.depart.date() if item.depart.hour is defined else item.depart %}
|
||||
{% set arrive_date = item.arrive.date() if item.arrive.hour is defined else item.arrive %}
|
||||
{% set is_overnight = depart_date != arrive_date %}
|
||||
{% set has_time = item.depart.hour is defined and item.arrive.hour is defined %}
|
||||
{% set depart_date = item.depart.date() if has_time else item.depart %}
|
||||
{% set arrive_date = item.arrive.date() if has_time else item.arrive %}
|
||||
{% set is_overnight = has_time and depart_date != arrive_date %}
|
||||
<div class="trip-transport-card my-1">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
|
|
@ -341,12 +344,16 @@
|
|||
{% if is_overnight %}<span class="badge bg-secondary text-nowrap ms-1">Night train</span>{% endif %}
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
{{ item.depart.strftime("%H:%M") }}
|
||||
→ {{ item.arrive.strftime("%H:%M") }}{% if is_overnight %} <span class="text-muted small">+1 day</span>{% endif %}
|
||||
{% if has_time %}
|
||||
{{ item.depart.strftime("%H:%M") }}
|
||||
→ {{ item.arrive.strftime("%H:%M") }}{% if is_overnight %} <span class="text-muted small">+1 day</span>{% endif %}
|
||||
{% endif %}
|
||||
{% if item.class %}
|
||||
<span class="badge bg-info text-nowrap">{{ item.class }}</span>
|
||||
{% endif %}
|
||||
<span class="text-muted">🕒{{ trip_duration(item.depart, item.arrive) }}</span>
|
||||
{% if has_time %}
|
||||
<span class="text-muted">🕒{{ trip_duration(item.depart, item.arrive) }}</span>
|
||||
{% endif %}
|
||||
{% if item.distance %}
|
||||
<span class="text-muted">🛤️ {{ "{:,.0f} km".format(item.distance) }}</span>
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue