function _weather_format_relative_humidity in Weather 6.5
Same name and namespace in other branches
- 5.6 weather.module \_weather_format_relative_humidity()
- 5 weather.module \_weather_format_relative_humidity()
Calculate the relative humidity
Parameters
float Temperature (must be Celsius):
float Dewpoint (must be Celsius):
Return value
string Formatted representation
1 call to _weather_format_relative_humidity()
- theme_weather_theming in ./
weather.module - Custom theme function for preprocessing the weather block output
File
- ./
weather.module, line 1762 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function _weather_format_relative_humidity($temperature, $dewpoint) {
$e = 6.11 * pow(10, 7.5 * $dewpoint['celsius'] / (237.7 + $dewpoint['celsius']));
$es = 6.11 * pow(10, 7.5 * $temperature['celsius'] / (237.7 + $temperature['celsius']));
$result = t('!rel_humidity %', array(
'!rel_humidity' => max(0, min(100, round(100 * ($e / $es), 0))),
));
return preg_replace("/([^ ]*) ([^ ]*)/", '<span style="white-space:nowrap;">\\1 \\2</span>', $result);
}