I am getting
error: 'getLocalTime' was not declared in this scope
when I am compiling this code for ESP8266, however works for ESP32:
#include "time.h"
void gettime()
{
static int16_t delaycount = 0 ; // To reduce number of NTP requests
static int16_t retrycount = 100 ;
if ( timeinfo.tm_year ) // Legal time found?
{
sprintf ( timetxt, "%02d:%02d:%02d", // Yes, format to a string
timeinfo.tm_hour,
timeinfo.tm_min,
timeinfo.tm_sec ) ;
}
if ( --delaycount <= 0 ) // Sync every few hours
{
delaycount = 7200 ; // Reset counter
if ( timeinfo.tm_year ) // Legal time found?
{
dbgprint ( "Sync TOD, old value is %s", timetxt ) ;
}
dbgprint ( "Sync TOD" ) ;
if ( !getLocalTime ( &timeinfo ) ) // Read from NTP server
{
dbgprint ( "Failed to obtain time!" ) ; // Error
timeinfo.tm_year = 0 ; // Set current time to illegal
if ( retrycount ) // Give up syncing?
{
retrycount-- ; // No try again
delaycount = 5 ; // Retry after 5 seconds
}
}
else
{
sprintf ( timetxt, "%02d:%02d:%02d", // Format new time to a string
timeinfo.tm_hour,
timeinfo.tm_min,
timeinfo.tm_sec ) ;
dbgprint ( "Sync TOD, new value is %s", timetxt ) ;
}
}
}
What shall I replace getLocalTime with?