You are here

function _weather_format_temperature in Weather 5

Same name and namespace in other branches
  1. 5.6 weather.module \_weather_format_temperature()
  2. 6.5 weather.module \_weather_format_temperature()

Convert temperatures

Parameters

int Temperature, always in degree celsius:

string The unit to be returned (metric, imperial):

Return value

string Formatted representation, either in celsius or fahrenheit

1 call to _weather_format_temperature()
theme_weather in ./weather.module
Custom theme function for the weather block output

File

./weather.module, line 703
Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world

Code

function _weather_format_temperature($temperature, $unit) {
  if (!isset($temperature)) {
    return t('No data');
  }
  if ($unit == 'imperial') {
    return t('!temperature &deg;F', array(
      '!temperature' => $temperature['fahrenheit'],
    ));
  }
  else {

    // default to metric units
    return t('!temperature &deg;C', array(
      '!temperature' => $temperature['celsius'],
    ));
  }
}