function _weather_format_relative_humidity in Weather 5
Same name and namespace in other branches
- 5.6 weather.module \_weather_format_relative_humidity()
- 6.5 weather.module \_weather_format_relative_humidity()
Calculate the relative humidity
The function uses celsius as input
1 call to _weather_format_relative_humidity()
- theme_weather in ./
weather.module - Custom theme function for the weather block output
File
- ./
weather.module, line 833 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function _weather_format_relative_humidity($temperature, $dewpoint) {
if (!isset($dewpoint)) {
return t('No data');
}
$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']));
return max(0, min(100, round(100 * ($e / $es), 0))) . "%";
}