updates/fixes

This commit is contained in:
Mars 2024-07-31 00:07:40 -04:00
parent 3ebbb2b3ec
commit 3f4b24c259
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895
5 changed files with 61 additions and 33 deletions

View file

@ -1,3 +1,4 @@
#include <chrono>
#include <curl/curl.h>
#include <fmt/core.h>
#include <rfl/json.hpp>
@ -96,9 +97,9 @@ fn Weather::getWeatherInfo() const -> WeatherOutput {
// Check if cache is valid
if (Result<WeatherOutput> data = ReadCacheFromFile()) {
if (WeatherOutput dataVal = *data;
system_clock::now() - system_clock::time_point(seconds(dataVal.dt)) <
minutes(10)) { // Assuming cache duration is always 10 minutes
WeatherOutput dataVal = *data;
if (system_clock::now() - system_clock::time_point(seconds(dataVal.dt)) < minutes(10)) {
fmt::println("Cache is valid. Returning cached data.");
return dataVal;