You are here

function weather_format_relative_humidity in Weather 7

Calculate relative humidity.

Parameters

int $temperature: Temperature (degree Celsius).

int $dewpoint: Dewpoint (degree Celsius).

Return value

string Formatted representation.

1 call to weather_format_relative_humidity()
theme_weather_theming in ./weather_theme.inc
Custom theme function for preprocessing the weather display.

File

./weather_theme.inc, line 524
Prepare themed weather output.

Code

function weather_format_relative_humidity($temperature, $dewpoint) {
  $e = 6.11 * pow(10, 7.5 * $dewpoint / (237.7 + $dewpoint));
  $es = 6.11 * pow(10, 7.5 * $temperature / (237.7 + $temperature));
  $result = t('!rel_humidity %', array(
    '!rel_humidity' => max(0, min(100, round(100 * ($e / $es), 0))),
  ));
  return preg_replace("/([^ ]*)&thinsp;([^ ]*)/", '<span style="white-space:nowrap;">\\1&thinsp;\\2</span>', $result);
}