Biber Unit Converter (BUC)

1.0.3
Can Oğuz
16.03.2012

Biber Unit Converter enables you to convert different units of the same measurement type to each other from within your ExpressionEngine 2.x templates.

Supports the following units:

Angle

  • arcminute
  • arcsecond
  • circle
  • degree
  • grad
  • octant
  • quadrant
  • radian
  • sextant
  • sign
  • turn

Density

  • g/cm3
  • g/l
  • g/ml
  • kg/m3
  • kg/l
  • mg/ml
  • mg/l
  • ounce/inch3
  • pound/foot3
  • tonne/m3

Digital Storage

  • bit
  • byte
  • Kbit
  • Kbyte
  • Mbit
  • Mbyte
  • Gbit
  • Gbyte
  • Tbit
  • Tbyte
  • Pbit
  • Pbyte
  • Ebit
  • Ebyte

Electric Current

  • A
  • abA
  • Bi
  • C/s
  • EMU
  • ESU
  • G
  • GA
  • Gi
  • kA
  • MA
  • muA
  • nA
  • V/omega
  • W/V

Energy

  • cal
  • hph
  • J
  • MJ
  • kJ
  • Wh
  • Ws

Force

  • dyn
  • kgf
  • kN
  • MN
  • N
  • lbf
  • t

Length / Area

  • cm
  • dm
  • ft
  • inch
  • km
  • m
  • mil
  • yards

Power

  • th/h
  • th/min
  • th/s
  • cal/h
  • cal/min
  • GW
  • HP
  • J/h
  • J/m
  • J/s
  • kW
  • lbF
  • MW
  • N
  • W

Pressure

  • atm
  • bar
  • cmHG
  • cmH20
  • fH2O
  • inH2O
  • inHg
  • mbar
  • Pa

Speed

  • c
  • cm/min
  • cm/sec
  • ft/h
  • ft/min
  • ft/sec
  • inch/min
  • inch/sec
  • km/h
  • knot
  • mach
  • m/h
  • m/min
  • m/s
  • yard/h
  • yard/min
  • yard/s

Temparature

  • celcius
  • fahrenheit
  • kelvin

Time

  • d
  • h
  • m,n
  • msec
  • nsec
  • w
  • y

Volume

  • barrel
  • dm3
  • gallon
  • lt
  • pint
  • tablespoon
  • teaspoon
  • Pa

Weight

  • carat
  • cg
  • dg
  • g
  • kg
  • lbs
  • mg
  • oz
  • tonne

Installation

Put the folder from the unpacked file into “third_party” folder.

Parameters

  • power
    Defines the power of conversion. i.e. 3 of dm3
    Default value is 1.
  • replace_unit
    Replaces the original output for unit.
  • round
    Defines whether to round up or down the output.
    up, down,
  • round_by
    Defines the decimal place for the rounding procedure.
    Default value is 0.
  • show_unit
    Used to hide the unit in returned value.
    true, false (false is default value)
  • unit_from
    Unit that you want the value to be converted from.
  • unit_position
    Defines the position of the unit comparing to output.
    before, after (after is the default value).
  • unit_to
    Unit that you want the value to be converted in.
  • unit_type
    Type of unit to be converted.
    angle, density, digital_storage, electric_currency, energy, force, length, power_units, pressure_units, speed, temperature, time, volume, weight
  • value
    Defines the value to be converted.

Units

You can use the below units with unit_to & unit_from parameters:

angle

  • arcminute
  • arcsecond
  • circle
  • turn
  • degree
  • grad
  • octant
  • quadrant
  • radian
  • sextant
  • sign

density_units

  • g/cm3
  • g/l
  • g/ml
  • kg/m3
  • kg/l
  • mg/ml
  • mg/l
  • ounce/inch3
  • pound/foot3
  • tonne/m3

digital_storage

  • bit
  • byte
  • Kbit
  • Kbyte
  • Mbit
  • Mbyte
  • Gbit
  • Gbyte
  • Tbit
  • Tbyte
  • Pbit
  • Pbyte
  • Ebit
  • Ebyte

electric_currency

  • abA
  • A
  • C/s
  • V/omega
  • W/V
  • Bi
  • EMU
  • ESU
  • G
  • GA
  • Gi
  • kA
  • MA
  • mA
  • µA
  • nA

energy

  • J
  • Nm
  • Ws
  • kJ
  • Wh
  • cal
  • MJ
  • hph

force

  • dyn
  • kgf
  • kN
  • MN
  • N
  • lbF
  • t

length

  • mil
  • km
  • m
  • dm
  • cm
  • mm
  • ft
  • inch
  • yards

power_units

  • th/h
  • th/min
  • cal/h
  • cal/min
  • th/s
  • GW
  • N
  • lbF
  • HP
  • W
  • J/h
  • J/min
  • J/s
  • kW
  • MW

pressure_units

  • atm
  • bar
  • cmHG
  • cmH2O
  • fH2O
  • inH2O,
  • inHg
  • mbar
  • Pa

speed

  • cm/min
  • cm/sec
  • ft/h
  • ft/min
  • ft/sec
  • inch/min
  • inch/sec
  • km/h
  • knot
  • mach
  • m/h
  • m/min
  • m/s
  • yard/h
  • yard/min
  • yard/s
  • c

temperature

  • celcius
  • fahrenheit
  • kelvin

time

  • y
  • w
  • d
  • h
  • min
  • sec
  • msec
  • nsec

volume

  • dm3
  • barrel(s)
  • gallon(s)
  • lt
  • pint(s)
  • tablespoon(s)
  • teaspoon(s)

weight

  • kg
  • g
  • dg
  • cg
  • mg
  • lbs
  • tonne
  • carat
  • oz

Usage

Below examples will help you to understand the plugin:

Simple usage

{exp:bbr_unit_converter unit_type="length" unit_from="m" unit_to="km"}

	1500
	{/exp:bbr_unit_converter}

result: 1

Showing the unit

{exp:bbr_unit_converter unit_type="length" unit_from="m" unit_to="km" show_unit="true"}
1500
	{/exp:bbr_unit_converter}

result: 1 km

Showing the unit before the value

{exp:bbr_unit_converter unit_type="length" unit_from="m" unit_to="km" show_unit="true" unit_position="before"}
1500
	{/exp:bbr_unit_converter}

result: km 1

Replacing the unit

{exp:bbr_unit_converter unit_type="length" unit_from="m" unit_to="km" show_unit="true" replace_unit="kilometer(s)"}
1500
	{/exp:bbr_unit_converter}

result: 1 kilometer(s)

Rounding

 

{exp:bbr_unit_converter unit_type="length" unit_from="m" unit_to="km" show_unit="true" round_by="2" round="up"}
1755
	{/exp:bbr_unit_converter}

result: 1.76 km

Using the power parameter

{exp:bbr_unit_converter unit_type="length" unit_from="dm" unit_to="m" power="3"}
1000
	{/exp:bbr_unit_converter}

result: 1