cevepe
November 30, 2021, 3:35pm
1
I read the clock from NTP and then ESP32 uses it, see the code:
void printLocalTime()
{
time(&now);
localtime_r(&now, &myTimeInfo);
strftime(NTPdatum, sizeof(NTPdatum), "%H:%M:%S %d.%m.%Y", &myTimeInfo);
}
But I would like to do a function where in the month 4 to 9 in the time 4 to 21 hours the function returns false to me, otherwise true.
How can I achieve this?
Please post a complete sketch rather than just a snippet
Where are you stuck ?
The first step is to look up what fields are in 'myTimeInfo'. I expect you will get a month and an hour.
boolean function()
{
time(&now);
localtime_r(&now, &myTimeInfo);
return !(myTimeInfo.month >= 4 && myTimeInfo.month <= 9 &&
myTimeInfo.hour >= 4 && myTimeInfo.hour <= 21);
}
system
Closed
May 29, 2022, 5:46pm
4
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.