function weather_format_pressure in Weather 7
Same name and namespace in other branches
- 7.3 weather_theme.inc \weather_format_pressure()
- 7.2 weather_theme.inc \weather_format_pressure()
Convert pressure.
Parameters
int $pressure: Pressure in hPa.
string $unit: Unit to be returned (for example, inHg, mmHg, hPa, kPa).
Return value
string Formatted representation.
1 call to weather_format_pressure()
- theme_weather_theming in ./
weather_theme.inc - Custom theme function for preprocessing the weather display.
File
- ./
weather_theme.inc, line 492 - Prepare themed weather output.
Code
function weather_format_pressure($pressure, $unit) {
if ($unit == 'inhg') {
$result = t('!pressure inHg', array(
'!pressure' => round($pressure * 0.02953, 2),
));
}
elseif ($unit == 'mmhg') {
$result = t('!pressure mmHg', array(
'!pressure' => round($pressure * 0.7500599999999999, 0),
));
}
elseif ($unit == 'kpa') {
$result = t('!pressure kPa', array(
'!pressure' => round($pressure / 10, 1),
));
}
else {
// default to metric units
$result = t('!pressure hPa', array(
'!pressure' => $pressure,
));
}
return preg_replace("/([^ ]*) ([^ ]*)/", '<span style="white-space:nowrap;">\\1 \\2</span>', $result);
}