add time source

This commit is contained in:
2024-03-23 15:11:49 +02:00
parent 23e197789f
commit 0555185044
10 changed files with 123 additions and 36 deletions

View File

@ -93,9 +93,9 @@ QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) const
// main data
QVariantMap mainWeather = _json["main"].toMap();
if (!weather.isEmpty()) {
output[tag("humidity")] = mainWeather["humidity"].toFloat();
output[tag("pressure")] = mainWeather["pressure"].toFloat();
output[tag("temperature")] = mainWeather["temp"].toFloat();
output[tag("humidity")] = mainWeather["humidity"].toDouble();
output[tag("pressure")] = mainWeather["pressure"].toDouble();
output[tag("temperature")] = mainWeather["temp"].toDouble();
}
// timestamp

View File

@ -86,7 +86,7 @@ QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const
values[tag("timestamp")] = condition["date"].toString();
values[tag("humidity")] = _atmosphere["humidity"].toInt();
// HACK temporary fix of invalid values on Yahoo! side
values[tag("pressure")] = static_cast<int>(_atmosphere["pressure"].toFloat() / 33.863753);
values[tag("pressure")] = static_cast<int>(_atmosphere["pressure"].toDouble() / 33.863753);
return values;
}
@ -103,7 +103,7 @@ QVariantHash YahooWeatherProvider::parseForecast(const QVariantMap &_json) const
values[tag("weatherId")] = id;
values[tag("timestamp")] = weatherMap["date"].toString();
// yahoo provides high and low temperatures. Lets calculate average one
values[tag("temperature")] = (weatherMap["high"].toFloat() + weatherMap["low"].toFloat()) / 2.0;
values[tag("temperature")] = (weatherMap["high"].toDouble() + weatherMap["low"].toDouble()) / 2.0;
// ... and no forecast data for humidity and pressure
values[tag("humidity")] = 0;
values[tag("pressure")] = 0.0;