Fingerprint and RTC

Hello everyone, i have a question about fingerprint and RTC.
I use these two sensor to make a project about absency with schedule.
I using adafruit fingerprint library for the fingerprint and I use RTClib library for the RTC.
And this is my code

#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal.h>
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial (2,3);
Adafruit_Fingerprint finger=Adafruit_Fingerprint(&mySerial);
int id;

RTC_DS1307 rtc;
int days;
int months;
int years;
int hours;
int minutes;
int seconds;
int totalsec1;
int totalsec2;

LiquidCrystal lcd (A2,A3,7,6,5,4);

bool stat=0;
String data;

void setup() {
Serial.begin(9600);
Wire.begin();
rtc.begin();
rtc.adjust(DateTime(F(DATE), F(TIME)));
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
lcd.begin(16,2);
finger.begin(57600);
if (finger.verifyPassword())
{
Serial.println(“Found fingerprint sensor!”);
} else
{
Serial.println(“Did not find fingerprint sensor :(”);
while(1);
}
Serial.println(“Waiting for valid finger…”);
}

void loop() {
DateTime now = rtc.now();
years=now.year();
months=now.month();
days=now.day();
hours=now.hour();
minutes=now.minute();
seconds=now.second();
DateTime dt0(years,months,days,6,30,0);
DateTime dt1(years,months,days,1,0,0);
DateTime dt2(years,months,days,hours,minutes,seconds);
TimeSpan ts0=dt2-dt0;
TimeSpan ts1=dt2-dt1;
totalsec1=ts0.totalseconds();
totalsec2=ts1.totalseconds();
Serial.println(totalsec1);
Serial.println(totalsec2);

if(hours>=6&&minutes>=30&&0<=totalsec1&&totalsec1<=5400)
{
digitalWrite(A0, HIGH);
digitalWrite(A1, LOW);
Serial.println(“IF 1 OK”);
getFingerprintID();
}
else if(hours>=1&&0<=totalsec2&&totalsec2<=5400)
{
digitalWrite(A0, HIGH);
digitalWrite(A1, LOW);
Serial.println(“IF 2 OK”);
getFingerprintID();
}
else
{
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
Serial.println(“IF 3 OK”);
}
delay(1000);
}

uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println(“Image taken”);
break;
case FINGERPRINT_NOFINGER:
Serial.println(“No finger detected”);
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println(“Communication error”);
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println(“Imaging error”);
return p;
default:
Serial.println(“Unknown error”);
return p;
}

// OK success!

p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
Serial.println(“Image converted”);
break;
case FINGERPRINT_IMAGEMESS:
Serial.println(“Image too messy”);
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println(“Communication error”);
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println(“Could not find fingerprint features”);
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println(“Could not find fingerprint features”);
return p;
default:
Serial.println(“Unknown error”);
return p;
}

// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK) {
Serial.println(“Found a print match!”);
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println(“Communication error”);
return p;
} else if (p == FINGERPRINT_NOTFOUND) {
Serial.println(“Did not find a match”);
return p;
} else {
Serial.println(“Unknown error”);
return p;
}

// found a match!
id=finger.fingerID;
Serial.print(“Found ID #”);
Serial.print(id);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

The problem is when this program reach to read fingerprint, the program is always return to setup. So the RTC can’t work properly because is always reset and return to setup.

Anyone can help me? Thanks