Template:display time
From Homestar Runner Wiki
(Difference between revisions)
(add logic to default zero-count averages to zero, to avoid division by zero) |
|||
Line 2: | Line 2: | ||
-->|total|#default={{format seconds|{{#expr: {{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}} }}}}<!-- /* Total in hh:mm:ss */ | -->|total|#default={{format seconds|{{#expr: {{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}} }}}}<!-- /* Total in hh:mm:ss */ | ||
-->|seconds={{#expr: {{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}} }}<!-- /* Total in seconds */ | -->|seconds={{#expr: {{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}} }}<!-- /* Total in seconds */ | ||
- | -->|average={{format seconds|{{#expr: ( ({{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}}) / ({{#count:{{{1}}}_count|0}} + {{{offset_count|0}}}) ) round 0}}}} <!-- /* Average in hh:mm:ss */ | + | -->|average={{format seconds|{{#ifexpr:({{#count:{{{1}}}_count|0}} + {{{offset_count|0}}}) ) round 0}}>0|{{#expr: ( ({{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}}) / ({{#count:{{{1}}}_count|0}} + {{{offset_count|0}}}) ) round 0}}|0}}}} <!-- /* Average in hh:mm:ss */ |
- | -->|average_seconds={{#expr: ( ({{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}}) / ({{#count:{{{1}}}_count|0}} + {{{offset_count|0}}}) ) round 0}} <!-- /* Average in hh:mm:ss */ | + | -->|average_seconds={{#ifexpr:({{#count:{{{1}}}_count|0}} + {{{offset_count|0}}}) ) round 0}}>0|{{#expr: ( ({{#count:{{{1}}}_tally|0}} + {{{offset_seconds|0}}}) / ({{#count:{{{1}}}_count|0}} + {{{offset_count|0}}}) ) round 0}}|0}} <!-- /* Average in hh:mm:ss */ |
-->|count={{#expr: {{#count:{{{1}}}_count|0}} + {{{offset_count|0}}} }} <!-- /* Total Number of entries */ | -->|count={{#expr: {{#count:{{{1}}}_count|0}} + {{{offset_count|0}}} }} <!-- /* Total Number of entries */ | ||
-->}}<!-- /* End Switch */ | -->}}<!-- /* End Switch */ | ||
Line 10: | Line 10: | ||
'''Usage:''' | '''Usage:''' | ||
- | :<code><nowiki>{{ </nowiki> display time | ''countername'' [| ''display_type''] [| offset_seconds = ''seconds''] [| offset_count = ''count'']}}</code> | + | :<code><nowiki>{{ </nowiki> display time | ''countername'' [| ''display_type''] [| offset_seconds = ''seconds''] [| offset_count = ''count'']}}</code> |
* where ''countername'' is the name of the counter being used. '''''This parameter is required.''''' | * where ''countername'' is the name of the counter being used. '''''This parameter is required.''''' | ||
* and ''display_type'' is the type of information to be displayed. Optional. Valid values are: | * and ''display_type'' is the type of information to be displayed. Optional. Valid values are: |
Revision as of 14:12, 19 April 2025
0:00 |average_seconds=Expression error: Unexpected closing bracket>0|Division by zero|0}} |count=0 }} This template is used for displaying tally totals in a group of toons.
Usage:
{{ display time | countername [| display_type] [| offset_seconds = seconds] [| offset_count = count]}}
- where countername is the name of the counter being used. This parameter is required.
- and display_type is the type of information to be displayed. Optional. Valid values are:
-
total
— Default. Displays the total number of tallied seconds in hh:mm:ss format. -
seconds
— Displays the total number of tallied seconds. -
average
— Displays the average time per toon in hh:mm:ss format. -
average_seconds
— Displays the average time per toon in seconds. -
count
— Displays the total number of entries.
-
- The (Optional) parameter
offset_seconds =
temporarily offsets the total number of seconds by the seconds value passed to this parameter. The total itself remains unaffected; only the calculated display values are affected. This value defaults to zero(0) when the parameter is not defined. - The (Optional) parameter
offset_count =
temporarily offsets the total count of toons by the count value passed to this parameter. The total itself remains unaffected; only the calculated display values are affected. This value defaults to zero(0) when the parameter is not defined.
- See {{tally time}} for usage examples.