diff options
| author | George Hazan <george.hazan@gmail.com> | 2025-04-17 16:54:34 +0300 |
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2025-04-17 16:54:34 +0300 |
| commit | edd9531655f0462bbb7f4b11e514d5f2569228af (patch) | |
| tree | 8a962f65c85e18c2e611abc30b1ac0341357c0e0 | |
| parent | 7c868a3010cdc5a6b00821943ecae66db7489277 (diff) | |
Weather: fix for displaying current data
| -rw-r--r-- | protocols/Weather/src/weather_update.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 2b4f86d9ca..7e44869876 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -364,7 +364,7 @@ static double g_elevation = 0; static void getData(OBJLIST<WIDATAITEM> &arValues, const JSONNode &node) { - arValues.insert(new WIDATAITEM(LPGENW("Date"), L"", parseConditions(node["datetime"].as_mstring()))); + arValues.insert(new WIDATAITEM(LPGENW("Date"), L"", node["datetime"].as_mstring())); arValues.insert(new WIDATAITEM(LPGENW("Condition"), L"", parseConditions(node["conditions"].as_mstring()))); arValues.insert(new WIDATAITEM(LPGENW("Temperature"), L"C", node["temp"].as_mstring())); arValues.insert(new WIDATAITEM(LPGENW("High"), L"C", node["tempmax"].as_mstring())); @@ -433,18 +433,22 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact) int iFore = 0; db_set_ws(hContact, WEATHERCONDITION, "Update", curr["datetime"].as_mstring()); + for (auto &it : arValues) { + ConvertDataValue(it); + if (!it->Value.IsEmpty()) + db_set_ws(hContact, WEATHERCONDITION, _T2A(it->Name), it->Value); + } + for (auto &fore : root["days"]) { - getData(arValues, fore); + OBJLIST<WIDATAITEM> arDaily(20); + getData(arDaily, fore); CMStringW result; - for (auto &it : arValues) { + for (auto &it : arDaily) { ConvertDataValue(it); if (it->Value.IsEmpty()) continue; - if (iFore == 0) - db_set_ws(hContact, WEATHERCONDITION, _T2A(it->Name), it->Value); - if (!result.IsEmpty()) result += L"; "; result.AppendFormat(L"%s: %s", TranslateW(it->Name), it->Value.c_str()); |
