Bonjour à tous,
J'ai écrit un code qui me permet de recuperer les infos de la couleur des jours Tempo.
Si je prends ce code:
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
Serial.println("Failed to obtain time");
return;
}
//recuperation date et heure
char timeDay[3];
strftime(timeDay, 3, "%d", &timeinfo);
jour = String(timeDay);
char timeMonth[4];
strftime(timeMonth, 4, "%m", &timeinfo);
mois = String(timeMonth);
char timeYear[6];
strftime(timeYear, 6, "%Y", &timeinfo);
an = String(timeYear);
today = an + "-" + mois + "-" + jour
HTTPClient http;
String url = "https://www.services-rte.com/cms/open_data/v1/tempo?season=" + season;
http.begin(url);
String recup = http.getString();
// Décode le JSON
DynamicJsonDocument doc(40000);
deserializeJson(doc, recup);
JsonObject values = doc["values"];
JourJJ = doc["values"][today] | "UNKNOWN";
J'ai bien today = 2024-09-22 et jourJJ = "BLUE"
Si je prends ce code:
struct tm timeinfo;
date = String(DayMonth);
char Today[15];
strftime(Today, 15, "%Y-%m-%d ", &timeinfo);
today = String(Today);
HTTPClient http;
String url = "https://www.services-rte.com/cms/open_data/v1/tempo?season=" + season;
http.begin(url);
String recup = http.getString();
// Décode le JSON
DynamicJsonDocument doc(40000);
deserializeJson(doc, recup);
JsonObject values = doc["values"];
JourJJ = doc["values"][today] | "UNKNOWN";
J'ai bien today = 2024-09-22 mais jourJJ = "UNKNOWN"
en faisant:
if (today.equals("2024-09-22"))
Dans le premier cas c'est true, dans le second c'est false.
Une idée?