• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

Template:Duration/sandbox

  • Template
  • Talk
  • Language
  • Watch
  • Edit
< Template:Duration
This is the template sandbox page for Template:Duration (diff).
See also the companion subpage for test cases.
Template documentation[view] [edit] [history] [purge]
WarningThis template is used on approximately 42,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.
This template uses Lua:
  • Module:Duration (sandbox)

This template emits the hAudio microformat.

Contents

  • 1 Usage
    • 1.1 Unformatted input
    • 1.2 Numbered parameters
    • 1.3 h, m and s parameters
    • 1.4 Parent templates
  • 2 Examples
    • 2.1 Unformatted input
    • 2.2 h, m and s parameters
    • 2.3 Numbered parameters
  • 3 Microformat
  • 4 TemplateData

Usage

edit

Unformatted input

edit

An unformatted duration can be input in the first parameter: {{Duration|10:20:30}} (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

edit
{{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

edit
{{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

edit

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

edit

Unformatted input

edit
  • {{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

edit
  • {{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
  • Red XN {{Duration|h=one|m=22|s=0}} renders as: Error in Module:Duration: Invalid values
  • Red XN {{Duration|h=1|m=22|s=78}} renders as: Error in Module:Duration: Seconds value must be less than 60
  • Red XN {{Duration|h=1.1|m=2.2}} renders as: Error in Module:Duration: Hours and minutes values must be integers

Numbered parameters

edit
  • {{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
  • Red XN {{Duration|1|22|}} renders as: 1:22:00
  • {{Duration|0|0|0}} renders as: (blank)
  • {{Duration|||}} renders as: (blank)
  • Red XN {{Duration|1|22|34|55}} renders as: Error in Module:Duration: Parameter number 4 should not be specified
  • Red XN {{Duration|one|22|0}} renders as: Error in Module:Duration: Invalid values
  • Red XN {{Duration|1|22|78}} renders as: Error in Module:Duration: Seconds value must be less than 60
  • Red XN {{Duration|1.1|2.2}} renders as: Error in Module:Duration: Hours and minutes values must be integers

Microformat

edit
The HTML mark-up produced by this template includes HTML classes intended to be part of an hAudio microformat that makes an audio recording's details readily parsable by computer programs. This aids tasks such as the cataloguing of articles and maintenance of databases. For more information about the use of microformats on Wikipedia, please visit the Microformat WikiProject.
Classes used

The HTML classes of this microformat include:

  • fn
  • album
  • description
  • category
  • contributor
  • duration
  • h
  • item
  • min
  • photo
  • position
  • price
  • published
  • s
Please do not rename or remove these classes
nor collapse nested elements which use them.

TemplateData

edit
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Duration in articles based on its TemplateData.

TemplateData for Duration

For use in templates emitting the hAudio [[microformat]]

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Hoursh 1

no description

Example
3
Numbersuggested
Minutesm 2

no description

Example
32
Numbersuggested
Secondss 3

no description

Example
42
Numbersuggested
The above documentation is transcluded from Template:Duration/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Duration/sandbox&oldid=973753428"
Last edited on 19 August 2020, at 01:43

Languages

      This page is not available in other languages.

      Wikipedia
      • Wikimedia Foundation
      • Powered by MediaWiki
      • This page was last edited on 19 August 2020, at 01:43 (UTC).
      • Content is available under CC BY-SA 4.0 unless otherwise noted.
      • Privacy policy
      • About Wikipedia
      • Disclaimers
      • Contact Wikipedia
      • Code of Conduct
      • Developers
      • Statistics
      • Cookie statement
      • Terms of Use
      • Desktop