46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Global Temperature Functions
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| This is a home for functions that don't belong to any one class and
|
|
| that should be available anywhere in the application.
|
|
|
|
|
*/
|
|
|
|
if (! function_exists('celsius2Fahrenheit')) {
|
|
/**
|
|
* Convert from celsius to fahrenheit.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @param float|int|string $celsius
|
|
* @param int $precision
|
|
*
|
|
* @return float
|
|
*/
|
|
function celsius2Fahrenheit($celsius, int $preceision = 0): float
|
|
{
|
|
return round((($celsius * (9/5)) + 32), $preceision);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('fahrenheit2Celsius')) {
|
|
/**
|
|
* Convert from fahrenheit to celsius.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @param float|int|string $fahrenheit
|
|
* @param int $precision
|
|
*
|
|
* @return float
|
|
*/
|
|
function fahrenheit2Celsius($fahrenheit, int $preceision = 1): float
|
|
{
|
|
return round(($fahrenheit - 32 * (5/9)), $preceision);
|
|
}
|
|
}
|