summaryrefslogtreecommitdiff
path: root/src/main/resources/templates/macros/hms.ftl
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/templates/macros/hms.ftl')
-rw-r--r--src/main/resources/templates/macros/hms.ftl25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/resources/templates/macros/hms.ftl b/src/main/resources/templates/macros/hms.ftl
new file mode 100644
index 0000000..339b8a9
--- /dev/null
+++ b/src/main/resources/templates/macros/hms.ftl
@@ -0,0 +1,25 @@
+<#macro hms seconds>
+ <#assign h = (seconds / 3600)?int />
+ <#assign m = (seconds % 3600 / 60)?int />
+ <#assign s = (seconds % 3600 % 60)?int />
+
+ <#if (h < 10)>
+ <#assign h = "0${h}" />
+ </#if>
+
+ <#if (m < 10)>
+ <#assign m = "0${m}" />
+ </#if>
+
+ <#if (s < 10)>
+ <#assign s = "0${s}" />
+ </#if>
+
+ <#if (seconds >= 3600)>
+ ${h}:${m}:${s}
+ <#elseif (seconds >= 60)>
+ ${m}:${s}
+ <#else>
+ ${s} seconds
+ </#if>
+</#macro>