BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/util/Bs_UnitConverter.class.php
BlueShoes Application Framework - util

Bs_UnitConverter

Bs_Object
   |
  +-- Bs_UnitConverter

Pseudostatic utility class to convert units.

 

public class Bs_UnitConverter extends Bs_Object

Pseudostatic utility class to convert units.
dependencies: none.source: i've collected information from the web, especially fromhttp://www.digitaldutch.com/unitconverter/ i don't think you can copyrightthe relations of units to each other or their names. so there cannot bea license violation.

Authors
Version4.0.$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

string

length(string $from, string $to, string $value, [ integer $precision ])

converts length.
string

temperature(string $from, string $to, string $value, [ integer $precision ])

converts temperature.
string

bitsAndBytes(string $from, string $to, string $value)

converts bits, bytes etc.
string

toUsefulBitAndByteString(mixed $bytes)

takes a number of bytes and converts it to a useful string.
int

unitStringToBytes(mixed $unitStr)

Takes a string with unit (200KB, 1.2M, 0.23G, ...) and converts ist to bytes (int or float)
void

Bs_UnitConverter()

Warning: documentation is missing.

Private Constant Summary

BS_UNITCONVERTER_VERSION >>4.0.$x$<< Warning: documentation is missing.
U_KB >>1024<< Warning: documentation is missing.
U_MB >>1048576<< Warning: documentation is missing.
U_GB >>1073741824<< Warning: documentation is missing.
U_TB >>1099511627776<< Warning: documentation is missing.
U_PB >>1125899906842624<< Warning: documentation is missing.
U_EB >>1152921504606846976<< Warning: documentation is missing.

Public Method Details

length

public string length( string $from, string $to, string $value, [ integer $precision ] )

  converts length.
can convert the following units (alphabetic listing):+---------------+------------------------------------+| KEY | DESCRIPTION |+---------------+------------------------------------+| cables | || cm | centimeters || chains | chains (surveyors) || dm | decimeters || ells | elles (UK) || fathoms | || feet | feet (UK and US) || furlongs | || hands | || hm | hectometers || inches | || km | kilometers || m | meters || miles | miles (UK and US) || milesNautical | miles (nautical) || mm | millimeters || yards | |+---------------+------------------------------------+not implemented but relations known: ångströms [Å], astronomical units [AU],barleycorns, ems (pica), feet (US survey), light years, micrometers, parsecs,picometers.

Parameter
string $from
(see key above)
string $to
(see key above)
string $value
integer $precision = >>3<<
to round. Using PHP's round() func.
Returns string

Throws FALSE (on unknown/misspelled units)

temperature

public string temperature( string $from, string $to, string $value, [ integer $precision ] )

  converts temperature.
can convert the following units:celsius, fahrenheit, kelvin, rankine, réaumure

Parameter
string $from
string $to
string $value
integer $precision = >>3<<
to round. Using PHP's round() func.
Returns string

Throws FALSE (on unknown/misspelled units)

bitsAndBytes

public string bitsAndBytes( string $from, string $to, string $value )

  converts bits, bytes etc.
can convert the following units:bits, bytes, kilobits, kilobytes, megabits, megabytes, gigabits, gigabytes,terabits, terabytes, petabits, petabytes, exabits, exabytes

Parameter
string $from
string $to
string $value
Returns string


toUsefulBitAndByteString

public string toUsefulBitAndByteString( mixed $bytes )

  takes a number of bytes and converts it to a useful string.
eg (todo)

Parameter
mixed $bytes
(numeric, can be string int double)
Returns string


unitStringToBytes

public int unitStringToBytes( mixed $unitStr )

  Takes a string with unit (200KB, 1.2M, 0.23G, ...) and converts ist to bytes (int or float)
Acceped units (case insensitive): K,M,G,T,P,E and KB,MB,GB,TB,PB,EBPARAM:If numeric we assume it as absloute byte size.If string it may end with 'k' of 'M' (for kilo-,Mega-byte) OR '%'If ending with '%' this means use x% of the available memory as given bymemory_limit in the php.ini file. But we never exeed 80%.

Parameter
mixed $unitStr
(see above)
Returns int

The set buffersize in byte.

Throws FALSE on error. (Buffer size is left unchanged)

Bs_UnitConverter

public void Bs_UnitConverter( )

 

Warning: documentation is missing.

Returns void


Private Constant Details

BS_UNITCONVERTER_VERSION

define( BS_UNITCONVERTER_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



U_KB

define( U_KB, >>1024<< )
Case: default: case sensitive



U_MB

define( U_MB, >>1048576<< )
Case: default: case sensitive



U_GB

define( U_GB, >>1073741824<< )
Case: default: case sensitive



U_TB

define( U_TB, >>1099511627776<< )
Case: default: case sensitive



U_PB

define( U_PB, >>1125899906842624<< )
Case: default: case sensitive



U_EB

define( U_EB, >>1152921504606846976<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta