Template:Mi to Km: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Drew R. Smith
No edit summary
imported>Drew R. Smith
No edit summary
Line 1: Line 1:
<includeonly>{{#ifexpr:({{#if:{{{1|}}}|1|0}} OR {{#if:{{{num|}}}|1|0}} OR {{#if:{{{l|}}}|1|0}} OR {{#if:{{{from|}}}|1|0}})|{{#ifexpr:({{#if:{{{2|}}}|1|0}} OR {{#if:{{{w|}}}|1|0}} OR {{#if:{{{to|}}}|1|0}})|{{#ifeq:{{LC:{{{convtype|dim}}}}}|range|{{{{#ifexpr:({{#if:{{{3|}}}|1|0}} OR {{#if:{{{h|}}}|1|0}})|color|x0}}|red|Range conversion is not possible when three numeric parameters are specified!}}{{{{#ifexpr:(NOT({{#if:{{{3|}}}|1|0}} OR {{#if:{{{h|}}}|1|0}}))|Mi to Km range|x0}}|{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}|{{{2|{{{w|{{{to}}}}}}}}}|abbr={{{abbr|mos}}}|spell={{{spell|american}}}|wiki={{{wiki|no}}}|precision={{{precision|-999}}}}}|{{{{#ifexpr:({{#if:{{{3|}}}|1|0}} OR {{#if:{{{h|}}}|1|0}})|Mi to Km 3D|Mi to Km 2D}}|{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}|{{{2|{{{w|{{{to}}}}}}}}}|{{{3|{{{h}}}}}}|abbr={{{abbr|mos}}}|spell={{{spell|american}}}|wiki={{{wiki|no}}}|precision={{{precision|-999}}}}}}}|{{#ifeq:{{LC:{{{convtype|dim}}}}}|range|{{color|red|Two numeric parameters are required for range conversions!}}|{{FORMATNUM:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}}}&nbsp;{{#ifeq:{{LC:{{{abbr|mos}}}}}|yes|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[inch|in]]|in}}|{{#ifeq:{{FORMATNUM:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}}}|1|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[mile]]|mile}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[mile]]s|miles}}}}}} ({{FORMATNUM:{{#expr:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}/ 2.589988110336 round {{#if:{{{precision|}}}|{{{precision}}}|{{#ifexpr:({{#expr:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}/ 2.589988110336}}<10)|1|0}}}}}}}}&nbsp;{{#ifeq:{{LC:{{{abbr|mos}}}}}|no|{{#ifexpr:({{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}/ 2.589988110336 round {{#if:{{{precision|}}}|{{{precision}}}|{{#ifexpr:({{#expr:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}/ 2.589988110336}}<10)|1|0}}}}=1)|{{#ifeq:{{LC:{{{spell|american}}}}}|commonwealth|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kilometre]]|kilometre}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kilometre|kiloimeter]]|kiloimeter}}}}|{{#ifeq:{{LC:{{{spell|american}}}}}|commonwealth|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kiloimetre]]s|kilometres}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kilometre|kilometers]]|kilometers}}}}}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kiloimetre|km]]|km}}}})}}}}|{{color|red|At least one numeric parameter is required!}}}}</includeonly><noinclude>
<includeonly>{{#ifexpr:({{#if:{{{1|}}}|1|0}} OR {{#if:{{{num|}}}|1|0}} OR {{#if:{{{l|}}}|1|0}} OR {{#if:{{{from|}}}|1|0}})|{{#ifexpr:({{#if:{{{2|}}}|1|0}} OR {{#if:{{{w|}}}|1|0}} OR {{#if:{{{to|}}}|1|0}})|{{#ifeq:{{LC:{{{convtype|dim}}}}}|range|{{{{#ifexpr:({{#if:{{{3|}}}|1|0}} OR {{#if:{{{h|}}}|1|0}})|color|x0}}|red|Range conversion is not possible when three numeric parameters are specified!}}{{{{#ifexpr:(NOT({{#if:{{{3|}}}|1|0}} OR {{#if:{{{h|}}}|1|0}}))|Mi to Km range|x0}}|{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}|{{{2|{{{w|{{{to}}}}}}}}}|abbr={{{abbr|mos}}}|spell={{{spell|american}}}|wiki={{{wiki|no}}}|precision={{{precision|-999}}}}}|{{{{#ifexpr:({{#if:{{{3|}}}|1|0}} OR {{#if:{{{h|}}}|1|0}})|Mi to Km 3D|Mi to Km 2D}}|{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}|{{{2|{{{w|{{{to}}}}}}}}}|{{{3|{{{h}}}}}}|abbr={{{abbr|mos}}}|spell={{{spell|american}}}|wiki={{{wiki|no}}}|precision={{{precision|-999}}}}}}}|{{#ifeq:{{LC:{{{convtype|dim}}}}}|range|{{color|red|Two numeric parameters are required for range conversions!}}|{{FORMATNUM:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}}}&nbsp;{{#ifeq:{{LC:{{{abbr|mos}}}}}|yes|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[mile|Mi]]|Mi}}|{{#ifeq:{{FORMATNUM:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}}}|1|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[mile]]|mile}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[mile]]s|miles}}}}}} ({{FORMATNUM:{{#expr:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}*1.609344 round {{#if:{{{precision|}}}|{{{precision}}}|{{#ifexpr:({{#expr:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}*1.609344}}<10)|1|0}}}}}}}}&nbsp;{{#ifeq:{{LC:{{{abbr|mos}}}}}|no|{{#ifexpr:({{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}*1.609344 round {{#if:{{{precision|}}}|{{{precision}}}|{{#ifexpr:({{#expr:{{{1|{{{num|{{{l|{{{from}}}}}}}}}}}}*1.609344}}<10)|1|0}}}}=1)|{{#ifeq:{{LC:{{{spell|american}}}}}|commonwealth|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kilometre]]|kilometre}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kilometre|kiloimeter]]|kiloimeter}}}}|{{#ifeq:{{LC:{{{spell|american}}}}}|commonwealth|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kiloimetre]]s|kilometres}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kilometre|kilometers]]|kilometers}}}}}}|{{#ifeq:{{LC:{{{wiki|no}}}}}|yes|[[kiloimetre|km]]|km}}}})}}}}|{{color|red|At least one numeric parameter is required!}}}}</includeonly><noinclude>
{{TlDoc|complex}}
{{TlDoc|complex}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
</noinclude>
</noinclude>

Revision as of 22:17, 14 June 2009

This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup and parser functions before editing the template.
If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages.
Remember that you can and should conduct experiments and test improvements in your user space before changing anything here.
This documentation is transcluded from Template:Mi to Km/doc (edit | history)


This template is intended to perform Mile-to-Kilometer conversions. It converts single values, ranges, as well as two- and three-dimensional measurements.

Accepted parameters

Italicized parameters are optional:

  • num, or l (length), or from, or first unnamed parameter is a required parameter, which specifies the number of miles to be converted to kilometers (for single value conversions), or length (for two- and three-dimensional conversions), or start of range (for range conversions). Please do not format this parameter; i.e., use 1234 instead of 1,234.
  • w (width), or to, or second unnamed parameter is a parameter specifying width (for dimensional conversions) or end of range (for range conversions) in miles to be converted to kilometers. Please do not format this parameter; i.e., use 1234 instead of 1,234.
  • h (height) or third unnamed parameter is a parameter specifying height (for three-dimensional conversions) in miles to be converted to kilometers. Please do not format this parameter; i.e., use 1234 instead of 1,234.
  • convtype (conversion type) can take values of either range or dim. Range is only meaningful when two values are supplied for conversion. The default value is dim.
  • abbr can take values of either mos, yes, or no. Mos will show the names of the units as (miles, Km); yes will show the abbreviated names of the units (Mi, Km); and no will show the full names of the units (miles, kilometers). With dimensional conversions, all values will be separated with the "by" preposition when the parameter is set to no, and with the "×" sign when the parameter is set to yes. When the parameter is set to mos, mile values will be separated with the "by" preposition, and the converted values in kilometers—with the "×" sign. The default value is mos.
  • spell can take values of American or Commonwealth and is only meaningful when abbr is set to no. American will use "kilometers", and Commonwealth—"kilometres". The default value is American.
  • precision is the number of decimal digits in the converted value. The default value is 0 for converted values equal or more than 10 and 1 for converted values of less than 10.
  • wiki specifies whether the names of the units should be wikified or not and can take values of either yes or no. The default value is no.

Capitalization of the parameters is unimportant.

Usage and examples

Single value conversion

Usage
{{Mi to Km | num | abbr | spell | precision | wiki}}
Examples
{{Mi to Km|1}} → 1 mile (1.6 km)
Short notation: {{Mi to Km|1|abbr=yes}} → 1 Mi (1.6 km)
Full notation: {{Mi to Km|num=1|abbr=no|spell=Commonwealth|precision=2|wiki=yes}} → 1 mile (1.61 kiloimetres)

Range conversions

Usage
{{Mi to Km | from | to | convtype | abbr | spell | precision | wiki}}
Examples
{{Mi to Km|10|20|convtype=range}} → 10–20 miles (16–32 km)
Short notation: {{Mi to Km|10|20|convtype=range|abbr=yes}} → 10–20 mi (16–32 km)
Full notation: {{Mi to Km|from=10|to=20|convtype=range|abbr=no|spell=Commonwealth|precision=1|wiki=yes}} → 10–20 miles (16.1–32.2 kilometres)

Two-dimensional conversions

Usage
{{Mi to Km | l | w | convtype | abbr | spell | precision | wiki}}
Examples
{{Mi to Km|10|20}} → 10 miles by 20 miles (16 km × 32 km)
Short notation: {{Mi to Km|10|20|abbr=yes}} → 10 mi × 20 mi (16 km × 32 km)
Full notation: {{Mi to Km|l=10|w=20|convtype=dim|abbr=no|spell=Commonwealth|precision=1|wiki=yes}} → 10 miles by 20 miles (16.1 kilometres by 32.2 kilometres)

Three-dimensional conversions

Usage
{{Mi to Km | l | w | h | convtype | abbr | spell | precision | wiki}}
Examples
{{Mi to Km|1|2|3}} → 1 mile by 2 miles by 3 miles (2.5 km × 5.1 km × 7.6 km)
Short notation: {{Mi to Km|1|2|3|abbr=yes}} → 1 mi × 2 mi × 3 mi (2.5 km × 5.1 km × 7.6 km)
Full notation: {{Mi to Km|l=1|w=2|h=3|convtype=dim|abbr=no|spell=Commonwealth|precision=2|wiki=yes}} → 1 mile by 2 miles by 3 miles (2.54 kilometres by 5.08 kilometres by 7.62 kilometres)

</noinclude>

See also