Current temperature ("Now") always displayed in Farenheit (see attached)

The settings on admin/settings/google-weather affect only "Weather forecast" section and temperature sign (C of F) in "Now" section but value in "Now" section always represent the temperature in Farenheit.

Comments

VSZ’s picture

StatusFileSize
new15.23 KB

Here is the attached screenshot

illutek’s picture

StatusFileSize
new621 bytes

I had the same problem

In the file google_weather-block.tpl.php on line 18 I have following code ' print $content['current']['temp']; ' replaced by

        // Make sure everything is converted into html entities
          $data = htmlentities($content['current']['temp']); 
        
        // Remove this Acirc; character and split at degrees
        $data = str_replace('Â', '', $data);
        $data = explode('°', $data, 2);
        
        // Check if data is needed in Celsius
        if ( $data[1] == 'C' ) {
            $data[0] = (int)(($data[0] - 32) / 1.8);
        }
                
        // Put everything back together
        print implode('°', $data);
        
adpo’s picture

I have the same problem in IE, and Chrome. No problem with firefox. After your update, IE and Chrome are fine, but Firefox displays wrong temperature.

kubala.webdesign’s picture

Assigned: Unassigned » kubala.webdesign

There is no dependency on web browser - all was work on server side, browser just display static HTML content.
I'll fix it ASAP.

adpo’s picture

I have found that drupal omits your module setting in favour of user languge settings.

lmparra’s picture

Hello, I had the same problem, and I have solved that.

In the file google_weather.module line 156 I have replaced:

<?php
'temp' => $convert_to == 'SI' ? (string) $today->temp_c->attributes()->data . $unit : (string) $today->temp_f->attributes()->data . $unit,
?>

By

<?php 
'temp' => $convert_to == 'SI' ? (string) $today->temp_f->attributes()->data . $unit : (string) $today->temp_c->attributes()->data . $unit,
?>
osfa’s picture

Component: User interface » Code
StatusFileSize
new13.93 KB

Solution for ºC.

Line 156 of the file google_weather.module
Original > 'temp' => $convert_to == 'SI' ? (string) $today->temp_c->attributes()->data . $unit : (string) $today->temp_f->attributes()->data . $unit,

New > 'temp' => (string) google_weather_convert($today->temp_c->attributes()->data, $convert_to) . $unit,

No need to change google_weather-block.tpl.php
This is the solution with less impact i have found.

Kubala.webdesign, as you are the mantainer, can you add this correction if necessary? I guess you are the only one who can upload new versions of the overall module.

Thanks.

4kant’s picture

Thanks osfa!
It works well for me.

jvandooren’s picture

Status: Active » Needs review
StatusFileSize
new709 bytes

Osfa's solution works for me as well.

I attached a patch with the change suggested in #7

jvandooren’s picture

After further testing, I noticed this fix is not entirely correct. Applying this fix triggers the another bug: #1075664: After Translating my website the temperature changes depending on language.

The following patch will fix both bugs.