Serenifly:
Die Schaltjahrkorrektur wird in der RTC selbst gemacht.
Sommmer/Winterzeit kann man leicht selbst machen. Hier ist eine Funktion um zu berechnen um gerade Sommerzeit ist:
RTC mit Sommerzeit - #3 by jurs - Deutsch - Arduino Forum
boolean summertime_EU(int year, byte month, byte day, byte hour, byte tzHours)
// European Daylight Savings Time calculation by "jurs" for German Arduino Forum
// input parameters: "normal time" for year, month, day, hour and tzHours (0=UTC, 1=MEZ)
// return value: returns true during Daylight Saving Time, false otherwise
{
if (month<3 || month>10) return false; // keine Sommerzeit in Jan, Feb, Nov, Dez
if (month>3 && month<10) return true; // Sommerzeit in Apr, Mai, Jun, Jul, Aug, Sep
if (month==3 && (hour + 24 * day)>=(1 + tzHours + 24*(31 - (5 * year /4 + 4) % 7)) || month==10 && (hour + 24 * day)<(1 + tzHours + 24*(31 - (5 * year /4 + 1) % 7)))
return true;
else
return false;
}
Je nachdem addiert man dann noch eine Stunden drauf oder nicht
In der Lib ist das nicht drin, weil es unterschiedliche Zeitumstellungen gibt, je nachdem wo man sich befindet.
Am besten kaufst du dir übrigens eine DS3231:
http://www.ebay.de/itm/DS3231-AT24C32-IIC-Real-Time-Clock-Memory-Modul-RTC-fur-Arduino-AVR-UNO-ARM-PIC-/281140941523?pt=Bauteile&hash=item41754e52d3
Ich habe nicht so schlechte Erfahrungen mit der DS1307 gemacht wie viele andere, aber sie geht trotzdem schnell falsch
sagt mal rechnet der falsch?
der liefert in 2018, Oktober 2 Uhr schon Winterzeit dabei wird erst um 3
Uhr zurückgestellt!
mein Code rechnet zumindest richtig!
Start!
2018/03/26_12:09:13 MESZ
2018/03/26_12:09:14 MESZ
-------
(2018, 3, 25, 1, 1) 01. MEZ
(2018, 3, 25, 2, 1) 02.MESZ
(2018, 3, 25, 3, 1) 03.MESZ
(2018, 10, 28, 1, 1) 04.MESZ
(2018, 10, 28, 2, 1) 05.MESZ
(2018, 10, 28, 3, 1) 06. MEZ
-------
06.MESZ
-------
2018/03/26_12:09:14 MESZ
boolean summertime_EU(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, int8_t tzHours)
// European Daylight Savings Time calculation by "jurs" for German Arduino Forum
// input parameters: "normal time" for year, month, day, hour and tzHours (0=UTC, 1=MEZ)
// return value: returns true during Daylight Saving Time, false otherwise
{
/*
// !!!!!!!!!!! RECHNET falsch !!!!!!!!!!
if (month<3 || month>10) return false; // keine Sommerzeit in Jan, Feb, Nov, Dez
if (month>3 && month<10) return true; // Sommerzeit in Apr, Mai, Jun, Jul, Aug, Sep
if (month==3 && (hour + 24 * day)>=(1 + tzHours + 24*(31 - (5 * year /4 + 4) % 7)) || month==10 && (hour + 24 * day)<(1 + tzHours + 24*(31 - (5 * year /4 + 1) % 7)))
return true;
else
return false;
*/
// !!!!!!!!!!! RECHNET richtig !!!!!!!!!!
uint8_t beginnMESZ = tagesnummer( year, 3, 31 );
uint16_t endeMESZ = tagesnummer( year, 10, 31 );
// uint8_t mo=month;
uint16_t tij=tagesnummer(year, month, day);
if(month > 2 && month < 11) // 11, 12, 1 und 2 haben keine Sommerzeit
{ // auf Sommerzeit korrigieren
while(wochentag_im_jahr(year, beginnMESZ) != 7)
beginnMESZ--;
while(wochentag_im_jahr(year, endeMESZ) != 7)
endeMESZ--;
if( tij>beginnMESZ && tij<endeMESZ )
return true;
else
{ if( tij==beginnMESZ && hour>=2 )
return true;
if( tij==endeMESZ && hour<3 )
return true;
}
} // if(mo > 2 && mo < 11)
return false;
} // boolean summertime_EU(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, int8_t tzHours)