Good Morning,
I'm using the ESP32 and VScode PlatformIO IDE and I have a couple of String related questions:
1. What is the difference between "String" and "string"? I can declare variables with either
- String test1 = "test1";
- string test2 = "test2";
2. The below printLocalTime function sends out the required DateTime on the serial port.
I would like to have this as a global string.
After looking on the web, the below Print::print function was put forward but I do not understand a) how to call this and b) how it returns a string
size_t Print::print(struct tm * timeinfo, const char * format)
{
const char * f = format;
if(!f){
f = "%c";
}
char buf[64];
size_t written = strftime(buf, 64, f, timeinfo);
print(buf);
return written;
}
void printLocalTime()
{
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time");
return;
}
Serial.println(&timeinfo, "%Y-%m-%d %H:%M:%S");
}