quick commit
This commit is contained in:
@@ -47,7 +47,6 @@ WeatherWidget::WeatherWidget() : Gtk::Box(Gtk::Orientation::VERTICAL) {
|
||||
dailyScroll.set_valign(Gtk::Align::START);
|
||||
dailyScroll.set_halign(Gtk::Align::FILL);
|
||||
|
||||
|
||||
this->append(currentScroll);
|
||||
this->append(hourlyScroll);
|
||||
this->append(dailyScroll);
|
||||
@@ -143,11 +142,11 @@ void WeatherWidget::fetchWeather() {
|
||||
dw.apparent_temperature_max = daily["apparent_temperature_max"][i].get<double>();
|
||||
dw.precipitation_sum = daily["precipitation_sum"][i].get<double>();
|
||||
dw.weather_code = daily["weather_code"][i].get<int>();
|
||||
auto time_str = daily["time"][i].get<std::string>();
|
||||
std::tm tm = {};
|
||||
auto time_str = daily["time"][i].get<std::string>();
|
||||
std::tm tm = {};
|
||||
std::istringstream ss(time_str);
|
||||
ss >> std::get_time(&tm, "%Y-%m-%d");
|
||||
|
||||
|
||||
std::mktime(&tm);
|
||||
char buffer[10];
|
||||
std::strftime(buffer, sizeof(buffer), "%a", &tm);
|
||||
@@ -156,11 +155,11 @@ void WeatherWidget::fetchWeather() {
|
||||
this->daily_weather[i] = dw;
|
||||
}
|
||||
|
||||
auto hourly = json["hourly"];
|
||||
auto hourly = json["hourly"];
|
||||
auto current_time = std::time(nullptr);
|
||||
auto nextHour = std::localtime(¤t_time)->tm_hour + 1;
|
||||
auto currentHour = std::localtime(¤t_time)->tm_hour;
|
||||
|
||||
for (int i = nextHour; i < nextHour + 24; i ++) {
|
||||
for (int i = currentHour; i < currentHour + 24; i++) {
|
||||
HourlyWeather hw{};
|
||||
hw.temperature_2m = hourly["temperature_2m"][i].get<double>();
|
||||
hw.apparent_temperature = hourly["apparent_temperature"][i].get<double>();
|
||||
@@ -169,7 +168,7 @@ void WeatherWidget::fetchWeather() {
|
||||
hw.precipitation = hourly["precipitation"][i].get<double>();
|
||||
hw.time = hourly["time"][i].get<std::string>().substr(11, 5);
|
||||
|
||||
this->hourly_weather[i - nextHour] = hw;
|
||||
this->hourly_weather[i - currentHour] = hw;
|
||||
}
|
||||
|
||||
} catch (const std::exception &ex) {
|
||||
|
||||
Reference in New Issue
Block a user