MCPcopy Create free account
hub / github.com/HASwitchPlate/openHASP / printLocalTime

Function printLocalTime

src/log/hasp_debug.cpp:414–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412{}
413
414void printLocalTime()
415{
416 char buffer[128];
417 time_t rawtime;
418 struct tm* timeinfo;
419
420 // if(!time(nullptr)) return;
421
422 time(&rawtime);
423 timeinfo = localtime(&rawtime);
424
425 strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo);
426 Serial.println(buffer);
427 // struct tm timeinfo;
428 // time_t now = time(nullptr);
429
430 // Serial-.print(ctime(&now));
431 // Serial.print(&timeinfo, " %d %B %Y %H:%M:%S ");
432
433#if LWIP_VERSION_MAJOR > 1
434
435 // LwIP v2 is able to list more details about the currently configured SNTP servers
436 for(int i = 0; i < SNTP_MAX_SERVERS; i++) {
437 IPAddress sntp = *sntp_getserver(i);
438 const char* name = sntp_getservername(i);
439 if(sntp.isSet()) {
440 Serial.printf("sntp%d: ", i);
441 if(name) {
442 Serial.printf("%s (%s) ", name, sntp.toString().c_str());
443 } else {
444 Serial.printf("%s ", sntp.toString().c_str());
445 }
446 Serial.printf("IPv6: %s Reachability: %o\n", sntp.isV6() ? D_YES : D_NO, sntp_getreachability(i));
447 }
448 }
449#endif
450}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected