not declearedin this scope

Hi im a new programmer in arduino. I have been learning and trying to connect esp8266 and a RTC DS3231 … but my program just doesnt work . it worked before i added and removed code:
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); this means me so much so please someone help me
this is the intire code:

#include <Wire.h>
#include <RtcDS3231.h>
RtcDS3231<TwoWire> Rtc(Wire);
#include <ESP8266WiFi.h>                              // pins:  + = 3V
#include <ESP8266mDNS.h>                              //        D = D2
#include <WiFiUdp.h>                                  //        C = D1
#include <ArduinoOTA.h>                               //        - = Ground 
#ifndef STASSID
#define STASSID "sorry not risking with my wifi" //"sorry not risking with my wifi"
#define STAPSK "sorry not risking with my wifi" //"sorry not risking with my wifi"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

unsigned long loop_timing = 0;


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

  init_wifi();
  ArduinoOTA.setHostname("ANDRI_ESP8266");
  init_ota();
  pinMode(D4, OUTPUT);
  }


void loop() {
  static bool blink_status = 0;
         // sets the delay between time printing
  if (millis() - loop_timing >= 1000) {
    loop_timing = millis();
    
    RtcDateTime now = Rtc.GetDateTime();
    printDateTime(now);
    Serial.println();

    RtcTemperature temp = Rtc.GetTemperature();
    temp.Print(Serial);
    Serial.println("C");
    
    Serial.printf("loop_timing: %u\n", loop_timing);

    digitalWrite(D4, blink_status);
    blink_status = !blink_status;
  }
  

  ArduinoOTA.handle();
}

void init_wifi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
    rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
  }
}

void init_ota() {
  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "sketch";
    } else { // U_SPIFFS
      type = "filesystem";
    }

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Auth Failed");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Begin Failed");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Connect Failed");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Receive Failed");
    } else if (error == OTA_END_ERROR) {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();
  Serial.println("\nResetting via RST pin...");
  Serial.println("\n Ready for use");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}
  }

#define countof(a) (sizeof(a) / sizeof(a[0]))

void printDateTime(const RtcDateTime& dt)
{
  char datestring[20];

  snprintf_P(datestring,
             countof(datestring),
             PSTR("%02u/%02u/%04u %02u:%02u:%02u"),
             dt.Month(),
             dt.Day(),
             dt.Year(),
             dt.Hour(),
             dt.Minute(),
             dt.Second() );
  Serial.print(datestring);
}

@REALCyberWolf

To get the best out of the forum please read the sticky posts at the TOP of each section before posting. You were in the wrong area so got moved here.

Bob.

Variables can only be used in the function in which they are declared. So if you declare a variable (e.g. int age = 27;) inside the setup() function you can only use it inside setup(). It will not work if your try to use it inside any other function (e.g. loop() ) If you want to be able to use it elsewhere you need to declare it as a global variable before the setup().

Do a search for "scope Arduino" for more information.

Do a search for "scope Arduino" for more information

Search C++ scope for good stuff too. The Arduino is programmed in C++ so those are the tutorials you want to find.

You have an extra '}' at the end of init_ota() which causes a problem with declaring printDateTime().

You try to call 'rtc.adjust()' but your RTC is named "Rtc", not "rtc". Also, the RtcDS3231 library doesn't seem to have an 'adjust' function so it's going to fail anyway.