Skip to content

Instantly share code, notes, and snippets.

@eteubert
Last active December 7, 2016 20:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eteubert/577c4da560c7a615054dd6fb1fe79826 to your computer and use it in GitHub Desktop.
Save eteubert/577c4da560c7a615054dd6fb1fe79826 to your computer and use it in GitHub Desktop.
Template für Podlove Podcast Publisher. Gesamtdauer aller Episoden.
{% set total = 0 %}
{% for episode in podcast.episodes %}
{% set total = total + episode.duration.totalMilliseconds %}
{% endfor %}
{# // is division and then rounding down (floor) #}
{% set hours = total // (1000 * 3600) %}
{% set minutes = (total // (1000 * 60)) % 60 %}
{% set seconds = (total // 1000) % 60 %}
{% if hours < 10 %}
{% set hours = "0" ~ hours %}
{% endif %}
{% if minutes < 10 %}
{% set minutes = "0" ~ minutes %}
{% endif %}
{% if seconds < 10 %}
{% set seconds = "0" ~ seconds %}
{% endif %}
Gesamtdauer aller {{ podcast.episodes|length }} Episoden: {{ hours }} Stunden {{ minutes }} Minuten {{ seconds }} Sekunden
@tobybaier
Copy link

Dankeschön :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment