More actions
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
{{Lua|Module:Duration}} | {{Lua|Module:Duration}} | ||
This template emits the hAudio | This template emits the hAudio microformat. | ||
== Usage == | == Usage == | ||
| Line 12: | Line 12: | ||
=== Unformatted input === | === Unformatted input === | ||
An unformatted duration can be input in the first parameter: <code>{{((}}Duration{{!}}10:20:30{{))}}</code> (hours:minutes:seconds) or <code> | An unformatted duration can be input in the first parameter: <code>{{((}}Duration{{!}}10:20:30{{))}}</code> (hours:minutes:seconds) or <code>Duration{{!}}20:30</code> (minutes:seconds). There ''must'' be a seconds value, as inputs in hours and minutes are indistinguishable from inputs in minutes and seconds. | ||
=== Numbered parameters === | === Numbered parameters === | ||
| Line 18: | Line 18: | ||
<syntaxhighlight lang="wikitext">{{Duration|10|20|30}}</syntaxhighlight> | <syntaxhighlight lang="wikitext">{{Duration|10|20|30}}</syntaxhighlight> | ||
where parameters are hours, minutes and seconds respectively. If the hours or minutes values are zero, then leave them blank (e.g. <code> | where parameters are hours, minutes and seconds respectively. If the hours or minutes values are zero, then leave them blank (e.g. <code>Duration{{!}}{{!}}20{{!}}30</code>). Minutes and seconds values default to zero, although they should ideally be specified. | ||
=== h, m and s parameters === | === h, m and s parameters === | ||
Revision as of 17:42, 8 April 2025
| This page uses Creative Commons Licensed content from Wikipedia (view authors). |
| This is a documentation subpage for Template:Duration It may contain usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
This template emits the hAudio microformat.
Usage
Unformatted input
An unformatted duration can be input in the first parameter: Template:((Duration|10:20:30Template:)) (hours:minutes:seconds) or Duration|20:30 (minutes:seconds). There must be a seconds value, as inputs in hours and minutes are indistinguishable from inputs in minutes and seconds.
Numbered parameters
{{Duration|10|20|30}}where parameters are hours, minutes and seconds respectively. If the hours or minutes values are zero, then leave them blank (e.g. Duration||20|30). Minutes and seconds values default to zero, although they should ideally be specified.
h, m and s parameters
{{Duration|h=10|m=20|s=30}}where h, m and s are hours, minutes and seconds respectively. Minutes and seconds values default to zero, although they should ideally be specified.
Parent templates
This template can be used in:
- {{Infobox album}}
- {{Infobox song}}
In {{Infobox album}}, the microformat is added automatically if there is not one already. However, more complicated values might require this template.
Examples
Unformatted input
{{Duration|1:22:34}}renders as: 1:22:34{{Duration|74:32}}renders as: 74:32{{Duration|1:02:34}}renders as: 1:02:34{{Duration|1:2:3}}renders as: 1:02:03{{Duration|0:22:34}}renders as: 0:22:34{{Duration|0:0:34}}renders as: 0:00:34{{Duration|0:34}}renders as: 0:34
h, m and s parameters
{{Duration|h=1|m=22|s=34}}renders as: 1:22:34{{Duration|m=74|s=32}}renders as: 74:32{{Duration|m=2|s=34}}renders as: 2:34{{Duration|h=1|s=34}}renders as: 1:00:34{{Duration|h=1}}renders as: 1:00:00{{Duration|h=0|m=22|s=34}}renders as: 0:22:34{{Duration|h=0|m=0|s=34}}renders as: 0:00:34{{Duration|h=1|m=22|s=34.5678}}renders as: 1:22:34.5678{{Duration|h=1|m=22|s=3}}renders as: 1:22:03{{Duration|h=1|m=2|s=34}}renders as: 1:02:34{{Duration|h=1|m=2|s=3}}renders as: 1:02:03{{Duration|h=1|m=2}}renders as: 1:02:00{{Duration|s=34}}renders as: 0:34{{Duration|m=0|s=34}}renders as: 0:34{{Duration|h=1|m=0|s=34}}renders as: 1:00:34{{Duration|h=1|m=22|s=0}}renders as: 1:22:00
{{Duration|h=one|m=22|s=0}}renders as: Error in Module:Duration: Invalid values
{{Duration|h=1|m=22|s=78}}renders as: Error in Module:Duration: Seconds value must be less than 60
{{Duration|h=1.1|m=2.2}}renders as: Error in Module:Duration: Hours and minutes values must be integers
Numbered parameters
{{Duration|1|22|34}}renders as: 1:22:34{{Duration||74|32}}renders as: 74:32{{Duration|1|2|34}}renders as: 1:02:34{{Duration|1|2|3}}renders as: 1:02:03{{Duration|0|22|34}}renders as: 0:22:34{{Duration|0|0|34}}renders as: 0:00:34{{Duration||0|34}}renders as: 0:34{{Duration|||34}}renders as: 0:34{{Duration|1|22|34.5678}}renders as: 1:22:34.5678{{Duration||1|22}}renders as: 1:22{{Duration|1|22}}renders as: 1:22:00{{Duration|1|22|0}}renders as: 1:22:00
{{Duration|1|22|}}renders as: 1:22:00{{Duration|0|0|0}}renders as: (blank){{Duration|||}}renders as: (blank)
{{Duration|1|22|34|55}}renders as: Error in Module:Duration: Parameter number 4 should not be specified
{{Duration|one|22|0}}renders as: Error in Module:Duration: Invalid values
{{Duration|1|22|78}}renders as: Error in Module:Duration: Seconds value must be less than 60
{{Duration|1.1|2.2}}renders as: Error in Module:Duration: Hours and minutes values must be integers
Microformat
TemplateData
For use in templates emitting the hAudio [[microformat]]
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Hours | h 1 | no description
| Number | suggested |
| Minutes | m 2 | no description
| Number | suggested |
| Seconds | s 3 | no description
| Number | suggested |