Difference between revisions of "Template:Hands/sandbox"
imported>DePiep |
imported>Mr. Stradivarius (sync - new code was causing script errors) |
||
| Line 1: | Line 1: | ||
| − | {{{{{ | + | <!-- |
| − | |1 | + | -============================================================= |
| − | |2={{#if:{{{ | + | - Template:Hands - Shows hands units as also inches & cm |
| − | | | + | -============================================================= |
| − | |4={{#if:{{{ | + | -- (see NOTES at bottom) |
| − | | | + | -->{{#if: {{{3|}}}<!-- |
| − | + | ------------------------------------------------------- Range | |
| − | | | + | --then-show-range-->|{{{1|1}}}{{ |
| − | + | #switch:{{{2|to}}} | |
| − | }}<noinclude> | + | | -|–|– = – |
| − | + | | , = , <b/> | |
| − | : | + | | #default = <b/> {{{2|to}}} <b/> |
| − | : | + | }}{{{3|3}}} {{#ifeq:{{{lk|on}}}|off<!-- |
| − | + | --then-unlink-->|{{ | |
| − | {documentation}} | + | #ifeq:{{{abbr|off}}}|off|hands|{{ |
| + | #ifeq:{{{abbr|h}}}|hh|hh|h}} }}<!-- | ||
| + | --else-linked-->|[[Hand (length)|{{ | ||
| + | #ifeq:{{{abbr|off}}}|off|hands|{{ | ||
| + | #ifeq:{{{abbr|h}}}|hh|hh|h}} }}<!-- | ||
| + | -->]]}} ({{#expr:(4*floor {{{1|1}}} + 10*({{{1|1}}}-floor {{{1|1}}})) {{ | ||
| + | #if:{{{r|}}}{{{rinch|}}}| round {{{rinch|{{{r|0}}} }}} }} | ||
| + | }}{{ | ||
| + | #switch:{{{2|to}}} | ||
| + | | -|–|– = – | ||
| + | | , = , <b/> | ||
| + | | #default = <b/> {{{2|to}}} <b/> | ||
| + | }}{{ | ||
| + | #expr:(4*floor {{{3|3}}} + 10*({{{3|3}}}-floor {{{3|3}}})) {{ | ||
| + | #if:{{{r|}}}{{{rinch|}}}| round {{{rinch|{{{r|0}}} }}} }} | ||
| + | }} inches{{ | ||
| + | #ifeq:{{{2|,}}}|,|<b/>;|,}} {{#expr:(2.54*(4*floor {{{1|1}}} + 10*({{{1|1}}}-floor {{{1|1}}})) ) | ||
| + | round {{{rcm|{{{r|0}}} }}} | ||
| + | }}{{ | ||
| + | #switch:{{{2|to}}} | ||
| + | | -|–|– = – | ||
| + | | , = , <b/> | ||
| + | | #default = <b/> {{{2|to}}} <b/> | ||
| + | }}{{ | ||
| + | #expr:(2.54*(4*floor {{{3|3}}} + 10*({{{3|3}}}-floor {{{3|3}}})) ) | ||
| + | round {{{rcm|{{{r|0}}} }}} }} cm)<!-- | ||
| + | ------------------------------------------------------- Single | ||
| + | --else-show-single-amount-->|{{hands/numdisp|{{{1|1.1}}}}} {{#ifeq:{{{lk|on}}}|off<!-- | ||
| + | --then-unlink-->|{{ | ||
| + | #ifeq:{{{abbr|off}}}|off|hands|{{ | ||
| + | #ifeq:{{{abbr|h}}}|hh|hh|h}} }}<!-- | ||
| + | --else-linked-->|[[Hand (unit)|{{ | ||
| + | #ifeq:{{{abbr|off}}}|off|hands|{{ | ||
| + | #ifeq:{{{abbr|h}}}|hh|hh|h}} }}<!-- | ||
| + | -->]]}} {{ | ||
| + | #ifexpr: | ||
| + | {{{1|0*1.1+3/4}}}*0 = 0 <!-- | ||
| + | --then-->|({{#expr:(4*floor {{{1|1}}} + 10*({{{1|1.1}}}-floor {{{1|1.1}}})) {{ | ||
| + | #if:{{{r|}}}{{{rinch|}}}| round {{{rinch|{{{r|1}}} }}} }} | ||
| + | }} inches, {{#expr: (2.54*(4*floor {{{1|1}}} + 10*({{{1|1.1}}}-floor {{{1|1.1}}})) ) | ||
| + | round {{{rcm|{{{r|0}}} }}} | ||
| + | }} cm)<!-- | ||
| + | --else--handle-fraction-->|({{#expr: 4*floor ({{{1|1+3/4}}}*0) + 10*({{{1|1+3/4}}}*0-floor( {{{1|1+3/4}}}*0 ) ) + 0*{{{1|1+3/4}}} {{ | ||
| + | #if:{{{r|}}}{{{rinch|}}}| round {{{rinch|{{{r|1}}} }}} }} | ||
| + | }} inches, {{#expr: 2.54*(4*floor( {{{1|1+3/4}}}*0 ) + 10*({{{1|1+3/4}}}*0-floor( {{{1|1+3/4}}}*0 ) ) + 0*{{{1|1+3/4}}} ) | ||
| + | round {{{rcm|{{{r|0}}} }}} | ||
| + | }} cm)}}<!--endif {1)*0=0 | ||
| + | -->}}<!--endif {3}--><noinclude> | ||
| + | <!-- | ||
| + | -------------------------------------------------------------- | ||
| + | --NOTES | ||
| + | -- | ||
| + | -- NOTE A1: This template converts hands to inches/cm using | ||
| + | -- factors of 4x to get inches, or 2.54x for centimetres. | ||
| + | -- The calculations are in 4 different sections: | ||
| + | -- convert {1} & convert {3} in a range, or else | ||
| + | -- convert {1}, or else convert {1} with fraction. | ||
| + | -- Hence, the rounding of amounts is repeated 4 times, for | ||
| + | -- each of those 4 calculation sections. Due to complexity, | ||
| + | -- a fraction is only allowed for a single, not in ranges. | ||
| + | -- | ||
| + | -------------------------------------------------------------- | ||
| + | --HISTORY: | ||
| + | --11Jan2009 Created to show both inches & cm by default. | ||
| + | --07Jul2011 Put NOTES comments to explain template markup. | ||
| + | --07Jul2011 Put HISTORY to log major changes (not typos). | ||
| + | --07Jul2011 New parameter abbr=on for "h" or abbr=hh for "hh". | ||
| + | --07Jul2011 New parameter r=2 to round inches/cm to 2 decimals. | ||
| + | --07Jul2011 New parameter rinch=2 to round inches to 2 decimals. | ||
| + | --07Jul2011 New parameter rcm=2 to round cm to 2 decimals. | ||
| + | --07Jul2011 For ranges, omits spaces when hyphen/ndash or comma. | ||
| + | -- | ||
| + | --> | ||
| + | {{documentation}} | ||
</noinclude> | </noinclude> | ||
Revision as of 13:42, 16 October 2014
1.1 hands (5 inches, 13 cm)
| This is the template sandbox page for Template:Hands (diff). |
A hand is a unit of length used to measure the height of horses and ponies. One hand is four inches, and a value of '12.3 hands' represents 12 hands + 3 inches (51 inches). This template converts hands into the equivalent heights in inches and centimetres.
Note: with hands, any fractional part (numbers and vulgar fractions after the period) are inches, not a decimal fraction of a hand. Hence '14.2 hands' means 14 hands, 2 inches, not 14Page Template:Screen reader-only/styles.css has no content. 2⁄10 hands.
Usage
Basic usage:
- {{hands|14.2}} → 14.2 hands (58 inches, 147 cm)
The optional parameters include:|abbr=on to show "h" (or |abbr=hh to show "hh"), |r=2 to round inches and cm to 2 decimal places, |rinch=2 to round the inches only, or |rcm=2 to round the centimeters only, |lk=off to unlink the hands unit.
| Input | Output |
|---|---|
| {{hands|14.2}} | 14.2 hands (58 inches, 147 cm) |
| {{hands|14.1+3/4}} | 14.1 3⁄4 hands (57.75 inches, 147 cm) |
| {{hands|15.3|lk=off}} | 15.3 hands (63 inches, 160 cm) |
| {{hands|15.3|abbr=h}} | 15.3 h (63 inches, 160 cm) |
| {{hands|15.3|abbr=hh}} | 15.3 hh (63 inches, 160 cm) |
| {{hands|14.1+1/2}} | 14.1 1⁄2 hands (57.5 inches, 146 cm) |
| {{hands|14.1+1/2|r=0}} | 14.1 1⁄2 hands (58 inches, 146 cm) |
| {{hands|14.1+1/2|r=1}} | 14.1 1⁄2 hands (57.5 inches, 146.1 cm) |
| {{hands|14.1+1/2|r=2}} | 14.1 1⁄2 hands (57.5 inches, 146.05 cm) |
| {{hands|14.1+1/2|rinch=0}} | 14.1 1⁄2 hands (58 inches, 146 cm) |
| {{hands|14.1+1/2|rcm=2}} | 14.1 1⁄2 hands (57.5 inches, 146.05 cm) |
| {{hands|15.1|-|16.3}} | 15.1–16.3 hands (61–67 inches, 155–170 cm) |
| {{hands|14.2|to|16.1}} | 14.2 to 16.1 hands (58 to 65 inches, 147 to 165 cm) |
| {{hands|14.2|any text here|16.1}} | 14.2 any text here 16.1 hands (58 any text here 65 inches, 147 any text here 165 cm) |
If the 'range' format is used, the text in the second parameter (such as "to") can take any text you wish to use, such as 'and', 'to' or –. When the range has a hyphen/dash or comma, then some spaces are omitted.
Hands can also be converted using {{convert}}, for example
- {{convert|15.3|hands}} → 15.3 hands (63 inches; 160 cm); or
- {{convert|15.3|hands|order=flip}} → 63 inches; 160 centimetres (15.3 h)
This could be useful when {{convert}} units or options are needed that are not in {{hands}}, such as the illustrated |order=flip.
Inverse
To convert other measurements into hands, use {{convert}}:
- Convert from cm: {{convert|148|to|152|cm|hand in|2}} → 148 to 152 centimetres (14.2 1⁄2 to 15.0 hands; 58 1⁄2 to 60 in)
- Convert from inches: {{convert|60|to|62|in|hand cm|2}} → 60 to 62 inches (15.0 to 15.2 hands; 152.40 to 157.48 cm)
Using a full three-way conversion (hands, inches and centimeters) in all cases is strongly recommended, regardless of which measurement is given first.
Singular use (not recommended):
- Convert from cm: {{convert|147|cm|hand in|2}} → 147 centimetres (14.2 hands; 58 in)
- Convert from inches: {{convert|60|in|hand cm|1}} → 60 inches (15.0 hands; 152.4 cm)
| The above documentation is transcluded from Template:Hands/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |