Closed hhhorb closed 9 years ago
Personally I wouldn't want this to be the extension's standard behavior, as I'd hate the loss of precision. But if that's how you wanted the extension to work, the easiest way would be to change the temperature_string
method in extension.js
to output values the way you want.
In the current code all values are rounded to 1 decimal place regardless of units system (on line 1110), so to process different temp-units differently that would have to be moved inside the switch(unit)
statement immediately following. This should do what you want, in a quick-and-dirty way. (The parseInt()
probably isn't necessary, but I put it in there for symmetry with the rest of the code.)
To add this as a supported feature, I'd prefer a configuration switch be added to make it optional, but that'd be up to Neroth.
diff --git a/extension.js b/extension.js
index 3c60d57..02d98da 100644
--- a/extension.js
+++ b/extension.js
@@ -1107,19 +1107,20 @@ const WEATHER_DEBUG_EXTENSION = 'debug-extension'; // Weather extension settin
if(!a)
temp = this.info.get_value_temp(unit)[1];
- temp = parseFloat(Math.round(temp*10)/10).toLocaleString();
-
switch(unit)
{
case GWeather.TemperatureUnit.FAHRENHEIT :
+ temp = parseInt(Math.round(temp), 10).toLocaleString();
return _("%s °F").replace("%s", temp);
break;
case GWeather.TemperatureUnit.CENTIGRADE :
+ temp = parseFloat(Math.round(temp*10)/10).toLocaleString();
return _("%s °C").replace("%s", temp);
break;
case GWeather.TemperatureUnit.KELVIN :
+ temp = parseFloat(Math.round(temp*10)/10).toLocaleString();
return _("%s K").replace("%s", temp);
break;
@Frank, perfect, thanks so much for this and the quick response!
Closing this issue, manually editing the file is fine. Cheers!
Fahrenheit is only used in the U.S. and a few other countries, but nobody ever displays the temperature as a direct conversion from Celsius (87.8 degrees, for example). Can the display be rounded to the nearest degree? If you're too busy, which part of which file could I look at to hack this on my own?
Many thanks, you're extension seems to be much more accurate than the Openweather one. Cheers!