// Learn about the ESP32 WiFi simulation in
// https://docs.wokwi.com/guides/esp32-wifi

#include <WiFi.h>

#define NTP_SERVER     "pool.ntp.org"
#define UTC_OFFSET     -28800
#define UTC_OFFSET_DST +3600

void setup() {
  Serial.begin(115200);

  WiFi.begin("Wokwi-GUEST", "", 6);
  Serial.print("Connecting to WiFi.");
  while (WiFi.status() != WL_CONNECTED) {
    delay(250);
    Serial.print('.');
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  configTime(UTC_OFFSET, UTC_OFFSET_DST, NTP_SERVER);
}

void loop() {
  printLocalTime();
  delay(250);
}

void printLocalTime() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) {
    Serial.println("Connection Err");
    return;
  }

  Serial.println(&timeinfo, "%I:%M:%S");
  Serial.println(&timeinfo, "%m/%d/%Y   %Z");
}