ARK: Survival Evolved Wiki
Danlev (discusión | contribuciones)
(Updating duration template to make it more readable. One other editor agreed, but if anyone else thinks the previous one was better, feel free to comment on the discuss page)
 
Will130 (discusión | contribuciones)
m
 
(No se muestran 6 ediciones intermedias de 3 usuarios)
Línea 1: Línea 1:
  +
<includeonly>{{#vardefine:input|{{{1|}}}}}<!--
<includeonly>{{#vardefine:input|{{{1|}}}}}{{#vardefine:time|{{#var:input}}}}{{#vardefine:days|{{#expr:({{#var:time}} - {{#var:time}} mod 86400) / 86400}}}}{{#vardefine:time|{{#expr:{{#var:time}} - {{#var:days}} * 86400}}}}{{#vardefine:hours|{{#expr:({{#var:time}} - {{#var:time}} mod 3600) / 3600}}}}{{#vardefine:time|{{#expr:{{#var:time}} - {{#var:hours}} * 3600}}}}{{#vardefine:minutes|{{#expr:({{#var:time}} - {{#var:time}} mod 60) / 60}}}}{{#vardefine:seconds|{{#expr:{{#var:time}} - {{#var:minutes}} * 60}}}}{{#ifexpr: {{#var:input}} >= 86400 | {{#var:days}}d }} {{#ifexpr: {{#var:input}} >= 3600 | {{#ifexpr: {{#var:hours}} > 0 | {{#var:hours}}h | }} }} {{#ifexpr: {{#var:input}} >= 60 | {{#ifexpr: {{#var:minutes}} > 0 | {{#var:minutes}}m | }} }} {{#ifexpr: {{#var:seconds}} < 60 | {{#ifexpr: {{#var:seconds}} > 0 | {{#var:seconds}}s | }} | }}</includeonly><noinclude>
 
  +
-->{{#vardefine:time|{{#var:input}}}}<!--
== Documentation ==
 
  +
-->{{#vardefine:days|{{#expr:floor({{#var:time}} / 86400)}}}}<!--
Formats a duration given in seconds.
 
  +
-->{{#vardefine:hourstotal|{{#expr:floor({{#var:time}} / 3600)}}}}<!--
  +
-->{{#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:seconds|{{#expr:{{#var:time}} - {{#var:minutes}} * 60 round 3}}}}<!--
   
  +
-->{{#if:{{{2|}}}|<!-- with second parameter, i.e. dd:hh:mm:ss
===Usage===
 
  +
-->{{#ifeq:{{{2|}}}|hhmm|<!-- with specific second parameter hhmm
<nowiki>{{duration|s}}</nowiki>
 
  +
-->{{#ifexpr: {{#var:input}} >= 3600 | {{#var:hourstotal}}: }}<!--
===Examples===
 
  +
-->{{#ifexpr: {{#var:input}} >= 60 | {{#ifexpr: {{#var:input}} < 3600 | {{#var:minutes}} | {{padleft:{{#var:minutes}}|2|0}} }} }}
* <code><nowiki>{{duration|20}}</nowiki></code> creates {{duration|20}}
 
  +
|{{#ifeq:{{{2|}}}|ddhhmm|<!-- with specific second parameter ddhhmm
* <code><nowiki>{{duration|140}}</nowiki></code> creates {{duration|140}}
 
  +
-->{{#ifexpr: {{#var:input}} >= 86400 | {{#var:days}}d }} <!--
* <code><nowiki>{{duration|86406}}</nowiki></code> creates {{duration|86406}}
 
  +
-->{{#ifexpr: {{#var:input}} >= 3600 | {{#ifexpr: {{#var:input}} < 86400 | {{#var:hours}}: | {{padleft:{{#var:hours}}|2|0}}: }} | 0: }}<!--
  +
-->{{#ifexpr: {{#var:input}} >= 60 | {{#ifexpr: {{#var:input}} < 3600 | {{#var:minutes}} | {{padleft:{{#var:minutes}}|2|0}} }} }}
  +
|<!-- with non-specific second parameter, i.e. f
  +
-->{{#ifexpr: {{#var:input}} >= 86400 | {{#var:days}}: }}<!--
  +
-->{{#ifexpr: {{#var:input}} >= 3600 | {{#ifexpr: {{#var:input}} < 86400 | {{#var:hours}}: | {{padleft:{{#var:hours}}|2|0}}: }} }}<!--
  +
-->{{#ifexpr: {{#var:input}} >= 60 | {{#ifexpr: {{#var:input}} < 3600 | {{#var:minutes}}: | {{padleft:{{#var:minutes}}|2|0}}: }} }}<!--
  +
-->{{#ifexpr: {{#var:input}} < 60 | {{#var:seconds}} | {{padleft:{{#var:seconds}}|2|0}} }}
  +
}}}}|<!-- without second parameter, i.e. like 1d 2h 3m 4s
  +
-->{{#ifexpr: {{#var:input}} >= 86400 | {{#var:days}}d }} <!--
  +
-->{{#ifexpr: {{#var:input}} >= 3600 | {{#ifexpr: {{#var:hours}} > 0 | {{#var:hours}}h | }} }} <!--
  +
-->{{#ifexpr: {{#var:input}} >= 60 | {{#ifexpr: {{#var:minutes}} > 0 | {{#var:minutes}}m | }} }} <!--
  +
-->{{#ifexpr: {{#var:seconds}} > 0 | {{#var:seconds}}s | }}
  +
}}</includeonly><noinclude>{{doc}}
  +
[[Category:Plantillas de formato]]
   
  +
[[de:Vorlage:Duration]]
[[Category:Formatting templates]]</noinclude>
 
  +
[[en:Template:Duration]]
  +
[[fr:Modèle:Duration]]
  +
[[it:Template:Duration]]
  +
[[ja:テンプレート:Duration]]
  +
[[pl:Szablon:Duration]]
  +
[[pt-br:Predefinição:Duration]]
  +
[[ru:Шаблон:Duration]]
  +
[[th:แม่แบบ:Duration]]
  +
</noinclude>

Revisión actual del 13:32 5 jul 2021

Template-info.png Documentación

Formats a duration given in seconds.

Usage

{{duration|s}}

Examples

  • {{duration|20}} creates 20s
  • {{duration|140}} creates 2m 20s
  • {{duration|86406}} creates 1d 6s