summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-09-01 08:58:59 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-09-01 08:58:59 -0700
commitbb546eb7e0477e85ba14eeeaf91453f456241da9 (patch)
tree03252771e1555d03be57fcf7794608e1c836b690 /src
parent04da9cbfa3d9ef5620d6b9d569606cc073c30320 (diff)
Added hours, minutes, seconds calculation to training page
Diffstat (limited to 'src')
-rw-r--r--src/templates/macros/hms.ftl13
-rw-r--r--src/templates/templates/training.ftl3
2 files changed, 15 insertions, 1 deletions
diff --git a/src/templates/macros/hms.ftl b/src/templates/macros/hms.ftl
new file mode 100644
index 0000000..f9662af
--- /dev/null
+++ b/src/templates/macros/hms.ftl
@@ -0,0 +1,13 @@
+<#macro hms seconds>
+ <#assign h = (seconds / 3600)?int />
+ <#assign m = (seconds % 3600 / 60)?int />
+ <#assign s = (seconds % 3600 % 60)?int />
+
+ <#if (seconds >= 3600)>
+ ${h}:${m}:${s}
+ <#elseif (seconds >= 60)>
+ ${m}:${s}
+ <#else>
+ ${s} seconds
+ </#if>
+</#macro>
diff --git a/src/templates/templates/training.ftl b/src/templates/templates/training.ftl
index 0490a9a..a6d30ea 100644
--- a/src/templates/templates/training.ftl
+++ b/src/templates/templates/training.ftl
@@ -1,5 +1,6 @@
<#include "/macros/common.ftl">
<#include "/macros/common-page.ftl">
+<#include "/macros/hms.ftl">
<@commonpage>
<@noticebox>
@@ -37,7 +38,7 @@
<#list videos as video>
<article>
<div class="image <#if video.completed>completed</#if>" id="${video.id}"><a href="#" onclick="playVideo('${video.id}'); return false"><img src="${video.image!staticRoot+"/images/videoimage.jpg"}" alt="${video.title}" /></a></div>
- <h2>${video.title}</h2> <span class="duration">${video.length}</span>
+ <h2>${video.title}</h2> <span class="duration"><@hms seconds=video.length /></span>
</article>
</#list>
</div>