// Arduino DS3232RTC Library
// https://github.com/JChristensen/DS3232RTC
//
// Example sketch illustrating Time library with Real Time Clock.
// This example is similar to the example provided with the Time Library.
// The #include statement has been changed to include the DS3232RTC library,
// a DS3232RTC object has been defined (myRTC) and the begin() method is called.
#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
byte Sommerzeit=0;
DS3232RTC myRTC;
void setup()
{
Serial.begin(115200);
myRTC.begin();
setSyncProvider(myRTC.get); // the function to get the time from the RTC
if(timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
set_sommerzeit();
}
byte oktober[5]={30,29,27,30,29};
byte maerz[5]={27,26,29,26,25};
int akt_jahr=2022;
byte j=0;
void set_sommerzeit()
{
for (byte y=0; y<=5; y++)
{
if(akt_jahr+y==year())
{
j=y;
}
}
if(year())
if(month()<3 && month()>10) // Prüfung nach Monate außerhalb der Umstellung
{
Sommerzeit=1;
}
else
{
// Umstellung im März
if(month()==3 && day()>=maerz[j])
{
Sommerzeit=1;
}
//Umstellung im Oktober
if(month()==10 && day()>=oktober[j])
{
Sommerzeit=1;;
}
}
}
void loop()
{
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour()-Sommerzeit);
printDigits(minute());
printDigits(second());
Serial.println();
Serial.println(weekday());
}
void printDigits(int digits)
{
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(':');
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}