User:Johan G/convert: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Undo revision 115775 by Wkitty42 (talk) maybe round is needed now that i see it is working! YAY!)
(Throwing more meaningful error when converting to the same unit)
 
(5 intermediate revisions by 2 users not shown)
Line 4: Line 4:
     -->{{#switch: {{{2|}}}
     -->{{#switch: {{{2|}}}
     | mm = {{#switch: {{{3|}}}
     | mm = {{#switch: {{{3|}}}
       | in = {{#expr: {{{1}}} div 25.4 round {{{4|0}}}}} {{#if: {{{5|}}}||in}}
      | mm = {{error|Conversion to same unit}}
       | ft = {{#expr: {{{1}}} div 304.8 round {{{4|0}}}}} {{#if: {{{5|}}}||ft}}
       | in = {{User:Johan G/convert/rear|{{{1}}} div 25.4|in|{{{4|}}}|{{{5|}}}}}
       | m = {{#expr: {{{1}}} div 1000 round {{{4|0}}}}} {{#if: {{{5|}}}||m}}
       | ft = {{User:Johan G/convert/rear|{{{1}}} div 304.8|ft|{{{4|}}}|{{{5|}}}}}
       | km = {{#expr: {{{1}}} div 1000000 round {{{4|0}}}}} {{#if: {{{5|}}}||km}}
       | m = {{User:Johan G/convert/rear|{{{1}}} div 1000|m|{{{4|}}}|{{{5|}}}}}
       | mi = {{#expr: {{{1}}} div 1609300 round {{{4|0}}}}} {{#if: {{{5|}}}||mi}}
       | km = {{User:Johan G/convert/rear|{{{1}}} div 1000000|km|{{{4|}}}|{{{5|}}}}}
       | NM = {{#expr: {{{1}}} div 1852000 round {{{4|0}}}}} {{#if: {{{5|}}}||NM}}
       | mi = {{User:Johan G/convert/rear|{{{1}}} div 1609300|mi|{{{4|}}}|{{{5|}}}}}
       | NM = {{User:Johan G/convert/rear|{{{1}}} div 1852000|NM|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
     | in = {{#switch: {{{3|}}}
     | in = {{#switch: {{{3|}}}
       | mm = {{error|Conversion not implemented}}
       | mm = {{error|Conversion not implemented}}
      | in = {{error|Conversion to same unit}}
       | ft = {{error|Conversion not implemented}}
       | ft = {{error|Conversion not implemented}}
       | m = {{error|Conversion not implemented}}
       | m = {{error|Conversion not implemented}}
Line 24: Line 26:
       | mm = {{error|Conversion not implemented}}
       | mm = {{error|Conversion not implemented}}
       | in = {{error|Conversion not implemented}}
       | in = {{error|Conversion not implemented}}
       | m = {{#expr: {{{1}}} * 0.3048 round {{{4|0}}}}} {{#if: {{{5|}}}||m}}
      | ft = {{error|Conversion to same unit}}
       | m = {{User:Johan G/convert/rear|{{{1}}} * 0.3048|m|{{{4|}}}|{{{5|}}}}}
       | km = {{error|Conversion not implemented}}
       | km = {{error|Conversion not implemented}}
       | mi = {{error|Conversion not implemented}}
       | mi = {{error|Conversion not implemented}}
       | NM = {{#expr: {{{1}}} * 0.00016457883 round {{{4|0}}}}} {{#if: {{{5|}}}||NM}}
       | NM = {{User:Johan G/convert/rear|{{{1}}} * 0.00016457883|NM|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
     | m = {{#switch: {{{3|}}}
     | m = {{#switch: {{{3|}}}
       | mm = {{#expr: {{{1}}} div 0.001 round {{{4|0}}}}} {{#if: {{{5|}}}||mm}}
       | mm = {{User:Johan G/convert/rear|{{{1}}} div 0.001|mm|{{{4|}}}|{{{5|}}}}}
       | in = {{#expr: {{{1}}} div 0.0254 round {{{4|0}}}}} {{#if: {{{5|}}}||in}}
       | in = {{User:Johan G/convert/rear|{{{1}}} div 0.0254|in|{{{4|}}}|{{{5|}}}}}
       | ft = {{#expr: {{{1}}} div 0.3048 round {{{4|0}}}}} {{#if: {{{5|}}}||ft}}
       | ft = {{User:Johan G/convert/rear|{{{1}}} div 0.3048|ft|{{{4|}}}|{{{5|}}}}}
       | km = {{#expr: {{{1}}} div 1000 round {{{4|0}}}}} {{#if: {{{5|}}}||km}}
      | m = {{error|Conversion to same unit}}
       | mi = {{#expr: {{{1}}} div 1609.3 round {{{4|0}}}}} {{#if: {{{5|}}}||mi}}
       | km = {{User:Johan G/convert/rear|{{{1}}} div 1000|km|{{{4|}}}|{{{5|}}}}}
       | NM = {{#expr: {{{1}}} div 1852 round {{{4|0}}}}} {{#if: {{{5|}}}||NM}}
       | mi = {{User:Johan G/convert/rear|{{{1}}} div 1609.3|mi|{{{4|}}}|{{{5|}}}}}
       | NM = {{User:Johan G/convert/rear|{{{1}}} div 1852|NM|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
     | km = {{#switch: {{{3|}}}
     | km = {{#switch: {{{3|}}}
       | mm = {{#expr: {{{1}}} div 0.000001 round {{{4|0}}}}} {{#if: {{{5|}}}||mm}}
       | mm = {{User:Johan G/convert/rear|{{{1}}} div 0.000001|mm|{{{4|}}}|{{{5|}}}}}
       | in = {{#expr: {{{1}}} div 0.0000254 round {{{4|0}}}}} {{#if: {{{5|}}}||in}}
       | in = {{User:Johan G/convert/rear|{{{1}}} div 0.0000254|in|{{{4|}}}|{{{5|}}}}}
       | ft = {{#expr: {{{1}}} div 0.0003048 round {{{4|0}}}}} {{#if: {{{5|}}}||ft}}
       | ft = {{User:Johan G/convert/rear|{{{1}}} div 0.0003048|ft|{{{4|}}}|{{{5|}}}}}
       | m = {{#expr: {{{1}}} div 1 round {{{4|0}}}}} {{#if: {{{5|}}}||m}}
       | m = {{User:Johan G/convert/rear|{{{1}}} div 1000|m|{{{4|}}}|{{{5|}}}}}
       | mi = {{#expr: {{{1}}} div 1.6093 round {{{4|0}}}}} {{#if: {{{5|}}}||mi}}
      | km = {{error|Conversion to same unit}}
       | NM = {{#expr: {{{1}}} div 1.852 round {{{4|0}}}}} {{#if: {{{5|}}}||NM}}
       | mi = {{User:Johan G/convert/rear|{{{1}}} div 1.6093|mi|{{{4|}}}|{{{5|}}}}}
       | NM = {{User:Johan G/convert/rear|{{{1}}} div 1.852|NM|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
Line 53: Line 58:
       | ft = {{error|Conversion not implemented}}
       | ft = {{error|Conversion not implemented}}
       | m = {{error|Conversion not implemented}}
       | m = {{error|Conversion not implemented}}
       | km = {{#expr: {{{1}}} * 1.60934 round {{{4|0}}}}} {{#if: {{{5|}}}||km}}
       | km = {{User:Johan G/convert/rear|{{{1}}} * 1.60934|km|{{{4|}}}|{{{5|}}}}}
       | NM = {{#expr: {{{1}}} * 0.868976 round {{{4|0}}}}} {{#if: {{{5|}}}||NM}}
      | mi = {{error|Conversion to same unit}}
       | NM = {{User:Johan G/convert/rear|{{{1}}} * 0.868976|NM|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
Line 64: Line 70:
       | km = {{error|Conversion not implemented}}
       | km = {{error|Conversion not implemented}}
       | mi = {{error|Conversion not implemented}}
       | mi = {{error|Conversion not implemented}}
      | NM = {{error|Conversion to same unit}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
     | ft/s = {{#switch: {{{3|}}}
     | ft/s = {{#switch: {{{3|}}}
      | ft/s = {{error|Conversion to same unit}}
       | m/s = {{error|Conversion not implemented}}
       | m/s = {{error|Conversion not implemented}}
       | km/h = {{error|Conversion not implemented}}
       | km/h = {{error|Conversion not implemented}}
Line 75: Line 83:
     | m/s = {{#switch: {{{3|}}}
     | m/s = {{#switch: {{{3|}}}
       | ft/s = {{error|Conversion not implemented}}
       | ft/s = {{error|Conversion not implemented}}
      | m/s = {{error|Conversion to same unit}}
       | km/h = {{error|Conversion not implemented}}
       | km/h = {{error|Conversion not implemented}}
       | mph = {{error|Conversion not implemented}}
       | mph = {{error|Conversion not implemented}}
Line 83: Line 92:
       | ft/s = {{error|Conversion not implemented}}
       | ft/s = {{error|Conversion not implemented}}
       | m/s = {{error|Conversion not implemented}}
       | m/s = {{error|Conversion not implemented}}
      | km/h = {{error|Conversion to same unit}}
       | mph = {{error|Conversion not implemented}}
       | mph = {{error|Conversion not implemented}}
       | kt = {{error|Conversion not implemented}}
       | kt = {{error|Conversion not implemented}}
Line 90: Line 100:
       | ft/s = {{error|Conversion not implemented}}
       | ft/s = {{error|Conversion not implemented}}
       | m/s = {{error|Conversion not implemented}}
       | m/s = {{error|Conversion not implemented}}
       | km/h = {{error|Conversion not implemented}}
       | km/h = {{User:Johan G/convert/rear|{{{1}}} * 1.60934|km/h|{{{4|}}}|{{{5|}}}}}
       | kt = {{#expr: {{{1}}} * 0.869 round {{{4|0}}}}} {{#if: {{{5|}}}||kt}}
      | mph = {{error|Conversion to same unit}}
       | kt = {{User:Johan G/convert/rear|{{{1}}} * 0.869|kt|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
Line 98: Line 109:
       | m/s = {{error|Conversion not implemented}}
       | m/s = {{error|Conversion not implemented}}
       | km/h = {{error|Conversion not implemented}}
       | km/h = {{error|Conversion not implemented}}
       | mph = {{#expr: {{{1}}} * 1.152 round {{{4|0}}}}} {{#if: {{{5|}}}||mph}}
       | mph = {{User:Johan G/convert/rear|{{{1}}} * 1.152|mph|{{{4|}}}|{{{5|}}}}}
      | kt = {{error|Conversion to same unit}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
     | s = {{#switch: {{{3|}}}
     | s = {{#switch: {{{3|}}}
       | min = {{#expr: {{{1}}} div 60 round {{{4|0}}}}} {{#if: {{{5|}}}||min}}
      | s = {{error|Conversion to same unit}}
       | h = {{#expr: {{{1}}} div 3600 round {{{4|0}}}}} {{#if: {{{5|}}}||h}}
       | min = {{User:Johan G/convert/rear|{{{1}}} div 60|min|{{{4|}}}|{{{5|}}}}}
       | d = {{#expr: {{{1}}} div 86400 round {{{4|0}}}}} {{#if: {{{5|}}}||d}}
       | h = {{User:Johan G/convert/rear|{{{1}}} div 3600|h|{{{4|}}}|{{{5|}}}}}
       | d = {{User:Johan G/convert/rear|{{{1}}} div 86400|d|{{{4|}}}|{{{5|}}}}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}
     | min = {{#switch: {{{3|}}}
     | min = {{#switch: {{{3|}}}
       | s = {{error|Conversion not implemented}}
       | s = {{error|Conversion not implemented}}
      | min = {{error|Conversion to same unit}}
       | h = {{error|Conversion not implemented}}
       | h = {{error|Conversion not implemented}}
       | d = {{error|Conversion not implemented}}
       | d = {{error|Conversion not implemented}}
Line 116: Line 130:
       | s = {{error|Conversion not implemented}}
       | s = {{error|Conversion not implemented}}
       | min = {{error|Conversion not implemented}}
       | min = {{error|Conversion not implemented}}
      | h = {{error|Conversion to same unit}}
       | d = {{error|Conversion not implemented}}
       | d = {{error|Conversion not implemented}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
Line 123: Line 138:
       | min = {{error|Conversion not implemented}}
       | min = {{error|Conversion not implemented}}
       | h = {{error|Conversion not implemented}}
       | h = {{error|Conversion not implemented}}
      | d = {{error|Conversion to same unit}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
       | #default = {{error|Parameter '''to-unit''' missing or not supported}}
     }}
     }}

Latest revision as of 19:02, 6 August 2018

Parameter value missing

The following template description is not displayed when the template is inserted in an article.

Goal

This template can be used to...

Adding this template to a page will automatically add Category:... to that page.

Caution Caution that might help prevent lost work, very complicated debugging etc...

Note Note that might be helpful or lead the reader in the right direction.

Usage

{{convert|value|from-unit|to-unit|decimals|hide-unit}}

The parameters value, from-unit and to-unit are mandatory, and the other optional

value
Value to be converted from one unit to another.
from-unit
Unit to be converted from
to-unit
Unit to be converted to
decimals
Number of decimals. If empty, no decimals will be shown
hide-unit
If not empty the unit will not be shown in the result

Examples

Examples using different options.

Supported units

Conversion between some of these units have been implemented.

Units of length

mm millimeter
in inches
ft feet
m meters
km kilometers
mi statute miles
NM nautical miles

Units of velocity

ft/s feet per second
m/s meters per second
km/h kilometers per hour
mph statute miles per hour
kt knots

Units of time

s seconds
min minutes
h hours
d days

Known issues

Known issues and workarounds if such are known.

Related templates