Anonymous

Template:Time: Difference between revisions

From Melvor Idle
No change in size ,  12 January 2021
Make text and example match
(Created new Time template)
 
(Make text and example match)
Line 1: Line 1:
Takes in a number of seconds and converts it into "X days, X hours, X minutes, X seconds"
Takes in a number of seconds and converts it into "X days, X hours, X minutes, X seconds"
For example, {{T|Time|90000}} becomes {{Time|90135}}
For example, {{T|Time|90135}} becomes {{Time|90135}}
<onlyinclude><includeonly>{{#vardefine:Time|{{formatnum:{{{1|}}}|R}}}}{{#vardefine:Days|{{#expr:floor({{#var:Time}} / 86400)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} - {{#var:Days}} * 86400}}}}{{#vardefine:Hours|{{#expr:floor({{#var:Time}} / 3600)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} - {{#var:Hours}} * 3600}}}}{{#vardefine:Minutes|{{#expr:floor({{#var:Time}} / 60)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} - {{#var:Minutes}} * 60}}}}{{#vardefine:Seconds|{{#var:Time}}}}<!--
<onlyinclude><includeonly>{{#vardefine:Time|{{formatnum:{{{1|}}}|R}}}}{{#vardefine:Days|{{#expr:floor({{#var:Time}} / 86400)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} - {{#var:Days}} * 86400}}}}{{#vardefine:Hours|{{#expr:floor({{#var:Time}} / 3600)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} - {{#var:Hours}} * 3600}}}}{{#vardefine:Minutes|{{#expr:floor({{#var:Time}} / 60)}}}}{{#vardefine:Time|{{#expr:{{#var:Time}} - {{#var:Minutes}} * 60}}}}{{#vardefine:Seconds|{{#var:Time}}}}<!--
-->{{#ifexpr:{{#var:Days}} > 0|{{#var:Days}} day{{#ifexpr:{{#var:Days}}<>1|s}},&ensp;}}{{#ifexpr:{{#var:Hours}} > 0|{{#var:Hours}} hour{{#ifexpr:{{#var:Hours}}<>1|s}},&ensp;}}{{#ifexpr:{{#var:Minutes}} > 0|{{#var:Minutes}} minute{{#ifexpr:{{#var:Minutes}}<>1|s}},&ensp;}}{{#var:Seconds}} second{{#ifexpr:{{#var:Seconds}}<>1|s}}</includeonly></onlyinclude>
-->{{#ifexpr:{{#var:Days}} > 0|{{#var:Days}} day{{#ifexpr:{{#var:Days}}<>1|s}},&ensp;}}{{#ifexpr:{{#var:Hours}} > 0|{{#var:Hours}} hour{{#ifexpr:{{#var:Hours}}<>1|s}},&ensp;}}{{#ifexpr:{{#var:Minutes}} > 0|{{#var:Minutes}} minute{{#ifexpr:{{#var:Minutes}}<>1|s}},&ensp;}}{{#var:Seconds}} second{{#ifexpr:{{#var:Seconds}}<>1|s}}</includeonly></onlyinclude>
285

edits