mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 00:41:09 +02:00
fix postcode with leading zeros
Origin commit data
------------------
Commit: eef63535ae
Author: TangoCash <eric@loxat.de>
Date: 2022-01-20 (Thu, 20 Jan 2022)
This commit is contained in:
@@ -182,9 +182,12 @@ bool CWeather::GetWeatherDetails()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CWeather::FindCoords(int postcode, std::string country)
|
||||
bool CWeather::FindCoords(int postcode, std::string country, int pc_len)
|
||||
{
|
||||
std::string data = "http://api.openweathermap.org/geo/1.0/zip?zip=" + std::to_string(postcode) + ","+country+"&appid=" + key;
|
||||
std::string pcode = std::to_string(postcode);
|
||||
unsigned int number_of_zeros = pc_len - pcode.length();
|
||||
pcode.insert(0, number_of_zeros, '0');
|
||||
std::string data = "http://api.openweathermap.org/geo/1.0/zip?zip=" + pcode + "," + country + "&appid=" + key;
|
||||
JSONCPP_STRING answer;
|
||||
JSONCPP_STRING formattedErrors;
|
||||
Json::CharReaderBuilder builder;
|
||||
|
@@ -91,7 +91,7 @@ class CWeather
|
||||
~CWeather();
|
||||
bool checkUpdate(bool forceUpdate = false);
|
||||
void setCoords(std::string new_coords, std::string new_city = "Unknown");
|
||||
bool FindCoords(int postcode, std::string country = "DE");
|
||||
bool FindCoords(int postcode, std::string country = "DE", int pc_len = 5);
|
||||
|
||||
// globals
|
||||
std::string getCity()
|
||||
|
Reference in New Issue
Block a user