function _yr_verdata_temperature in Yr Weatherdata 7
Same name and namespace in other branches
- 6.2 yr_verdata.module \_yr_verdata_temperature()
Function for resolving the temperature.
Parameters
$temp: The temperature property of a tab object from the xml. Must be an array with 'unit' and 'value'. Currently, only the unit 'celsius' is provided from yr.no.
Return value
Returns an array with output-safe temperatures in celsius, Fahrenheit and Kelvin.
1 call to _yr_verdata_temperature()
- theme_yr_verdata_temp in ./
yr_verdata.module - Function for generating a themed temperature display.
File
- ./
yr_verdata.module, line 1236 - yr_verdata.module This file contains the code for getting the forecast from yr.no and displaying it on a Drupal site.
Code
function _yr_verdata_temperature($temp) {
$temperature = array();
switch ($temp['unit']) {
case 'celsius':
$temperature['celsius'] = (int) $temp['value'];
$temperature['fahrenheit'] = round($temp['value'] * 9 / 5 + 32);
$temperature['kelvin'] = $temp['value'] + 273;
break;
}
$temperature['class'] = $temperature['celsius'] > 0 ? 'warm' : 'cold';
return $temperature;
}