Template:Duration/doc

From Terraria Mods Wiki
Jump to navigation Jump to search

Format a time value, input in seconds.

Usage

{{ duration | <time in seconds> | <maximum unit> | round = <rounding level> }}

First unnamed parameter

Number, time in seconds. Any valid {{#expr:}} string is accepted.

Second unnamed parameter

Greatest unit of the output. Can be any of seconds, minutes (default), hours, days, and weeks, or s, m, h, d, and w for short, respectively.

round

Rounding level for decimal seconds, 2 by default.

Examples

Code Result
{{duration|41}} 41 seconds
{{duration|40.75}} 40.75 seconds
{{duration|90}} 1 minute 30 seconds
{{duration|1800}} 30 minutes
{{duration|7201}} 120 minutes 1 second
{{duration|604800}} 10,080 minutes
{{duration|604800|weeks}} 1 week
{{duration|7201|weeks}} 2 hours 1 second
{{duration|604800|d}} 7 days
{{duration|7201|w}} 2 hours 1 second
{{duration|1/3}} 0.33 seconds
{{duration|1/3|round=6}} 0.333333 seconds
{{duration|(35/11 mod 2) - (10^-2 / pi*3) + ceil(21/6)}} 4.99 seconds
{{duration|{{#time:U|+3 days 2 hours 44 minutes 23 seconds}}-{{#time:U}}|days}} 3 days 2 hours 44 minutes 24 seconds
{{duration|{{#time:U|+2 days 37 hours 98 minutes 63 seconds}}-{{#time:U}}|hours}} 86 hours 39 minutes 4 seconds
{{duration|-41}} −41 seconds
{{duration|-3601|days}} −1 hour 1 second
{{duration|0}} 0 seconds
{{duration|0.001}} 0 seconds
{{duration|-0.001}} −0 seconds
{{duration|0.001|round=5}} 0.001 second