Template:TimeHMS: Difference between revisions

From Melvor Idle
(Use :Time instead of :Common)
(Prefer template instead of module.)
Line 1: Line 1:
Takes in a number of seconds and converts it into "X days, H:M:S"
Takes in a number of seconds and converts it into "X days, H:M:S"
For example, {{T|TimeHMS|90135}} becomes {{TimeHMS|90135}}. This is a convenience function for [[Template:Time]].
For example, {{T|TimeHMS|90135}} becomes {{TimeHMS|90135}}. This is the shorthand notation variant for [[Template:Time]].
 
<onlyinclude><includeonly><!--
This uses a function inside of [[Module:Time]].<onlyinclude><includeonly>{{#invoke:Time|prettyPrintTime|{{{1}}}|hms=true}}</includeonly></onlyinclude>
Definition of variables-->{{#vardefine:Time|{{formatnum:{{{1|}}}|R}}}}{{#vardefine:Days|{{#expr:floor({{#var:Time}} / 86400)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} mod 86400}}}}{{#vardefine:Hours|{{#expr:floor({{#var:Time}} / 3600)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} mod 3600}}}}{{#vardefine:Minutes|{{#expr:floor({{#var:Time}} / 60)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} mod 60}}}}{{#vardefine:Seconds|{{#var:Time}}}}<!--
Output of template into x day(s), hh:mm:ss-->
{{#ifexpr:{{#var:Days}} > 0|{{#var:Days}} day{{#ifexpr:{{#var:Days}}<>1|s}},&ensp;}}{{#ifexpr:{{#var:Hours}} < 10|0{{#var:Hours}}|{{#var:Hours}}}}:{{#ifexpr:{{#var:Minutes}} < 10|0{{#var:Minutes}}|{{#var:Minutes}}}}:{{#ifexpr:{{#var:Seconds}} < 10|0{{#var:Seconds}}|{{#var:Seconds}}}}</includeonly></onlyinclude><noinclude>{{/doc}}</noinclude>

Revision as of 20:31, 1 April 2024

Takes in a number of seconds and converts it into "X days, H:M:S" For example, {{TimeHMS|90135}} becomes 1 day, 01:02:15. This is the shorthand notation variant for Template:Time. Takes in a number of seconds and converts it into "X days, H:M:S" For example, {{TimeHMS|90135}} becomes 1 day, 01:02:15. This is the shorthand notation variant for Template:Time.